Class: AliexpressAPI::DsLogistic

Inherits:
Base
  • Object
show all
Defined in:
lib/aliexpress_api/resources/ds_logistic.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Methods inherited from Base

#[], #[]=, activate_session, app_key, app_secret, #as_json, connection, #initialize, #respond_to_missing?, service_endpoint, session, session=, #to_hash, #to_json

Methods included from ThreadsafeAttributes

included

Constructor Details

This class inherits a constructor from AliexpressAPI::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AliexpressAPI::Base

Class Method Details

.freights(params = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/aliexpress_api/resources/ds_logistic.rb', line 6

def freights(params = {})
  params = {
    method: 'aliexpress.logistics.buyer.freight.calculate',
    param_aeop_freight_calculate_for_buyer_d_t_o: params.dup
  }

  response = post(service_endpoint, params)
  result = response['aliexpress_logistics_buyer_freight_calculate_response']['result']

  unless result['success']
    raise ResultError.new(result, message: result['error_desc'])
  end

  list = result['aeop_freight_calculate_result_for_buyer_d_t_o_list']['aeop_freight_calculate_result_for_buyer_dto']
  list.map(&:with_indifferent_access)
end

.tracking_info(params) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/aliexpress_api/resources/ds_logistic.rb', line 23

def tracking_info(params)
  params = params.merge(
    method: 'aliexpress.logistics.ds.trackinginfo.query',
    origin: 'ESCROW'
  )
  response = post(service_endpoint, params)
  result = response['aliexpress_logistics_ds_trackinginfo_query_response']

  unless result['result_success']
    raise ResultError.new(result, message: result['error_desc'])
  end

  {
    official_website: result['official_website'],
    details: result['details']['details']
  }.with_indifferent_access
end