Class: Io::Flow::V0::Models::LocalizedPrice
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::LocalizedPrice
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The localized prices for an item are returned as a list - the key of each element is defined here
Direct Known Subclasses
LocalizedItemDuty, LocalizedItemPrice, LocalizedItemVat, LocalizedPriceUndefinedType, LocalizedTotal
Defined Under Namespace
Modules: Types
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ LocalizedPrice
constructor
A new instance of LocalizedPrice.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ LocalizedPrice
Returns a new instance of LocalizedPrice.
4675 4676 4677 4678 4679 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4675 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name], 'LocalizedPrice') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) end |
Class Method Details
.from_json(hash) ⇒ Object
4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4689 def LocalizedPrice.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:key].to_s.strip if discriminator.empty? raise "Union type[localized_price] requires a field named 'key'" end case discriminator when Types::LOCALIZED_ITEM_PRICE; LocalizedItemPrice.new(hash) when Types::LOCALIZED_ITEM_VAT; LocalizedItemVat.new(hash) when Types::LOCALIZED_ITEM_DUTY; LocalizedItemDuty.new(hash) when Types::LOCALIZED_TOTAL; LocalizedTotal.new(hash) else LocalizedPriceUndefinedType.new(:name => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
4681 4682 4683 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4681 def subtype_to_hash raise 'Cannot serialize an instance of localized_price directly - must use one of the specific types: localized_item_price, localized_item_vat, localized_item_duty, localized_total' end |
#to_hash ⇒ Object
4685 4686 4687 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4685 def to_hash subtype_to_hash.merge(:key => @name) end |