Class: Plaid::TransferEvent

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/plaid/models/transfer_event.rb

Overview

Represents an event in 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(event_id:, timestamp:, event_type:, account_id:, transfer_id:, origination_account_id:, transfer_type:, transfer_amount:, failure_reason:, additional_properties: nil) ⇒ TransferEvent

Returns a new instance of TransferEvent.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/plaid/models/transfer_event.rb', line 88

def initialize(event_id:, timestamp:, event_type:, account_id:,
               transfer_id:, origination_account_id:, transfer_type:,
               transfer_amount:, failure_reason:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @event_id = event_id
  @timestamp = timestamp
  @event_type = event_type
  @account_id = 
  @transfer_id = transfer_id
  @origination_account_id = 
  @transfer_type = transfer_type
  @transfer_amount = transfer_amount
  @failure_reason = failure_reason
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idString

The account ID associated with the transfer.

Returns:

  • (String)


35
36
37
# File 'lib/plaid/models/transfer_event.rb', line 35

def 
  @account_id
end

#event_idInteger

Plaid’s unique identifier for this event. IDs are sequential unsigned 64-bit integers.

Returns:

  • (Integer)


16
17
18
# File 'lib/plaid/models/transfer_event.rb', line 16

def event_id
  @event_id
end

#event_typeTransferEventType

The type of event that this transfer represents. ‘pending`: A new transfer was created; it is in the pending state. `cancelled`: The transfer was cancelled by the client. `failed`: The transfer failed, no funds were moved. `posted`: The transfer has been successfully submitted to the payment network. `reversed`: A posted transfer was reversed.

Returns:



31
32
33
# File 'lib/plaid/models/transfer_event.rb', line 31

def event_type
  @event_type
end

#failure_reasonTransferFailure

The failure reason if the type of this transfer is ‘“failed”` or `“reversed”`. Null value otherwise.

Returns:



59
60
61
# File 'lib/plaid/models/transfer_event.rb', line 59

def failure_reason
  @failure_reason
end

#origination_account_idString

The ID of the origination account that this balance belongs to.

Returns:

  • (String)


43
44
45
# File 'lib/plaid/models/transfer_event.rb', line 43

def 
  @origination_account_id
end

#timestampDateTime

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

Returns:

  • (DateTime)


21
22
23
# File 'lib/plaid/models/transfer_event.rb', line 21

def timestamp
  @timestamp
end

#transfer_amountString

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

Returns:

  • (String)


54
55
56
# File 'lib/plaid/models/transfer_event.rb', line 54

def transfer_amount
  @transfer_amount
end

#transfer_idString

Plaid’s unique identifier for a transfer.

Returns:

  • (String)


39
40
41
# File 'lib/plaid/models/transfer_event.rb', line 39

def transfer_id
  @transfer_id
end

#transfer_typeTransferType1

The type of transfer. This will be either ‘debit` or `credit`. A `debit` indicates a transfer of money into the origination account; a `credit` indicates a transfer of money out of the origination account.

Returns:



49
50
51
# File 'lib/plaid/models/transfer_event.rb', line 49

def transfer_type
  @transfer_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



108
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
144
# File 'lib/plaid/models/transfer_event.rb', line 108

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  event_id = hash.key?('event_id') ? hash['event_id'] : nil
  timestamp = if hash.key?('timestamp')
                (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp'])
              end
  event_type = hash.key?('event_type') ? hash['event_type'] : nil
   = hash.key?('account_id') ? hash['account_id'] : nil
  transfer_id = hash.key?('transfer_id') ? hash['transfer_id'] : nil
   =
    hash.key?('origination_account_id') ? hash['origination_account_id'] : nil
  transfer_type = hash.key?('transfer_type') ? hash['transfer_type'] : nil
  transfer_amount =
    hash.key?('transfer_amount') ? hash['transfer_amount'] : nil
  failure_reason = TransferFailure.from_hash(hash['failure_reason']) if hash['failure_reason']

  # 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.
  TransferEvent.new(event_id: event_id,
                    timestamp: timestamp,
                    event_type: event_type,
                    account_id: ,
                    transfer_id: transfer_id,
                    origination_account_id: ,
                    transfer_type: transfer_type,
                    transfer_amount: transfer_amount,
                    failure_reason: failure_reason,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/plaid/models/transfer_event.rb', line 62

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['event_id'] = 'event_id'
  @_hash['timestamp'] = 'timestamp'
  @_hash['event_type'] = 'event_type'
  @_hash['account_id'] = 'account_id'
  @_hash['transfer_id'] = 'transfer_id'
  @_hash['origination_account_id'] = 'origination_account_id'
  @_hash['transfer_type'] = 'transfer_type'
  @_hash['transfer_amount'] = 'transfer_amount'
  @_hash['failure_reason'] = 'failure_reason'
  @_hash
end

.nullablesObject

An array for nullable fields



82
83
84
85
86
# File 'lib/plaid/models/transfer_event.rb', line 82

def self.nullables
  %w[
    origination_account_id
  ]
end

.optionalsObject

An array for optional fields



77
78
79
# File 'lib/plaid/models/transfer_event.rb', line 77

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



161
162
163
164
165
166
167
168
169
# File 'lib/plaid/models/transfer_event.rb', line 161

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} event_id: #{@event_id.inspect}, timestamp: #{@timestamp.inspect},"\
  " event_type: #{@event_type.inspect}, account_id: #{@account_id.inspect}, transfer_id:"\
  " #{@transfer_id.inspect}, origination_account_id: #{@origination_account_id.inspect},"\
  " transfer_type: #{@transfer_type.inspect}, transfer_amount: #{@transfer_amount.inspect},"\
  " failure_reason: #{@failure_reason.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_timestampObject



146
147
148
# File 'lib/plaid/models/transfer_event.rb', line 146

def to_custom_timestamp
  DateTimeHelper.to_rfc3339(timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



151
152
153
154
155
156
157
158
# File 'lib/plaid/models/transfer_event.rb', line 151

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} event_id: #{@event_id}, timestamp: #{@timestamp}, event_type:"\
  " #{@event_type}, account_id: #{@account_id}, transfer_id: #{@transfer_id},"\
  " origination_account_id: #{@origination_account_id}, transfer_type: #{@transfer_type},"\
  " transfer_amount: #{@transfer_amount}, failure_reason: #{@failure_reason},"\
  " additional_properties: #{@additional_properties}>"
end