Class: Xdelivery::API::Orders
- Inherits:
-
Base
- Object
- Base
- Xdelivery::API::Orders
show all
- Includes:
- Enumerable
- Defined in:
- lib/xdelivery/api/orders.rb
Constant Summary
collapse
- COLUMNS =
[
:order_id, :provider, :recipient, :mobile, :email, :store_id, :store_name, :address,
:items, :warehouse_items, :total_order_amount, :cash_on_delivery, :order_created_at,
:note, :callback_url, :ref_id, :tag, :merchant_note, :shop_id
]
- INVOICE_COLUMNS =
[
:create_type, :email, :company_code, :company_title, :donate_code, :device_id, :device, :items
]
Constants inherited
from Base
Base::BASE_URL
Instance Attribute Summary collapse
Attributes inherited from Base
#access_key, #merchant_no
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Attribute Details
#orders ⇒ Object
Returns the value of attribute orders.
6
7
8
|
# File 'lib/xdelivery/api/orders.rb', line 6
def orders
@orders
end
|
Instance Method Details
#[](index) ⇒ Object
33
34
35
|
# File 'lib/xdelivery/api/orders.rb', line 33
def [](index)
orders[index]
end
|
#add(params, invoice_params = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/xdelivery/api/orders.rb', line 18
def add(params, invoice_params={})
self.orders ||= []
(params || {}).delete_if do |k, v|
COLUMNS.include?(k) == false
end
invoice_params.delete_if do |k, v|
INVOICE_COLUMNS.include?(k) == false
end
params.merge!(invoice: invoice_params) unless invoice_params.empty?
orders.push(params)
params
end
|
#count ⇒ Object
37
38
39
|
# File 'lib/xdelivery/api/orders.rb', line 37
def count
orders.count
end
|
#create! ⇒ Object
41
42
43
44
|
# File 'lib/xdelivery/api/orders.rb', line 41
def create!
response = post('/orders/batch.json')
Response::Orders.new(response)
end
|