Class: FdxV660Api::BuyNowPayLaterTransactionEntity

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

Overview

A buy now pay later 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(bnpl_status: SKIP, fees: SKIP, next_payment_amount: SKIP, next_payment_date: SKIP, purchase_details: SKIP, payment_details: SKIP, outstanding_balance: SKIP, transaction_type: 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: 'Buy Now Pay Later 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) ⇒ BuyNowPayLaterTransactionEntity

Returns a new instance of BuyNowPayLaterTransactionEntity.



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
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 83

def initialize(bnpl_status: SKIP, fees: SKIP, next_payment_amount: SKIP,
               next_payment_date: SKIP, purchase_details: SKIP,
               payment_details: SKIP, outstanding_balance: SKIP,
               transaction_type: 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: 'Buy Now Pay Later 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)
  @bnpl_status = bnpl_status unless bnpl_status == SKIP
  @fees = fees unless fees == SKIP
  @next_payment_amount = next_payment_amount unless next_payment_amount == SKIP
  @next_payment_date = next_payment_date unless next_payment_date == SKIP
  @purchase_details = purchase_details unless purchase_details == SKIP
  @payment_details = payment_details unless payment_details == SKIP
  @outstanding_balance = outstanding_balance unless outstanding_balance == SKIP
  @transaction_type = transaction_type unless transaction_type == 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

#bnpl_statusAccountStatus1

Buy Now, Pay Later item status. One of: OPEN, CLOSED, PENDINGOPEN, PENDINGCLOSE, PAID, DELINQUENT, NEGATIVECURRENTBALANCE, RESTRICTED

Returns:



16
17
18
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 16

def bnpl_status
  @bnpl_status
end

#feesFloat

Fees charged on the buy now pay later purchase

Returns:

  • (Float)


20
21
22
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 20

def fees
  @fees
end

#next_payment_amountFloat

Amount of next payment

Returns:

  • (Float)


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

def next_payment_amount
  @next_payment_amount
end

#next_payment_dateDate

Due date of next payment

Returns:

  • (Date)


28
29
30
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 28

def next_payment_date
  @next_payment_date
end

#outstanding_balanceFloat

The outstanding balance on the buy now pay later purchase

Returns:

  • (Float)


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

def outstanding_balance
  @outstanding_balance
end

#payment_detailsPaymentDetailsEntity1

Breakdown of payment details



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

def payment_details
  @payment_details
end

#purchase_detailsBuyNowPayLaterPurchaseDetails1

Buy now pay later details



32
33
34
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 32

def purchase_details
  @purchase_details
end

#transaction_typeBuyNowPayLaterTransactionType2

The transaction type; one of CHECK, PAYMENT, FEE, ADJUSTMENT, INTEREST, PURCHASE



45
46
47
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 45

def transaction_type
  @transaction_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  bnpl_status = hash.key?('bnplStatus') ? hash['bnplStatus'] : SKIP
  fees = hash.key?('fees') ? hash['fees'] : SKIP
  next_payment_amount =
    hash.key?('nextPaymentAmount') ? hash['nextPaymentAmount'] : SKIP
  next_payment_date =
    hash.key?('nextPaymentDate') ? hash['nextPaymentDate'] : SKIP
  purchase_details = BuyNowPayLaterPurchaseDetails1.from_hash(hash['purchaseDetails']) if
    hash['purchaseDetails']
  payment_details = PaymentDetailsEntity1.from_hash(hash['paymentDetails']) if
    hash['paymentDetails']
  outstanding_balance =
    hash.key?('outstandingBalance') ? hash['outstandingBalance'] : SKIP
  transaction_type =
    hash.key?('transactionType') ? hash['transactionType'] : SKIP
   = 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'] ||= 'Buy Now Pay Later 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.
  BuyNowPayLaterTransactionEntity.new(bnpl_status: bnpl_status,
                                      fees: fees,
                                      next_payment_amount: next_payment_amount,
                                      next_payment_date: next_payment_date,
                                      purchase_details: purchase_details,
                                      payment_details: payment_details,
                                      outstanding_balance: outstanding_balance,
                                      transaction_type: transaction_type,
                                      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.



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 48

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['bnpl_status'] = 'bnplStatus'
  @_hash['fees'] = 'fees'
  @_hash['next_payment_amount'] = 'nextPaymentAmount'
  @_hash['next_payment_date'] = 'nextPaymentDate'
  @_hash['purchase_details'] = 'purchaseDetails'
  @_hash['payment_details'] = 'paymentDetails'
  @_hash['outstanding_balance'] = 'outstandingBalance'
  @_hash['transaction_type'] = 'transactionType'
  @_hash = super().merge(@_hash)
  @_hash
end

.nullablesObject

An array for nullable fields



78
79
80
81
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 78

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

.optionalsObject

An array for optional fields



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 63

def self.optionals
  _arr = %w[
    bnpl_status
    fees
    next_payment_amount
    next_payment_date
    purchase_details
    payment_details
    outstanding_balance
    transaction_type
  ]
  (_arr << super()).flatten!
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

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.



304
305
306
307
308
309
310
311
312
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 304

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

#to_sObject

Provides a human-readable string representation of the object.



294
295
296
297
298
299
300
301
# File 'lib/fdx_v660_api/models/buy_now_pay_later_transaction_entity.rb', line 294

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