Class: FdxV660Api::CommercialTransactionEntity

Inherits:
Transaction show all
Defined in:
lib/fdx_v660_api/models/commercial_transaction_entity.rb

Overview

A transaction on a commercial account type

Instance Attribute Summary collapse

Attributes inherited from Transaction

#account_category, #account_id, #amount, #card_number_display, #category, #category_code, #category_type, #debit_credit_memo, #description, #fi_attributes, #foreign_amount, #foreign_currency, #image_ids, #line_item, #links, #memo, #posted_timestamp, #reference, #reference_transaction_id, #remittance, #reward, #rewards, #status, #sub_category, #transaction_id, #transaction_payee, #transaction_timestamp

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Transaction

discriminators, #to_custom_posted_timestamp, #to_custom_transaction_timestamp

Methods inherited from BaseModel

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

Constructor Details

#initialize(immediate_available_balance: SKIP, next_day_available_balance: SKIP, two_days_plus_available_balance: SKIP, reference_bank_id: SKIP, reference_branch_id: SKIP, reference_customer_id: SKIP, commercial_code: SKIP, 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: 'Commercial Transaction entity', 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) ⇒ CommercialTransactionEntity

Returns a new instance of CommercialTransactionEntity.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 75

def initialize(immediate_available_balance: SKIP,
               next_day_available_balance: SKIP,
               two_days_plus_available_balance: SKIP,
               reference_bank_id: SKIP, reference_branch_id: SKIP,
               reference_customer_id: SKIP, commercial_code: SKIP,
               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: 'Commercial Transaction entity',
               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)
  unless immediate_available_balance == SKIP
    @immediate_available_balance =
      immediate_available_balance
  end
  unless next_day_available_balance == SKIP
    @next_day_available_balance =
      next_day_available_balance
  end
  unless two_days_plus_available_balance == SKIP
    @two_days_plus_available_balance =
      two_days_plus_available_balance
  end
  @reference_bank_id = reference_bank_id unless reference_bank_id == SKIP
  @reference_branch_id = reference_branch_id unless reference_branch_id == SKIP
  @reference_customer_id = reference_customer_id unless reference_customer_id == SKIP
  @commercial_code = commercial_code unless commercial_code == SKIP
  @additional_properties = additional_properties

  # Call the constructor of the base class
  super(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

Instance Attribute Details

#commercial_codeCommercialCodeEntity1

The code for a specific treasury management defined field



38
39
40
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 38

def commercial_code
  @commercial_code
end

#immediate_available_balanceFloat

Immediate available balance

Returns:

  • (Float)


14
15
16
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 14

def immediate_available_balance
  @immediate_available_balance
end

#next_day_available_balanceFloat

Next day available balance

Returns:

  • (Float)


18
19
20
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 18

def next_day_available_balance
  @next_day_available_balance
end

#reference_bank_idString

Reference bank id

Returns:

  • (String)


26
27
28
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 26

def reference_bank_id
  @reference_bank_id
end

#reference_branch_idString

Reference branch id

Returns:

  • (String)


30
31
32
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 30

def reference_branch_id
  @reference_branch_id
end

#reference_customer_idString

Reference customer id

Returns:

  • (String)


34
35
36
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 34

def reference_customer_id
  @reference_customer_id
end

#two_days_plus_available_balanceFloat

Two days plus available balance

Returns:

  • (Float)


22
23
24
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 22

def two_days_plus_available_balance
  @two_days_plus_available_balance
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



143
144
145
146
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
225
226
227
228
229
230
231
232
233
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
278
279
280
281
282
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 143

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  immediate_available_balance =
    hash.key?('immediateAvailableBalance') ? hash['immediateAvailableBalance'] : SKIP
  next_day_available_balance =
    hash.key?('nextDayAvailableBalance') ? hash['nextDayAvailableBalance'] : SKIP
  two_days_plus_available_balance =
    hash.key?('twoDaysPlusAvailableBalance') ? hash['twoDaysPlusAvailableBalance'] : SKIP
  reference_bank_id =
    hash.key?('referenceBankId') ? hash['referenceBankId'] : SKIP
  reference_branch_id =
    hash.key?('referenceBranchId') ? hash['referenceBranchId'] : SKIP
  reference_customer_id =
    hash.key?('referenceCustomerId') ? hash['referenceCustomerId'] : SKIP
  commercial_code = CommercialCodeEntity1.from_hash(hash['commercialCode']) if
    hash['commercialCode']
   = 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'] ||= 'Commercial Transaction entity'
  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.
  CommercialTransactionEntity.new(immediate_available_balance: immediate_available_balance,
                                  next_day_available_balance: next_day_available_balance,
                                  two_days_plus_available_balance: two_days_plus_available_balance,
                                  reference_bank_id: reference_bank_id,
                                  reference_branch_id: reference_branch_id,
                                  reference_customer_id: reference_customer_id,
                                  commercial_code: commercial_code,
                                  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.



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['immediate_available_balance'] = 'immediateAvailableBalance'
  @_hash['next_day_available_balance'] = 'nextDayAvailableBalance'
  @_hash['two_days_plus_available_balance'] =
    'twoDaysPlusAvailableBalance'
  @_hash['reference_bank_id'] = 'referenceBankId'
  @_hash['reference_branch_id'] = 'referenceBranchId'
  @_hash['reference_customer_id'] = 'referenceCustomerId'
  @_hash['commercial_code'] = 'commercialCode'
  @_hash = super().merge(@_hash)
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  _arr = []
  (_arr << super()).flatten!
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 56

def self.optionals
  _arr = %w[
    immediate_available_balance
    next_day_available_balance
    two_days_plus_available_balance
    reference_bank_id
    reference_branch_id
    reference_customer_id
    commercial_code
  ]
  (_arr << super()).flatten!
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



286
287
288
289
290
291
292
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 286

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



307
308
309
310
311
312
313
314
315
316
317
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 307

def inspect
  class_name = self.class.name.split('::').last
  super_string = super().inspect.sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, immediate_available_balance:"\
  " #{@immediate_available_balance.inspect}, next_day_available_balance:"\
  " #{@next_day_available_balance.inspect}, two_days_plus_available_balance:"\
  " #{@two_days_plus_available_balance.inspect}, reference_bank_id:"\
  " #{@reference_bank_id.inspect}, reference_branch_id: #{@reference_branch_id.inspect},"\
  " reference_customer_id: #{@reference_customer_id.inspect}, commercial_code:"\
  " #{@commercial_code.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



295
296
297
298
299
300
301
302
303
304
# File 'lib/fdx_v660_api/models/commercial_transaction_entity.rb', line 295

def to_s
  class_name = self.class.name.split('::').last
  super_string = super().sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, immediate_available_balance:"\
  " #{@immediate_available_balance}, next_day_available_balance:"\
  " #{@next_day_available_balance}, two_days_plus_available_balance:"\
  " #{@two_days_plus_available_balance}, reference_bank_id: #{@reference_bank_id},"\
  " reference_branch_id: #{@reference_branch_id}, reference_customer_id:"\
  " #{@reference_customer_id}, commercial_code: #{@commercial_code}>"
end