Class: Io::Flow::V0::Models::ItemPriceUpdateForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ItemPriceUpdateForm
- 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
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ ItemPriceUpdateForm
constructor
A new instance of ItemPriceUpdateForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ItemPriceUpdateForm
Returns a new instance of ItemPriceUpdateForm.
42216 42217 42218 42219 42220 42221 42222 42223 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42216 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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
42214 42215 42216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42214 def attributes @attributes end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
42214 42215 42216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42214 def currency @currency end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
42214 42215 42216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42214 def number @number end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
42214 42215 42216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42214 def price @price end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
42229 42230 42231 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42229 def copy(incoming={}) ItemPriceUpdateForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
42233 42234 42235 42236 42237 42238 42239 42240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42233 def to_hash { :number => number, :currency => currency, :price => price.to_f.to_s, :attributes => attributes } end |
#to_json ⇒ Object
42225 42226 42227 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42225 def to_json JSON.dump(to_hash) end |