Class: Io::Flow::V0::Models::LocalizedPrice

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 = {}) ⇒ LocalizedPrice

Returns a new instance of LocalizedPrice.



10959
10960
10961
10962
10963
10964
10965
10966
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10959

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key, :currency, :amount, :label], 'LocalizedPrice')
  @key = (x = opts.delete(:key); x.is_a?(::Io::Flow::V0::Models::LocalizedPriceKey) ? x : ::Io::Flow::V0::Models::LocalizedPriceKey.apply(x))
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric)
  @label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



10957
10958
10959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10957

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



10957
10958
10959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10957

def currency
  @currency
end

#keyObject (readonly)

Returns the value of attribute key.



10957
10958
10959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10957

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



10957
10958
10959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10957

def label
  @label
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10972
10973
10974
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10972

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

#to_hashObject



10976
10977
10978
10979
10980
10981
10982
10983
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10976

def to_hash
  {
    :key => key.value,
    :currency => currency,
    :amount => amount,
    :label => label
  }
end

#to_jsonObject



10968
10969
10970
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10968

def to_json
  JSON.dump(to_hash)
end