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.



30086
30087
30088
30089
30090
30091
30092
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30086

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.



30084
30085
30086
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30084

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



30084
30085
30086
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30084

def currency
  @currency
end

#priceObject (readonly)

Returns the value of attribute price.



30084
30085
30086
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30084

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30098
30099
30100
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30098

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

#to_hashObject



30102
30103
30104
30105
30106
30107
30108
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30102

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

#to_jsonObject



30094
30095
30096
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30094

def to_json
  JSON.dump(to_hash)
end