Class: B2W::Product
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#[], camel_case, endpoint, execute, get, #initialize, #persisted?, post, #put, to_params, token, version
Constructor Details
This class inherits a constructor from B2W::Base
Class Method Details
.create!(params) ⇒ Object
3
4
5
6
7
8
|
# File 'lib/b2w/product.rb', line 3
def self.create!(params)
post(:product, params) do |body, request, result|
yield body, request, result if block_given?
new persisted: result.is_a?(Net::HTTPCreated)
end
end
|
.find(sku) ⇒ Object
26
27
28
|
# File 'lib/b2w/product.rb', line 26
def self.find(sku)
get "sku/#{sku}"
end
|
Instance Method Details
#cod_terc_exists? ⇒ Boolean
38
39
40
|
# File 'lib/b2w/product.rb', line 38
def cod_terc_exists?
bool_operation { self.class.get "product/#{id}" }
end
|
#exists? ⇒ Boolean
34
35
36
|
# File 'lib/b2w/product.rb', line 34
def exists?
bool_operation { self.class.get "sku/#{sku}" }
end
|
#update!(params) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/b2w/product.rb', line 10
def update!(params)
bool_operation do
self.class.post("product/#{sku}/sku", params) do |body, request, result|
binding.pry
yield body, request, result if block_given?
end
end
end
|
#update_price! ⇒ Object
19
20
21
22
23
24
|
# File 'lib/b2w/product.rb', line 19
def update_price!
put(:sku, "#{sku}/price", sellPrice: self['sell_price'], listPrice: self['list_price']) do |body, request, result|
binding.pry
yield body, request, result if block_given?
end
end
|
#update_stock! ⇒ Object
30
31
32
|
# File 'lib/b2w/product.rb', line 30
def update_stock!
put(:sku, "#{sku}/stock", quantity: self['quantity'])
end
|