Class: Io::Flow::V0::Models::ItemPriceUpdateForm

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

Overview

The item price update form is used to update only the price (and attributes, eg. msrp) of given item. This form defines the format of the CSV import.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ItemPriceUpdateForm

Returns a new instance of ItemPriceUpdateForm.



35920
35921
35922
35923
35924
35925
35926
35927
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35920

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :price], 'ItemPriceUpdateForm')
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @currency = (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, 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.



35918
35919
35920
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35918

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



35918
35919
35920
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35918

def currency
  @currency
end

#numberObject (readonly)

Returns the value of attribute number.



35918
35919
35920
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35918

def number
  @number
end

#priceObject (readonly)

Returns the value of attribute price.



35918
35919
35920
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35918

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35933
35934
35935
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35933

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

#to_hashObject



35937
35938
35939
35940
35941
35942
35943
35944
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35937

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

#to_jsonObject



35929
35930
35931
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35929

def to_json
  JSON.dump(to_hash)
end