Class: Xdelivery::API::Products

Inherits:
Base
  • Object
show all
Includes:
Enumerable
Defined in:
lib/xdelivery/api/products.rb

Constant Summary collapse

COLUMNS =
[
  :days_produce, :qty_day_average, :qty_week_average, :qty_month_average, :qty_owe
]

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

Constructor Details

This class inherits a constructor from Xdelivery::API::Base

Instance Attribute Details

#productsObject

Returns the value of attribute products.



6
7
8
# File 'lib/xdelivery/api/products.rb', line 6

def products
  @products
end

Instance Method Details

#set(code, params) ⇒ Object



12
13
14
15
16
# File 'lib/xdelivery/api/products.rb', line 12

def set(code, params)
  self.products ||= []
  params.delete_if { |k, v| COLUMNS.include?(k) == false }
  products.push(params.merge(code: code))
end

#update!Object



18
19
20
21
# File 'lib/xdelivery/api/products.rb', line 18

def update!
  response = patch('/products/update_all.json')
  Response::Products.new(response)
end