Class: ThePlaidApi::TransferRefund

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/transfer_refund.rb

Overview

Represents a refund within the Transfers API.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, transfer_id:, amount:, status:, failure_reason:, created:, ledger_id: SKIP, network_trace_id: SKIP, additional_properties: nil) ⇒ TransferRefund

Returns a new instance of TransferRefund.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 91

def initialize(id:, transfer_id:, amount:, status:, failure_reason:,
               created:, ledger_id: SKIP, network_trace_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @transfer_id = transfer_id
  @amount = amount
  @status = status
  @failure_reason = failure_reason
  @ledger_id = ledger_id unless ledger_id == SKIP
  @created = created
  @network_trace_id = network_trace_id unless network_trace_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

The amount of the refund (decimal string with two digits of precision e.g. “10.00”).

Returns:

  • (String)


24
25
26
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 24

def amount
  @amount
end

#createdDateTime

The datetime when this refund was created. This will be of the form ‘2006-01-02T15:04:05Z`

Returns:

  • (DateTime)


49
50
51
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 49

def created
  @created
end

#failure_reasonTransferRefundFailure

The failure reason if the event type for a refund is ‘“failed”` or `“returned”`. Null value otherwise.



40
41
42
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 40

def failure_reason
  @failure_reason
end

#idString

Plaid’s unique identifier for a refund.

Returns:

  • (String)


15
16
17
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 15

def id
  @id
end

#ledger_idString

Plaid’s unique identifier for a Plaid Ledger Balance.

Returns:

  • (String)


44
45
46
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 44

def ledger_id
  @ledger_id
end

#network_trace_idString

The trace identifier for the transfer based on its network. This will only be set after the transfer has posted. For ‘ach` or `same-day-ach` transfers, this is the ACH trace number. For `rtp` transfers, this is the Transaction Identification number. For `wire` transfers, this is the IMAD (Input Message Accountability Data) number.

Returns:

  • (String)


58
59
60
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 58

def network_trace_id
  @network_trace_id
end

#statusTransferRefundStatus

The status of the refund. ‘pending`: A new refund was created; it is in the pending state. `posted`: The refund has been successfully submitted to the payment network. `settled`: Credits have been refunded to the Plaid linked account. `cancelled`: The refund was cancelled by the client. `failed`: The refund has failed. `returned`: The refund was returned.



35
36
37
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 35

def status
  @status
end

#transfer_idString

The ID of the transfer to refund.

Returns:

  • (String)


19
20
21
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 19

def transfer_id
  @transfer_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 109

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  transfer_id = hash.key?('transfer_id') ? hash['transfer_id'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  failure_reason = TransferRefundFailure.from_hash(hash['failure_reason']) if
    hash['failure_reason']
  created = if hash.key?('created')
              (DateTimeHelper.from_rfc3339(hash['created']) if hash['created'])
            end
  ledger_id = hash.key?('ledger_id') ? hash['ledger_id'] : SKIP
  network_trace_id =
    hash.key?('network_trace_id') ? hash['network_trace_id'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  TransferRefund.new(id: id,
                     transfer_id: transfer_id,
                     amount: amount,
                     status: status,
                     failure_reason: failure_reason,
                     created: created,
                     ledger_id: ledger_id,
                     network_trace_id: network_trace_id,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 61

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['transfer_id'] = 'transfer_id'
  @_hash['amount'] = 'amount'
  @_hash['status'] = 'status'
  @_hash['failure_reason'] = 'failure_reason'
  @_hash['ledger_id'] = 'ledger_id'
  @_hash['created'] = 'created'
  @_hash['network_trace_id'] = 'network_trace_id'
  @_hash
end

.nullablesObject

An array for nullable fields



83
84
85
86
87
88
89
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 83

def self.nullables
  %w[
    failure_reason
    ledger_id
    network_trace_id
  ]
end

.optionalsObject

An array for optional fields



75
76
77
78
79
80
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 75

def self.optionals
  %w[
    ledger_id
    network_trace_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



159
160
161
162
163
164
165
166
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 159

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, transfer_id: #{@transfer_id.inspect}, amount:"\
  " #{@amount.inspect}, status: #{@status.inspect}, failure_reason:"\
  " #{@failure_reason.inspect}, ledger_id: #{@ledger_id.inspect}, created:"\
  " #{@created.inspect}, network_trace_id: #{@network_trace_id.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_createdObject



145
146
147
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 145

def to_custom_created
  DateTimeHelper.to_rfc3339(created)
end

#to_sObject

Provides a human-readable string representation of the object.



150
151
152
153
154
155
156
# File 'lib/the_plaid_api/models/transfer_refund.rb', line 150

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, transfer_id: #{@transfer_id}, amount: #{@amount}, status:"\
  " #{@status}, failure_reason: #{@failure_reason}, ledger_id: #{@ledger_id}, created:"\
  " #{@created}, network_trace_id: #{@network_trace_id}, additional_properties:"\
  " #{@additional_properties}>"
end