Class: FdxV660Api::LineOfCreditTransactionEntity

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

Overview

A line of credit transaction

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(transaction_type: SKIP, check_number: SKIP, payment_details: 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: 'Line of Credit 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) ⇒ LineOfCreditTransactionEntity

Returns a new instance of LineOfCreditTransactionEntity.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 51

def initialize(transaction_type: SKIP, check_number: SKIP,
               payment_details: 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: 'Line of Credit 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)
  @transaction_type = transaction_type unless transaction_type == SKIP
  @check_number = check_number unless check_number == SKIP
  @payment_details = payment_details unless payment_details == 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

#check_numberInteger

Check number, or cheque number on Canadian accounts

Returns:

  • (Integer)


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

def check_number
  @check_number
end

#payment_detailsPaymentDetailsEntity1

Breakdown of payment details



23
24
25
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 23

def payment_details
  @payment_details
end

#transaction_typeLineOfCreditTransactionType2

The type of the transaction on the line of credit account. ADJUSTMENT, CHECK, FEE, INTEREST, PAYMENT, PURCHASE, WITHDRAWAL



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

def transaction_type
  @transaction_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
141
142
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
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 102

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_type =
    hash.key?('transactionType') ? hash['transactionType'] : SKIP
  check_number = hash.key?('checkNumber') ? hash['checkNumber'] : SKIP
  payment_details = PaymentDetailsEntity1.from_hash(hash['paymentDetails']) if
    hash['paymentDetails']
   = 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'] ||= 'Line of Credit 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.
  LineOfCreditTransactionEntity.new(transaction_type: transaction_type,
                                    check_number: check_number,
                                    payment_details: payment_details,
                                    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.



26
27
28
29
30
31
32
33
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_type'] = 'transactionType'
  @_hash['check_number'] = 'checkNumber'
  @_hash['payment_details'] = 'paymentDetails'
  @_hash = super().merge(@_hash)
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
49
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 46

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

.optionalsObject

An array for optional fields



36
37
38
39
40
41
42
43
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 36

def self.optionals
  _arr = %w[
    transaction_type
    check_number
    payment_details
  ]
  (_arr << super()).flatten!
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



232
233
234
235
236
237
238
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 232

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.



249
250
251
252
253
254
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 249

def inspect
  class_name = self.class.name.split('::').last
  super_string = super().inspect.sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, transaction_type: #{@transaction_type.inspect},"\
  " check_number: #{@check_number.inspect}, payment_details: #{@payment_details.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



241
242
243
244
245
246
# File 'lib/fdx_v660_api/models/line_of_credit_transaction_entity.rb', line 241

def to_s
  class_name = self.class.name.split('::').last
  super_string = super().sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, transaction_type: #{@transaction_type}, check_number:"\
  " #{@check_number}, payment_details: #{@payment_details}>"
end