Class: Io::Flow::V0::Models::PaymentDiscount
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::PaymentDiscount
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ PaymentDiscount
constructor
A new instance of PaymentDiscount.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ PaymentDiscount
Returns a new instance of PaymentDiscount.
56747 56748 56749 56750 56751 56752 56753 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56747 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:amount], 'PaymentDiscount') @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal) @name = HttpClient::Preconditions.assert_class('name', (x = opts.delete(:name); x.nil? ? "Discount" : x), String) @code = (x = opts.delete(:code); x.nil? ? nil : HttpClient::Preconditions.assert_class('code', x, String)) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
56745 56746 56747 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56745 def amount @amount end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
56745 56746 56747 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56745 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
56745 56746 56747 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56745 def name @name end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
56759 56760 56761 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56759 def copy(incoming={}) PaymentDiscount.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
56763 56764 56765 56766 56767 56768 56769 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56763 def to_hash { :amount => amount.to_f.to_s, :name => name, :code => code } end |
#to_json ⇒ Object
56755 56756 56757 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56755 def to_json JSON.dump(to_hash) end |