Class: AliexpressAPI::DsOrder

Inherits:
Base
  • Object
show all
Defined in:
lib/aliexpress_api/resources/ds_order.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

.create!(attributes = {}) ⇒ Object



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

def create!(attributes = {})
  params = {
    method: 'aliexpress.trade.buy.placeorder',
    param_place_order_request4_open_api_d_t_o: attributes
  }
  response = post(service_endpoint, params)
  result = response['aliexpress_trade_buy_placeorder_response']['result']

  unless result['is_success']
    raise ResultError.new(result, message: result['error_msg'] || result['error_code'])
  end

  result['order_list']
end

.find(id) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/aliexpress_api/resources/ds_order.rb', line 21

def find(id)
  params = {
    method: 'aliexpress.trade.ds.order.get',
    single_order_query: { order_id: id }
  }
  response = post(service_endpoint, params)
  result = response['aliexpress_trade_ds_order_get_response']['result']
  new(result)
end