Class: Io::Flow::V0::Models::LocalItemPricing

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

Overview

Localized item pricing information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ LocalItemPricing

Returns a new instance of LocalItemPricing.



22569
22570
22571
22572
22573
22574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22569

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))
  @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 }
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



22567
22568
22569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22567

def attributes
  @attributes
end

#priceObject (readonly)

Returns the value of attribute price.



22567
22568
22569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22567

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22580
22581
22582
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22580

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

#to_hashObject



22584
22585
22586
22587
22588
22589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22584

def to_hash
  {
    :price => price.to_hash,
    :attributes => attributes.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1].to_hash; hash }
  }
end

#to_jsonObject



22576
22577
22578
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22576

def to_json
  JSON.dump(to_hash)
end