Class: Io::Flow::V0::Models::PaymentRefund

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

Overview

A refund is used to return already captured funds back to the customer. The customer will see the amount credited back to them as a separate transaction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentRefund

Returns a new instance of PaymentRefund.



54118
54119
54120
54121
54122
54123
54124
54125
54126
54127
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54118

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :amount, :currency, :created_at, :updated_at, :status], 'PaymentRefund')
  @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::PaymentRefundStatus) ? x : ::Io::Flow::V0::Models::PaymentRefundStatus.new(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



54116
54117
54118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54116

def amount
  @amount
end

#created_atObject (readonly)

Returns the value of attribute created_at.



54116
54117
54118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54116

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



54116
54117
54118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54116

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



54116
54117
54118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54116

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



54116
54117
54118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54116

def status
  @status
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



54116
54117
54118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54116

def updated_at
  @updated_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



54133
54134
54135
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54133

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

#to_hashObject



54137
54138
54139
54140
54141
54142
54143
54144
54145
54146
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54137

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



54129
54130
54131
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54129

def to_json
  JSON.dump(to_hash)
end