Class: FdxV660Api::TransactionSummary

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

Overview

Summary data elements for a financial transaction

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, additional_properties: nil) ⇒ TransactionSummary

Returns a new instance of TransactionSummary.



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/fdx_v660_api/models/transaction_summary.rb', line 121

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, 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
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idString

Corresponds to AccountId in Account

Returns:

  • (String)


15
16
17
# File 'lib/fdx_v660_api/models/transaction_summary.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_summary.rb', line 52

def amount
  @amount
end

#debit_credit_memoDebitCreditMemo2

DEBIT, CREDIT, MEMO

Returns:



44
45
46
# File 'lib/fdx_v660_api/models/transaction_summary.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_summary.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_summary.rb', line 71

def fi_attributes
  @fi_attributes
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_summary.rb', line 76

def links
  @links
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_summary.rb', line 24

def posted_timestamp
  @posted_timestamp
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_summary.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_summary.rb', line 67

def rewards
  @rewards
end

#statusTransactionStatus2

PENDING, MEMO, POSTED, AUTHORIZATION

Returns:



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

def status
  @status
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_summary.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_summary.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_summary.rb', line 29

def transaction_timestamp
  @transaction_timestamp
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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
195
196
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
# File 'lib/fdx_v660_api/models/transaction_summary.rb', line 147

def self.from_hash(hash)
  return nil unless hash

  # 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')

  # 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.
  TransactionSummary.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,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/fdx_v660_api/models/transaction_summary.rb', line 79

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
end

.nullablesObject

An array for nullable fields



117
118
119
# File 'lib/fdx_v660_api/models/transaction_summary.rb', line 117

def self.nullables
  []
end

.optionalsObject

An array for optional fields



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/fdx_v660_api/models/transaction_summary.rb', line 98

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
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



246
247
248
249
250
251
252
253
254
255
256
# File 'lib/fdx_v660_api/models/transaction_summary.rb', line 246

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}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_posted_timestampObject



226
227
228
# File 'lib/fdx_v660_api/models/transaction_summary.rb', line 226

def to_custom_posted_timestamp
  DateTimeHelper.to_rfc3339(posted_timestamp)
end

#to_custom_transaction_timestampObject



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

def to_custom_transaction_timestamp
  DateTimeHelper.to_rfc3339(transaction_timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



235
236
237
238
239
240
241
242
243
# File 'lib/fdx_v660_api/models/transaction_summary.rb', line 235

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},"\
  " additional_properties: #{@additional_properties}>"
end