Class: Io::Flow::V0::Models::ItemPriceUpdatePutForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ItemPriceUpdatePutForm

Returns a new instance of ItemPriceUpdatePutForm.



32630
32631
32632
32633
32634
32635
32636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32630

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:currency, :price], 'ItemPriceUpdatePutForm')
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @price = HttpClient::Preconditions.assert_class('price', HttpClient::Helper.to_big_decimal(opts.delete(:price)), BigDecimal)
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



32628
32629
32630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32628

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



32628
32629
32630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32628

def currency
  @currency
end

#priceObject (readonly)

Returns the value of attribute price.



32628
32629
32630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32628

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



32642
32643
32644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32642

def copy(incoming={})
  ItemPriceUpdatePutForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



32646
32647
32648
32649
32650
32651
32652
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32646

def to_hash
  {
    :currency => currency,
    :price => price.to_f.to_s,
    :attributes => attributes
  }
end

#to_jsonObject



32638
32639
32640
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32638

def to_json
  JSON.dump(to_hash)
end