Class: Io::Flow::V0::Models::Conversion
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Conversion
- 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
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Conversion
constructor
A new instance of Conversion.
- #to_hash ⇒ Object
- #to_json ⇒ Object
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
#base ⇒ Object (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 |
#rate ⇒ Object (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 |
#target ⇒ Object (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_hash ⇒ Object
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_json ⇒ Object
8218 8219 8220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8218 def to_json JSON.dump(to_hash) end |