Class: Io::Flow::V0::Models::Conversion

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

Overview

Describes conversion information from a base currency to a target currency.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Conversion

Returns a new instance of Conversion.



8210
8211
8212
8213
8214
8215
8216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8210

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:base, :target, :rate], 'Conversion')
  @base = HttpClient::Preconditions.assert_class('base', opts.delete(:base), String)
  @target = HttpClient::Preconditions.assert_class('target', opts.delete(:target), String)
  @rate = HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(opts.delete(:rate)), BigDecimal)
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



8208
8209
8210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8208

def base
  @base
end

#rateObject (readonly)

Returns the value of attribute rate.



8208
8209
8210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8208

def rate
  @rate
end

#targetObject (readonly)

Returns the value of attribute target.



8208
8209
8210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8208

def target
  @target
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



8222
8223
8224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8222

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

#to_hashObject



8226
8227
8228
8229
8230
8231
8232
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8226

def to_hash
  {
    :base => base,
    :target => target,
    :rate => rate
  }
end

#to_jsonObject



8218
8219
8220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8218

def to_json
  JSON.dump(to_hash)
end