Class: FdxV660Api::Transaction

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/transaction.rb

Overview

Financial transaction details not specific to an account category

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(account_id: SKIP, transaction_id: SKIP, posted_timestamp: SKIP, transaction_timestamp: SKIP, description: SKIP, transaction_payee: SKIP, debit_credit_memo: SKIP, status: SKIP, amount: SKIP, reward: SKIP, rewards: SKIP, fi_attributes: SKIP, links: SKIP, account_category: 'Transaction', reference_transaction_id: SKIP, card_number_display: SKIP, memo: SKIP, category: SKIP, sub_category: SKIP, category_code: SKIP, category_type: SKIP, reference: SKIP, remittance: SKIP, foreign_amount: SKIP, foreign_currency: SKIP, image_ids: SKIP, line_item: SKIP, additional_properties: nil) ⇒ Transaction

Returns a new instance of Transaction.



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/fdx_v660_api/models/transaction.rb', line 234

def initialize(account_id: SKIP, transaction_id: SKIP,
               posted_timestamp: SKIP, transaction_timestamp: SKIP,
               description: SKIP, transaction_payee: SKIP,
               debit_credit_memo: SKIP, status: SKIP, amount: SKIP,
               reward: SKIP, rewards: SKIP, fi_attributes: SKIP,
               links: SKIP, account_category: 'Transaction',
               reference_transaction_id: SKIP, card_number_display: SKIP,
               memo: SKIP, category: SKIP, sub_category: SKIP,
               category_code: SKIP, category_type: SKIP, reference: SKIP,
               remittance: SKIP, foreign_amount: SKIP,
               foreign_currency: SKIP, image_ids: SKIP, line_item: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_id =  unless  == SKIP
  @transaction_id = transaction_id unless transaction_id == SKIP
  @posted_timestamp = posted_timestamp unless posted_timestamp == SKIP
  @transaction_timestamp = transaction_timestamp unless transaction_timestamp == SKIP
  @description = description unless description == SKIP
  @transaction_payee = transaction_payee unless transaction_payee == SKIP
  @debit_credit_memo = debit_credit_memo unless debit_credit_memo == SKIP
  @status = status unless status == SKIP
  @amount = amount unless amount == SKIP
  @reward = reward unless reward == SKIP
  @rewards = rewards unless rewards == SKIP
  @fi_attributes = fi_attributes unless fi_attributes == SKIP
  @links = links unless links == SKIP
  @account_category =  unless  == SKIP
  @reference_transaction_id = reference_transaction_id unless reference_transaction_id == SKIP
  @card_number_display = card_number_display unless card_number_display == SKIP
  @memo = memo unless memo == SKIP
  @category = category unless category == SKIP
  @sub_category = sub_category unless sub_category == SKIP
  @category_code = category_code unless category_code == SKIP
  @category_type = category_type unless category_type == SKIP
  @reference = reference unless reference == SKIP
  @remittance = remittance unless remittance == SKIP
  @foreign_amount = foreign_amount unless foreign_amount == SKIP
  @foreign_currency = foreign_currency unless foreign_currency == SKIP
  @image_ids = image_ids unless image_ids == SKIP
  @line_item = line_item unless line_item == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_categoryString

Links (unique to this transaction) used to retrieve full transaction details or images of checks or transaction receipts

Returns:

  • (String)


81
82
83
# File 'lib/fdx_v660_api/models/transaction.rb', line 81

def 
  @account_category
end

#account_idString

Corresponds to AccountId in Account

Returns:

  • (String)


15
16
17
# File 'lib/fdx_v660_api/models/transaction.rb', line 15

def 
  @account_id
end

#amountFloat

The amount of money in the account currency

Returns:

  • (Float)


52
53
54
# File 'lib/fdx_v660_api/models/transaction.rb', line 52

def amount
  @amount
end

#card_number_displayString

The payment card number (e.g. debit, credit or digital), suitably masked, used to originate the transaction. May differ from primary account number as a secondary or employee card or a one-time use number. This is an optional field and won't be returned for certain types of transactions such as cash or check deposits

Returns:

  • (String)


95
96
97
# File 'lib/fdx_v660_api/models/transaction.rb', line 95

def card_number_display
  @card_number_display
end

#categoryString

High-level description of transaction category. Such as Transportation. The deprecated prior description was 'Transaction category, preferably MCC or SIC'

Returns:

  • (String)


105
106
107
# File 'lib/fdx_v660_api/models/transaction.rb', line 105

def category
  @category
end

#category_codeString

Transaction category code from MCC or SIC codesets

Returns:

  • (String)


115
116
117
# File 'lib/fdx_v660_api/models/transaction.rb', line 115

def category_code
  @category_code
end

#category_typeCategoryType2

Type of transaction category code, either MCC (Merchant Category Code) or SIC (Standard Industrial Classification)

Returns:



120
121
122
# File 'lib/fdx_v660_api/models/transaction.rb', line 120

def category_type
  @category_type
end

#debit_credit_memoDebitCreditMemo2

DEBIT, CREDIT, MEMO

Returns:



44
45
46
# File 'lib/fdx_v660_api/models/transaction.rb', line 44

def debit_credit_memo
  @debit_credit_memo
end

#descriptionString

The description of the transaction, such as information about a merchant's name or place of business in a manner that is user friendly and accessible to the customer. Detailed information on a payee, such as address, can be sent in transactionPayee

Returns:

  • (String)


36
37
38
# File 'lib/fdx_v660_api/models/transaction.rb', line 36

def description
  @description
end

#fi_attributesArray[FiAttributeEntity]

Array of FI-specific attributes

Returns:



71
72
73
# File 'lib/fdx_v660_api/models/transaction.rb', line 71

def fi_attributes
  @fi_attributes
end

#foreign_amountFloat

The amount of money in the foreign currency

Returns:

  • (Float)


132
133
134
# File 'lib/fdx_v660_api/models/transaction.rb', line 132

def foreign_amount
  @foreign_amount
end

#foreign_currencyIso4217CurrencyCode3

The ISO 4217 code of the foreign currency



136
137
138
# File 'lib/fdx_v660_api/models/transaction.rb', line 136

def foreign_currency
  @foreign_currency
end

#image_idsArray[String]

Array of Image Identifiers (unique to this transaction) used to retrieve Images of check or transaction receipt

Returns:

  • (Array[String])


141
142
143
# File 'lib/fdx_v660_api/models/transaction.rb', line 141

def image_ids
  @image_ids
end

#line_itemArray[LineItemEntity]

Breakdown of the transaction details

Returns:



145
146
147
# File 'lib/fdx_v660_api/models/transaction.rb', line 145

def line_item
  @line_item
end

Links (unique to this transaction) used to retrieve full transaction details or images of checks or transaction receipts

Returns:



76
77
78
# File 'lib/fdx_v660_api/models/transaction.rb', line 76

def links
  @links
end

#memoString

Secondary transaction description

Returns:

  • (String)


99
100
101
# File 'lib/fdx_v660_api/models/transaction.rb', line 99

def memo
  @memo
end

#posted_timestampDateTime

The date and time that the transaction was posted to the account. If not provided then TransactionTimestamp can be used as PostedTimeStamp

Returns:

  • (DateTime)


24
25
26
# File 'lib/fdx_v660_api/models/transaction.rb', line 24

def posted_timestamp
  @posted_timestamp
end

#referenceString

A tracking reference identifier

Returns:

  • (String)


124
125
126
# File 'lib/fdx_v660_api/models/transaction.rb', line 124

def reference
  @reference
end

#reference_transaction_idString

For reverse postings, the identity of the transaction being reversed. For the correction transaction, the identity of the reversing post. For credit card posting transactions, the identity of the authorization transaction

Returns:

  • (String)


87
88
89
# File 'lib/fdx_v660_api/models/transaction.rb', line 87

def reference_transaction_id
  @reference_transaction_id
end

#remittanceRemittance2

Remittance details for the transaction

Returns:



128
129
130
# File 'lib/fdx_v660_api/models/transaction.rb', line 128

def remittance
  @remittance
end

#rewardTransactionRewardEntity

Rewards earned with this transaction. If data provider does not have rewards data available alongside full Transaction details, instead of including in full /transactions response this can be returned as part of /reward-transactions endpoint. Deprecated in v6.5 to be replaced by array property rewards in next major version v7.0



60
61
62
# File 'lib/fdx_v660_api/models/transaction.rb', line 60

def reward
  @reward
end

#rewardsArray[TransactionRewardEntity]

Array of rewards earned or adjusted with this transaction. If data provider does not have rewards data available alongside full Transaction details, instead of including in full /transactions response this can be returned as part of /reward-transactions endpoint

Returns:



67
68
69
# File 'lib/fdx_v660_api/models/transaction.rb', line 67

def rewards
  @rewards
end

#statusTransactionStatus2

PENDING, MEMO, POSTED, AUTHORIZATION

Returns:



48
49
50
# File 'lib/fdx_v660_api/models/transaction.rb', line 48

def status
  @status
end

#sub_categoryString

Lower-level description of the transaction's sub-category. Such as Airfare. The deprecated prior description was 'Transaction category detail specifying the standard of the transaction category. For example, "MCC"'

Returns:

  • (String)


111
112
113
# File 'lib/fdx_v660_api/models/transaction.rb', line 111

def sub_category
  @sub_category
end

#transaction_idString

Long term persistent identity of the transaction (unique to account)

Returns:

  • (String)


19
20
21
# File 'lib/fdx_v660_api/models/transaction.rb', line 19

def transaction_id
  @transaction_id
end

#transaction_payeeTransactionPayeeEntity3

The merchant or individual payee who was involved in the transaction



40
41
42
# File 'lib/fdx_v660_api/models/transaction.rb', line 40

def transaction_payee
  @transaction_payee
end

#transaction_timestampDateTime

The date and time that the transaction was added to the server backend systems

Returns:

  • (DateTime)


29
30
31
# File 'lib/fdx_v660_api/models/transaction.rb', line 29

def transaction_timestamp
  @transaction_timestamp
end

Class Method Details

.discriminatorsObject

Discriminators mapping.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/fdx_v660_api/models/transaction.rb', line 148

def self.discriminators
  if @_discriminators.nil?
    @_discriminators = {}
    @_discriminators['Buy Now Pay Later Transaction entity'] = BuyNowPayLaterTransactionEntity
    @_discriminators['Commercial Transaction entity'] = CommercialTransactionEntity
    @_discriminators['Deposit Transaction entity'] = DepositTransactionEntity
    @_discriminators['Digital Wallet Transaction entity'] = DigitalWalletTransactionEntity
    @_discriminators['Insurance Transaction entity'] = InsuranceTransactionEntity
    @_discriminators['Investment Transaction entity'] = InvestmentTransactionEntity
    @_discriminators['Line of Credit Transaction entity'] = LineOfCreditTransactionEntity
    @_discriminators['Loan Transaction entity'] = LoanTransactionEntity
  end
  @_discriminators
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/fdx_v660_api/models/transaction.rb', line 280

def self.from_hash(hash)
  return nil unless hash

  # Delegate unboxing to another function if a discriminator
  # value for a child class is present.
  unboxer = discriminators[hash['accountCategory']]
  return unboxer.send(:from_hash, hash) if unboxer

  # Extract variables from the hash.
   = hash.key?('accountId') ? hash['accountId'] : SKIP
  transaction_id = hash.key?('transactionId') ? hash['transactionId'] : SKIP
  posted_timestamp = if hash.key?('postedTimestamp')
                       (DateTimeHelper.from_rfc3339(hash['postedTimestamp']) if hash['postedTimestamp'])
                     else
                       SKIP
                     end
  transaction_timestamp = if hash.key?('transactionTimestamp')
                            (DateTimeHelper.from_rfc3339(hash['transactionTimestamp']) if hash['transactionTimestamp'])
                          else
                            SKIP
                          end
  description = hash.key?('description') ? hash['description'] : SKIP
  transaction_payee = TransactionPayeeEntity3.from_hash(hash['transactionPayee']) if
    hash['transactionPayee']
  debit_credit_memo =
    hash.key?('debitCreditMemo') ? hash['debitCreditMemo'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : SKIP
  reward = TransactionRewardEntity.from_hash(hash['reward']) if hash['reward']
  # Parameter is an array, so we need to iterate through it
  rewards = nil
  unless hash['rewards'].nil?
    rewards = []
    hash['rewards'].each do |structure|
      rewards << (TransactionRewardEntity.from_hash(structure) if structure)
    end
  end

  rewards = SKIP unless hash.key?('rewards')
  # Parameter is an array, so we need to iterate through it
  fi_attributes = nil
  unless hash['fiAttributes'].nil?
    fi_attributes = []
    hash['fiAttributes'].each do |structure|
      fi_attributes << (FiAttributeEntity.from_hash(structure) if structure)
    end
  end

  fi_attributes = SKIP unless hash.key?('fiAttributes')
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (HateoasLink.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')
   = hash['accountCategory'] ||= 'Transaction'
  reference_transaction_id =
    hash.key?('referenceTransactionId') ? hash['referenceTransactionId'] : SKIP
  card_number_display =
    hash.key?('cardNumberDisplay') ? hash['cardNumberDisplay'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  category = hash.key?('category') ? hash['category'] : SKIP
  sub_category = hash.key?('subCategory') ? hash['subCategory'] : SKIP
  category_code = hash.key?('categoryCode') ? hash['categoryCode'] : SKIP
  category_type = hash.key?('categoryType') ? hash['categoryType'] : SKIP
  reference = hash.key?('reference') ? hash['reference'] : SKIP
  remittance = Remittance2.from_hash(hash['remittance']) if hash['remittance']
  foreign_amount = hash.key?('foreignAmount') ? hash['foreignAmount'] : SKIP
  foreign_currency =
    hash.key?('foreignCurrency') ? hash['foreignCurrency'] : SKIP
  image_ids = hash.key?('imageIds') ? hash['imageIds'] : SKIP
  # Parameter is an array, so we need to iterate through it
  line_item = nil
  unless hash['lineItem'].nil?
    line_item = []
    hash['lineItem'].each do |structure|
      line_item << (LineItemEntity.from_hash(structure) if structure)
    end
  end

  line_item = SKIP unless hash.key?('lineItem')

  # 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.
  Transaction.new(account_id: ,
                  transaction_id: transaction_id,
                  posted_timestamp: posted_timestamp,
                  transaction_timestamp: transaction_timestamp,
                  description: description,
                  transaction_payee: transaction_payee,
                  debit_credit_memo: debit_credit_memo,
                  status: status,
                  amount: amount,
                  reward: reward,
                  rewards: rewards,
                  fi_attributes: fi_attributes,
                  links: links,
                  account_category: ,
                  reference_transaction_id: reference_transaction_id,
                  card_number_display: card_number_display,
                  memo: memo,
                  category: category,
                  sub_category: sub_category,
                  category_code: category_code,
                  category_type: category_type,
                  reference: reference,
                  remittance: remittance,
                  foreign_amount: foreign_amount,
                  foreign_currency: foreign_currency,
                  image_ids: image_ids,
                  line_item: line_item,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/fdx_v660_api/models/transaction.rb', line 164

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_id'] = 'accountId'
  @_hash['transaction_id'] = 'transactionId'
  @_hash['posted_timestamp'] = 'postedTimestamp'
  @_hash['transaction_timestamp'] = 'transactionTimestamp'
  @_hash['description'] = 'description'
  @_hash['transaction_payee'] = 'transactionPayee'
  @_hash['debit_credit_memo'] = 'debitCreditMemo'
  @_hash['status'] = 'status'
  @_hash['amount'] = 'amount'
  @_hash['reward'] = 'reward'
  @_hash['rewards'] = 'rewards'
  @_hash['fi_attributes'] = 'fiAttributes'
  @_hash['links'] = 'links'
  @_hash['account_category'] = 'accountCategory'
  @_hash['reference_transaction_id'] = 'referenceTransactionId'
  @_hash['card_number_display'] = 'cardNumberDisplay'
  @_hash['memo'] = 'memo'
  @_hash['category'] = 'category'
  @_hash['sub_category'] = 'subCategory'
  @_hash['category_code'] = 'categoryCode'
  @_hash['category_type'] = 'categoryType'
  @_hash['reference'] = 'reference'
  @_hash['remittance'] = 'remittance'
  @_hash['foreign_amount'] = 'foreignAmount'
  @_hash['foreign_currency'] = 'foreignCurrency'
  @_hash['image_ids'] = 'imageIds'
  @_hash['line_item'] = 'lineItem'
  @_hash
end

.nullablesObject

An array for nullable fields



230
231
232
# File 'lib/fdx_v660_api/models/transaction.rb', line 230

def self.nullables
  []
end

.optionalsObject

An array for optional fields



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/fdx_v660_api/models/transaction.rb', line 197

def self.optionals
  %w[
    account_id
    transaction_id
    posted_timestamp
    transaction_timestamp
    description
    transaction_payee
    debit_credit_memo
    status
    amount
    reward
    rewards
    fi_attributes
    links
    account_category
    reference_transaction_id
    card_number_display
    memo
    category
    sub_category
    category_code
    category_type
    reference
    remittance
    foreign_amount
    foreign_currency
    image_ids
    line_item
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/fdx_v660_api/models/transaction.rb', line 430

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id.inspect}, transaction_id:"\
  " #{@transaction_id.inspect}, posted_timestamp: #{@posted_timestamp.inspect},"\
  " transaction_timestamp: #{@transaction_timestamp.inspect}, description:"\
  " #{@description.inspect}, transaction_payee: #{@transaction_payee.inspect},"\
  " debit_credit_memo: #{@debit_credit_memo.inspect}, status: #{@status.inspect}, amount:"\
  " #{@amount.inspect}, reward: #{@reward.inspect}, rewards: #{@rewards.inspect},"\
  " fi_attributes: #{@fi_attributes.inspect}, links: #{@links.inspect}, account_category:"\
  " #{@account_category.inspect}, reference_transaction_id:"\
  " #{@reference_transaction_id.inspect}, card_number_display:"\
  " #{@card_number_display.inspect}, memo: #{@memo.inspect}, category: #{@category.inspect},"\
  " sub_category: #{@sub_category.inspect}, category_code: #{@category_code.inspect},"\
  " category_type: #{@category_type.inspect}, reference: #{@reference.inspect}, remittance:"\
  " #{@remittance.inspect}, foreign_amount: #{@foreign_amount.inspect}, foreign_currency:"\
  " #{@foreign_currency.inspect}, image_ids: #{@image_ids.inspect}, line_item:"\
  " #{@line_item.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_posted_timestampObject



404
405
406
# File 'lib/fdx_v660_api/models/transaction.rb', line 404

def to_custom_posted_timestamp
  DateTimeHelper.to_rfc3339(posted_timestamp)
end

#to_custom_transaction_timestampObject



408
409
410
# File 'lib/fdx_v660_api/models/transaction.rb', line 408

def to_custom_transaction_timestamp
  DateTimeHelper.to_rfc3339(transaction_timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/fdx_v660_api/models/transaction.rb', line 413

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id}, transaction_id: #{@transaction_id},"\
  " posted_timestamp: #{@posted_timestamp}, transaction_timestamp: #{@transaction_timestamp},"\
  " description: #{@description}, transaction_payee: #{@transaction_payee}, debit_credit_memo:"\
  " #{@debit_credit_memo}, status: #{@status}, amount: #{@amount}, reward: #{@reward},"\
  " rewards: #{@rewards}, fi_attributes: #{@fi_attributes}, links: #{@links},"\
  " account_category: #{@account_category}, reference_transaction_id:"\
  " #{@reference_transaction_id}, card_number_display: #{@card_number_display}, memo:"\
  " #{@memo}, category: #{@category}, sub_category: #{@sub_category}, category_code:"\
  " #{@category_code}, category_type: #{@category_type}, reference: #{@reference}, remittance:"\
  " #{@remittance}, foreign_amount: #{@foreign_amount}, foreign_currency:"\
  " #{@foreign_currency}, image_ids: #{@image_ids}, line_item: #{@line_item},"\
  " additional_properties: #{@additional_properties}>"
end