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.



11206
11207
11208
11209
11210
11211
11212
11213
11214
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11206

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key, :currency, :amount, :label, :base], '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)
  @base = (x = opts.delete(:base); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



11204
11205
11206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11204

def amount
  @amount
end

#baseObject (readonly)

Returns the value of attribute base.



11204
11205
11206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11204

def base
  @base
end

#currencyObject (readonly)

Returns the value of attribute currency.



11204
11205
11206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11204

def currency
  @currency
end

#keyObject (readonly)

Returns the value of attribute key.



11204
11205
11206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11204

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



11204
11205
11206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11204

def label
  @label
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11220
11221
11222
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11220

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

#to_hashObject



11224
11225
11226
11227
11228
11229
11230
11231
11232
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11224

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

#to_jsonObject



11216
11217
11218
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11216

def to_json
  JSON.dump(to_hash)
end