class MoySklad::Model::Good
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/moy_sklad/model/good.rb, line 3 def initialize(*args) super(*args) create_nested_collection(:barcode) end
Public Instance Methods
add_barcode(code, options)
click to toggle source
# File lib/moy_sklad/model/good.rb, line 24 def add_barcode(code, options) barcode = create_and_load_resource("barcode", {barcode: code}.merge(options)) if to_a(:barcode).empty? self.barcode = [barcode] else self.barcode << barcode end end
get_sale_price(uuid)
click to toggle source
# File lib/moy_sklad/model/good.rb, line 19 def get_sale_price(uuid) create_nested_resource(:salePrices) self.salePrices.find_object(:price, :priceTypeUuid, uuid) end
set_sale_price(type, value, currency)
click to toggle source
# File lib/moy_sklad/model/good.rb, line 8 def set_sale_price(type, value, currency) create_nested_resource(:salePrices) v = self.salePrices.find_object(:price, :priceTypeUuid, type) if v.nil? create_price(type, value, currency) else v.value = value.to_i end end
Private Instance Methods
create_price(type, value, currency)
click to toggle source
# File lib/moy_sklad/model/good.rb, line 35 def create_price(type, value, currency) options = { currencyUuid: currency, priceTypeUuid: type, value: value.to_i } p = create_and_load_resource('Price', options) if self.salePrices.price.is_a?(MoySklad::Client::Attribute::MissingAttr) self.salePrices.price = [p] else self.salePrices.price << p end end