Class: Io::Flow::V0::Models::PaymentInformation

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

Returns a new instance of PaymentInformation.



56866
56867
56868
56869
56870
56871
56872
56873
56874
56875
56876
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56866

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:authorizations], 'PaymentInformation')
  @amount_refundable = (x = opts.delete(:amount_refundable); x.nil? ? nil : HttpClient::Preconditions.assert_class('amount_refundable', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @amount_refunded = (x = opts.delete(:amount_refunded); x.nil? ? nil : HttpClient::Preconditions.assert_class('amount_refunded', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @refundable_before = (x = opts.delete(:refundable_before); x.nil? ? nil : HttpClient::Preconditions.assert_class('refundable_before', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @amount_capturable = (x = opts.delete(:amount_capturable); x.nil? ? nil : HttpClient::Preconditions.assert_class('amount_capturable', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @amount_captured = (x = opts.delete(:amount_captured); x.nil? ? nil : HttpClient::Preconditions.assert_class('amount_captured', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @capturable_before = (x = opts.delete(:capturable_before); x.nil? ? nil : HttpClient::Preconditions.assert_class('capturable_before', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @authorizations = HttpClient::Preconditions.assert_class('authorizations', opts.delete(:authorizations), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentAuthorization) ? x : ::Io::Flow::V0::Models::PaymentAuthorization.new(x)) }
end

Instance Attribute Details

#amount_capturableObject (readonly)

Returns the value of attribute amount_capturable.



56864
56865
56866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56864

def amount_capturable
  @amount_capturable
end

#amount_capturedObject (readonly)

Returns the value of attribute amount_captured.



56864
56865
56866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56864

def amount_captured
  @amount_captured
end

#amount_refundableObject (readonly)

Returns the value of attribute amount_refundable.



56864
56865
56866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56864

def amount_refundable
  @amount_refundable
end

#amount_refundedObject (readonly)

Returns the value of attribute amount_refunded.



56864
56865
56866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56864

def amount_refunded
  @amount_refunded
end

#authorizationsObject (readonly)

Returns the value of attribute authorizations.



56864
56865
56866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56864

def authorizations
  @authorizations
end

#capturable_beforeObject (readonly)

Returns the value of attribute capturable_before.



56864
56865
56866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56864

def capturable_before
  @capturable_before
end

#refundable_beforeObject (readonly)

Returns the value of attribute refundable_before.



56864
56865
56866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56864

def refundable_before
  @refundable_before
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



56882
56883
56884
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56882

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

#to_hashObject



56886
56887
56888
56889
56890
56891
56892
56893
56894
56895
56896
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56886

def to_hash
  {
    :amount_refundable => amount_refundable.to_f.to_s,
    :amount_refunded => amount_refunded.to_f.to_s,
    :refundable_before => refundable_before,
    :amount_capturable => amount_capturable.to_f.to_s,
    :amount_captured => amount_captured.to_f.to_s,
    :capturable_before => capturable_before,
    :authorizations => authorizations.map { |o| o.to_hash }
  }
end

#to_jsonObject



56878
56879
56880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56878

def to_json
  JSON.dump(to_hash)
end