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.



36922
36923
36924
36925
36926
36927
36928
36929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36922

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)))
  @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.



36920
36921
36922
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36920

def attributes
  @attributes
end

#dutyObject (readonly)

Returns the value of attribute duty.



36920
36921
36922
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36920

def duty
  @duty
end

#priceObject (readonly)

Returns the value of attribute price.



36920
36921
36922
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36920

def price
  @price
end

#vatObject (readonly)

Returns the value of attribute vat.



36920
36921
36922
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36920

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36935
36936
36937
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36935

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

#to_hashObject



36939
36940
36941
36942
36943
36944
36945
36946
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36939

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

#to_jsonObject



36931
36932
36933
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36931

def to_json
  JSON.dump(to_hash)
end