Class: Io::Flow::V0::Models::CreditPaymentForm

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 = {}) ⇒ CreditPaymentForm

Returns a new instance of CreditPaymentForm.



24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24959

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:order_number, :description, :amount, :max, :currency], 'CreditPaymentForm')
  @order_number = HttpClient::Preconditions.assert_class('order_number', opts.delete(:order_number), String)
  @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String)
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @max = HttpClient::Preconditions.assert_class('max', HttpClient::Helper.to_big_decimal(opts.delete(:max)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



24957
24958
24959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24957

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



24957
24958
24959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24957

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



24957
24958
24959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24957

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description.



24957
24958
24959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24957

def description
  @description
end

#maxObject (readonly)

Returns the value of attribute max.



24957
24958
24959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24957

def max
  @max
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



24957
24958
24959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24957

def order_number
  @order_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24974
24975
24976
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24974

def copy(incoming={})
  CreditPaymentForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24978

def to_hash
  {
    :order_number => order_number,
    :description => description,
    :amount => amount.to_f.to_s,
    :max => max.to_f.to_s,
    :currency => currency,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



24970
24971
24972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24970

def to_json
  JSON.dump(to_hash)
end