Class: Io::Flow::V0::Models::LocalItemPricing
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::LocalItemPricing
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Localized item pricing information
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#duty ⇒ Object
readonly
Returns the value of attribute duty.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#price_attributes ⇒ Object
readonly
Returns the value of attribute price_attributes.
-
#shipping ⇒ Object
readonly
Returns the value of attribute shipping.
-
#vat ⇒ Object
readonly
Returns the value of attribute vat.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ LocalItemPricing
constructor
A new instance of LocalItemPricing.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ LocalItemPricing
Returns a new instance of LocalItemPricing.
48766 48767 48768 48769 48770 48771 48772 48773 48774 48775 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48766 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:price, :attributes], 'LocalItemPricing') @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::LocalizedItemPrice) ? x : ::Io::Flow::V0::Models::LocalizedItemPrice.new(x)) @vat = (x = opts.delete(:vat); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LocalizedItemVat) ? x : ::Io::Flow::V0::Models::LocalizedItemVat.new(x))) @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LocalizedItemDuty) ? x : ::Io::Flow::V0::Models::LocalizedItemDuty.new(x))) @shipping = (x = opts.delete(:shipping); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))) @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = (x = d[1]; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)); h } @price_attributes = (x = opts.delete(:price_attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('price_attributes', x, Hash).inject({}) { |h, d| h[d[0]] = (x = d[1]; x.is_a?(::Io::Flow::V0::Models::LocalItemAttributePricing) ? x : ::Io::Flow::V0::Models::LocalItemAttributePricing.new(x)); h }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
48764 48765 48766 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48764 def attributes @attributes end |
#duty ⇒ Object (readonly)
Returns the value of attribute duty.
48764 48765 48766 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48764 def duty @duty end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
48764 48765 48766 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48764 def price @price end |
#price_attributes ⇒ Object (readonly)
Returns the value of attribute price_attributes.
48764 48765 48766 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48764 def price_attributes @price_attributes end |
#shipping ⇒ Object (readonly)
Returns the value of attribute shipping.
48764 48765 48766 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48764 def shipping @shipping end |
#vat ⇒ Object (readonly)
Returns the value of attribute vat.
48764 48765 48766 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48764 def vat @vat end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
48781 48782 48783 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48781 def copy(incoming={}) LocalItemPricing.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
48785 48786 48787 48788 48789 48790 48791 48792 48793 48794 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48785 def to_hash { :price => price.to_hash, :vat => vat.nil? ? nil : vat.to_hash, :duty => duty.nil? ? nil : duty.to_hash, :shipping => shipping.nil? ? nil : shipping.to_hash, :attributes => attributes.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1].to_hash; hash }, :price_attributes => price_attributes.nil? ? nil : price_attributes.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1].to_hash; hash } } end |
#to_json ⇒ Object
48777 48778 48779 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48777 def to_json JSON.dump(to_hash) end |