Class: Io::Flow::V0::Models::Price
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Price
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents an amount-currency pair for a basic price
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Price
constructor
A new instance of Price.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Price
Returns a new instance of Price.
59815 59816 59817 59818 59819 59820 59821 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59815 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:amount, :currency, :label], 'Price') @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric) @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String) @label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
59813 59814 59815 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59813 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
59813 59814 59815 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59813 def currency @currency end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
59813 59814 59815 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59813 def label @label end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
59827 59828 59829 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59827 def copy(incoming={}) Price.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
59831 59832 59833 59834 59835 59836 59837 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59831 def to_hash { :amount => amount, :currency => currency, :label => label } end |
#to_json ⇒ Object
59823 59824 59825 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59823 def to_json JSON.dump(to_hash) end |