Class: ThePlaidApi::TransferLedgerEvent

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

Overview

Represents a ledger 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(ledger_event_id:, ledger_id:, amount:, description:, pending_balance:, available_balance:, type:, timestamp:, transfer_id: SKIP, refund_id: SKIP, sweep_id: SKIP, additional_properties: nil) ⇒ TransferLedgerEvent

Returns a new instance of TransferLedgerEvent.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 92

def initialize(ledger_event_id:, ledger_id:, amount:, description:,
               pending_balance:, available_balance:, type:, timestamp:,
               transfer_id: SKIP, refund_id: SKIP, sweep_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @ledger_event_id = ledger_event_id
  @ledger_id = ledger_id
  @amount = amount
  @transfer_id = transfer_id unless transfer_id == SKIP
  @refund_id = refund_id unless refund_id == SKIP
  @sweep_id = sweep_id unless sweep_id == SKIP
  @description = description
  @pending_balance = pending_balance
  @available_balance = available_balance
  @type = type
  @timestamp = timestamp
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

The amount of the ledger event as a decimal string.

Returns:

  • (String)


23
24
25
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 23

def amount
  @amount
end

#available_balanceString

The new available balance after this event.

Returns:

  • (String)


47
48
49
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 47

def available_balance
  @available_balance
end

#descriptionString

A description of the ledger event.

Returns:

  • (String)


39
40
41
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 39

def description
  @description
end

#ledger_event_idString

Plaid’s unique identifier for this ledger event.

Returns:

  • (String)


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

def ledger_event_id
  @ledger_event_id
end

#ledger_idString

The ID of the ledger this event belongs to.

Returns:

  • (String)


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

def ledger_id
  @ledger_id
end

#pending_balanceString

The new pending balance after this event.

Returns:

  • (String)


43
44
45
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 43

def pending_balance
  @pending_balance
end

#refund_idString

The ID of the refund source that triggered this ledger event.

Returns:

  • (String)


31
32
33
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 31

def refund_id
  @refund_id
end

#sweep_idString

The ID of the sweep source that triggered this ledger event.

Returns:

  • (String)


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

def sweep_id
  @sweep_id
end

#timestampDateTime

The datetime when this ledger event occurred.

Returns:

  • (DateTime)


55
56
57
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 55

def timestamp
  @timestamp
end

#transfer_idString

The ID of the transfer source that triggered this ledger event.

Returns:

  • (String)


27
28
29
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 27

def transfer_id
  @transfer_id
end

#typeString

The type of balance that was impacted by this event.

Returns:

  • (String)


51
52
53
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 51

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 114

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  ledger_event_id =
    hash.key?('ledger_event_id') ? hash['ledger_event_id'] : nil
  ledger_id = hash.key?('ledger_id') ? hash['ledger_id'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  pending_balance =
    hash.key?('pending_balance') ? hash['pending_balance'] : nil
  available_balance =
    hash.key?('available_balance') ? hash['available_balance'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  timestamp = if hash.key?('timestamp')
                (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp'])
              end
  transfer_id = hash.key?('transfer_id') ? hash['transfer_id'] : SKIP
  refund_id = hash.key?('refund_id') ? hash['refund_id'] : SKIP
  sweep_id = hash.key?('sweep_id') ? hash['sweep_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.
  TransferLedgerEvent.new(ledger_event_id: ledger_event_id,
                          ledger_id: ledger_id,
                          amount: amount,
                          description: description,
                          pending_balance: pending_balance,
                          available_balance: available_balance,
                          type: type,
                          timestamp: timestamp,
                          transfer_id: transfer_id,
                          refund_id: refund_id,
                          sweep_id: sweep_id,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['ledger_event_id'] = 'ledger_event_id'
  @_hash['ledger_id'] = 'ledger_id'
  @_hash['amount'] = 'amount'
  @_hash['transfer_id'] = 'transfer_id'
  @_hash['refund_id'] = 'refund_id'
  @_hash['sweep_id'] = 'sweep_id'
  @_hash['description'] = 'description'
  @_hash['pending_balance'] = 'pending_balance'
  @_hash['available_balance'] = 'available_balance'
  @_hash['type'] = 'type'
  @_hash['timestamp'] = 'timestamp'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    transfer_id
    refund_id
    sweep_id
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    transfer_id
    refund_id
    sweep_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



172
173
174
175
176
177
178
179
180
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 172

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} ledger_event_id: #{@ledger_event_id.inspect}, ledger_id:"\
  " #{@ledger_id.inspect}, amount: #{@amount.inspect}, transfer_id: #{@transfer_id.inspect},"\
  " refund_id: #{@refund_id.inspect}, sweep_id: #{@sweep_id.inspect}, description:"\
  " #{@description.inspect}, pending_balance: #{@pending_balance.inspect}, available_balance:"\
  " #{@available_balance.inspect}, type: #{@type.inspect}, timestamp: #{@timestamp.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_timestampObject



157
158
159
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 157

def to_custom_timestamp
  DateTimeHelper.to_rfc3339(timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



162
163
164
165
166
167
168
169
# File 'lib/the_plaid_api/models/transfer_ledger_event.rb', line 162

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} ledger_event_id: #{@ledger_event_id}, ledger_id: #{@ledger_id}, amount:"\
  " #{@amount}, transfer_id: #{@transfer_id}, refund_id: #{@refund_id}, sweep_id:"\
  " #{@sweep_id}, description: #{@description}, pending_balance: #{@pending_balance},"\
  " available_balance: #{@available_balance}, type: #{@type}, timestamp: #{@timestamp},"\
  " additional_properties: #{@additional_properties}>"
end