Class: Io::Flow::V0::Models::PaymentDiscount

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#amountObject (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

#codeObject (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

#nameObject (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_hashObject



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_jsonObject



56755
56756
56757
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56755

def to_json
  JSON.dump(to_hash)
end