Class: Io::Flow::V0::Models::Local
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Local
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#experience ⇒ Object
readonly
Returns the value of attribute experience.
-
#price_attributes ⇒ Object
readonly
Returns the value of attribute price_attributes.
-
#prices ⇒ Object
readonly
Returns the value of attribute prices.
-
#rates ⇒ Object
readonly
Returns the value of attribute rates.
-
#spot_rates ⇒ Object
readonly
Returns the value of attribute spot_rates.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Local
constructor
A new instance of Local.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Local
Returns a new instance of Local.
45202 45203 45204 45205 45206 45207 45208 45209 45210 45211 45212 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45202 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:experience, :prices, :rates, :spot_rates], 'Local') @experience = (x = opts.delete(:experience); x.is_a?(::Io::Flow::V0::Models::ExperienceSummary) ? x : ::Io::Flow::V0::Models::ExperienceSummary.new(x)) @prices = HttpClient::Preconditions.assert_class('prices', opts.delete(:prices), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LocalizedPrice) ? x : ::Io::Flow::V0::Models::LocalizedPrice.from_json(x)) } @rates = HttpClient::Preconditions.assert_class('rates', opts.delete(:rates), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Rate) ? x : ::Io::Flow::V0::Models::Rate.new(x)) } @spot_rates = HttpClient::Preconditions.assert_class('spot_rates', opts.delete(:spot_rates), Array).map { |v| HttpClient::Preconditions.assert_class('spot_rates', HttpClient::Helper.to_object(v), Hash) } @status = (x = (x = opts.delete(:status); x.nil? ? "included" : x); x.is_a?(::Io::Flow::V0::Models::SubcatalogItemStatus) ? x : ::Io::Flow::V0::Models::SubcatalogItemStatus.apply(x)) @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); 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::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)); h }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
45200 45201 45202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45200 def attributes @attributes end |
#experience ⇒ Object (readonly)
Returns the value of attribute experience.
45200 45201 45202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45200 def experience @experience end |
#price_attributes ⇒ Object (readonly)
Returns the value of attribute price_attributes.
45200 45201 45202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45200 def price_attributes @price_attributes end |
#prices ⇒ Object (readonly)
Returns the value of attribute prices.
45200 45201 45202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45200 def prices @prices end |
#rates ⇒ Object (readonly)
Returns the value of attribute rates.
45200 45201 45202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45200 def rates @rates end |
#spot_rates ⇒ Object (readonly)
Returns the value of attribute spot_rates.
45200 45201 45202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45200 def spot_rates @spot_rates end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
45200 45201 45202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45200 def status @status end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
45218 45219 45220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45218 def copy(incoming={}) Local.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
45222 45223 45224 45225 45226 45227 45228 45229 45230 45231 45232 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45222 def to_hash { :experience => experience.to_hash, :prices => prices.map { |o| o.to_hash }, :rates => rates.map { |o| o.to_hash }, :spot_rates => spot_rates, :status => status.value, :attributes => attributes.nil? ? nil : attributes, :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
45214 45215 45216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45214 def to_json JSON.dump(to_hash) end |