Class: Io::Flow::V0::Models::Local

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Local

Returns a new instance of Local.



36812
36813
36814
36815
36816
36817
36818
36819
36820
36821
36822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36812

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

#attributesObject (readonly)

Returns the value of attribute attributes.



36810
36811
36812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36810

def attributes
  @attributes
end

#experienceObject (readonly)

Returns the value of attribute experience.



36810
36811
36812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36810

def experience
  @experience
end

#price_attributesObject (readonly)

Returns the value of attribute price_attributes.



36810
36811
36812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36810

def price_attributes
  @price_attributes
end

#pricesObject (readonly)

Returns the value of attribute prices.



36810
36811
36812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36810

def prices
  @prices
end

#ratesObject (readonly)

Returns the value of attribute rates.



36810
36811
36812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36810

def rates
  @rates
end

#spot_ratesObject (readonly)

Returns the value of attribute spot_rates.



36810
36811
36812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36810

def spot_rates
  @spot_rates
end

#statusObject (readonly)

Returns the value of attribute status.



36810
36811
36812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36810

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36828
36829
36830
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36828

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

#to_hashObject



36832
36833
36834
36835
36836
36837
36838
36839
36840
36841
36842
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36832

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_jsonObject



36824
36825
36826
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36824

def to_json
  JSON.dump(to_hash)
end