Class: Io::Flow::V0::Models::PaymentReversal

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

Overview

A reversal is used to release the remaining authorization hold for a payment request. When a reversal is processed, this indicates that the funds in question were never withdrawn from the customer’s account.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentReversal

Returns a new instance of PaymentReversal.



58972
58973
58974
58975
58976
58977
58978
58979
58980
58981
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58972

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :amount, :currency, :created_at, :updated_at, :status], 'PaymentReversal')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @updated_at = HttpClient::Preconditions.assert_class('updated_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:updated_at)), DateTime)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::PaymentReversalStatus) ? x : ::Io::Flow::V0::Models::PaymentReversalStatus.new(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



58970
58971
58972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58970

def amount
  @amount
end

#created_atObject (readonly)

Returns the value of attribute created_at.



58970
58971
58972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58970

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



58970
58971
58972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58970

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



58970
58971
58972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58970

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



58970
58971
58972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58970

def status
  @status
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



58970
58971
58972
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58970

def updated_at
  @updated_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



58987
58988
58989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58987

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

#to_hashObject



58991
58992
58993
58994
58995
58996
58997
58998
58999
59000
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58991

def to_hash
  {
    :id => id,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :created_at => created_at,
    :updated_at => updated_at,
    :status => status.to_hash
  }
end

#to_jsonObject



58983
58984
58985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58983

def to_json
  JSON.dump(to_hash)
end