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.
50406 50407 50408 50409 50410 50411 50412 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50406 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.
50404 50405 50406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50404 def amount @amount end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
50404 50405 50406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50404 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
50404 50405 50406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50404 def name @name end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
50418 50419 50420 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50418 def copy(incoming={}) PaymentDiscount.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
50422 50423 50424 50425 50426 50427 50428 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50422 def to_hash { :amount => amount.to_f.to_s, :name => name, :code => code } end |
#to_json ⇒ Object
50414 50415 50416 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50414 def to_json JSON.dump(to_hash) end |