Sha256: 76621952bdeeb5f34bdfdb7484e18482a211ea3d24c14cc5b9f77cde2b5f1abe
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module Xdelivery module API class Orders < Base include Enumerable attr_accessor :orders 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 ] INVOICE_COLUMNS = [ :create_type, :email, :company_code, :donate_code, :device_id, :device, :items, :invoice_setting_id ] 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 def [](index) orders[index] end def count orders.count end def create! response = post('/orders/batch.json') Response::Orders.new(response) end protected def post_data { import: { orders: orders } } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xdelivery-0.2.1 | lib/xdelivery/api/orders.rb |
xdelivery-0.2.0 | lib/xdelivery/api/orders.rb |