class B2W::Product
Public Class Methods
create!(params) { |body, request, result| ... }
click to toggle source
# 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)
click to toggle source
# File lib/b2w/product.rb, line 30 def self.find(sku) get "sku/#{sku}" end
Public Instance Methods
cod_terc_exists?()
click to toggle source
# File lib/b2w/product.rb, line 26 def cod_terc_exists? bool_operation { self.class.get "product/#{id}" } end
exists?()
click to toggle source
# File lib/b2w/product.rb, line 22 def exists? bool_operation { self.class.get "sku/#{sku}" } end
update!(params)
click to toggle source
# File lib/b2w/product.rb, line 10 def update!(params) bool_operation { self.class.post "product/#{sku}/sku", params } end
update_price!()
click to toggle source
# File lib/b2w/product.rb, line 14 def update_price! put(:sku, "#{sku}/price", sellPrice: self['sell_price'], listPrice: self['list_price']) end
update_stock!()
click to toggle source
# File lib/b2w/product.rb, line 18 def update_stock! put(:sku, "#{sku}/stock", quantity: self['quantity']) end
Private Instance Methods
bool_operation() { || ... }
click to toggle source
# File lib/b2w/product.rb, line 36 def bool_operation begin yield true rescue RestClient::ResourceNotFound false rescue RestClient::UnprocessableEntity false end end
id()
click to toggle source
# File lib/b2w/product.rb, line 51 def id self['id'] end
sku()
click to toggle source
# File lib/b2w/product.rb, line 47 def sku self['sku'] end