Class: FdxV660Api::BuyNowPayLaterPurchaseDetails

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

Overview

A Buy Now Pay Later purchase details

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(payment_frequency: SKIP, payment_frequency_multiplier: SKIP, number_of_payments: SKIP, original_principal: SKIP, transaction_payee: SKIP, bills: SKIP, scheduled_payments: SKIP, charged_interest: SKIP, purchase_apr: SKIP, purchase_timestamp: SKIP, additional_properties: nil) ⇒ BuyNowPayLaterPurchaseDetails

Returns a new instance of BuyNowPayLaterPurchaseDetails.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 92

def initialize(payment_frequency: SKIP, payment_frequency_multiplier: SKIP,
               number_of_payments: SKIP, original_principal: SKIP,
               transaction_payee: SKIP, bills: SKIP,
               scheduled_payments: SKIP, charged_interest: SKIP,
               purchase_apr: SKIP, purchase_timestamp: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @payment_frequency = payment_frequency unless payment_frequency == SKIP
  unless payment_frequency_multiplier == SKIP
    @payment_frequency_multiplier =
      payment_frequency_multiplier
  end
  @number_of_payments = number_of_payments unless number_of_payments == SKIP
  @original_principal = original_principal unless original_principal == SKIP
  @transaction_payee = transaction_payee unless transaction_payee == SKIP
  @bills = bills unless bills == SKIP
  @scheduled_payments = scheduled_payments unless scheduled_payments == SKIP
  @charged_interest = charged_interest unless charged_interest == SKIP
  @purchase_apr = purchase_apr unless purchase_apr == SKIP
  @purchase_timestamp = purchase_timestamp unless purchase_timestamp == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#billsArray[BillEntity]

Payments due on the buy now pay later account

Returns:



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

def bills
  @bills
end

#charged_interestInterestRateEntity8

The periodic interest rate charged on the purchase

Returns:



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

def charged_interest
  @charged_interest
end

#number_of_paymentsFloat

The number of payments expected

Returns:

  • (Float)


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

def number_of_payments
  @number_of_payments
end

#original_principalFloat

The buy now pay later purchase price

Returns:

  • (Float)


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

def original_principal
  @original_principal
end

#payment_frequencyEventFrequency3

Defines how often the payment repeats

Returns:



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

def payment_frequency
  @payment_frequency
end

#payment_frequency_multiplierFloat

If present multiplies the paymentFrequency eg. every 3 weeks, otherwise defaults to 1

Returns:

  • (Float)


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

def payment_frequency_multiplier
  @payment_frequency_multiplier
end

#purchase_aprFloat

The APR on the buy now pay later purchase, if the purchase is interest-bearing

Returns:

  • (Float)


49
50
51
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 49

def purchase_apr
  @purchase_apr
end

#purchase_timestampDateTime

When the buy now pay later item was purchased

Returns:

  • (DateTime)


53
54
55
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 53

def purchase_timestamp
  @purchase_timestamp
end

#scheduled_paymentsArray[ScheduledPaymentEntity]

Array of payments scheduled

Returns:



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

def scheduled_payments
  @scheduled_payments
end

#transaction_payeeTransactionPayeeEntity1

The payee for the buy now pay later item



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

def transaction_payee
  @transaction_payee
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_frequency =
    hash.key?('paymentFrequency') ? hash['paymentFrequency'] : SKIP
  payment_frequency_multiplier =
    hash.key?('paymentFrequencyMultiplier') ? hash['paymentFrequencyMultiplier'] : SKIP
  number_of_payments =
    hash.key?('numberOfPayments') ? hash['numberOfPayments'] : SKIP
  original_principal =
    hash.key?('originalPrincipal') ? hash['originalPrincipal'] : SKIP
  transaction_payee = TransactionPayeeEntity1.from_hash(hash['transactionPayee']) if
    hash['transactionPayee']
  # Parameter is an array, so we need to iterate through it
  bills = nil
  unless hash['bills'].nil?
    bills = []
    hash['bills'].each do |structure|
      bills << (BillEntity.from_hash(structure) if structure)
    end
  end

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

  scheduled_payments = SKIP unless hash.key?('scheduledPayments')
  charged_interest = InterestRateEntity8.from_hash(hash['chargedInterest']) if
    hash['chargedInterest']
  purchase_apr = hash.key?('purchaseApr') ? hash['purchaseApr'] : SKIP
  purchase_timestamp = if hash.key?('purchaseTimestamp')
                         (DateTimeHelper.from_rfc3339(hash['purchaseTimestamp']) if hash['purchaseTimestamp'])
                       else
                         SKIP
                       end

  # 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.
  BuyNowPayLaterPurchaseDetails.new(payment_frequency: payment_frequency,
                                    payment_frequency_multiplier: payment_frequency_multiplier,
                                    number_of_payments: number_of_payments,
                                    original_principal: original_principal,
                                    transaction_payee: transaction_payee,
                                    bills: bills,
                                    scheduled_payments: scheduled_payments,
                                    charged_interest: charged_interest,
                                    purchase_apr: purchase_apr,
                                    purchase_timestamp: purchase_timestamp,
                                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payment_frequency'] = 'paymentFrequency'
  @_hash['payment_frequency_multiplier'] = 'paymentFrequencyMultiplier'
  @_hash['number_of_payments'] = 'numberOfPayments'
  @_hash['original_principal'] = 'originalPrincipal'
  @_hash['transaction_payee'] = 'transactionPayee'
  @_hash['bills'] = 'bills'
  @_hash['scheduled_payments'] = 'scheduledPayments'
  @_hash['charged_interest'] = 'chargedInterest'
  @_hash['purchase_apr'] = 'purchaseApr'
  @_hash['purchase_timestamp'] = 'purchaseTimestamp'
  @_hash
end

.nullablesObject

An array for nullable fields



88
89
90
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 88

def self.nullables
  []
end

.optionalsObject

An array for optional fields



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 72

def self.optionals
  %w[
    payment_frequency
    payment_frequency_multiplier
    number_of_payments
    original_principal
    transaction_payee
    bills
    scheduled_payments
    charged_interest
    purchase_apr
    purchase_timestamp
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



198
199
200
201
202
203
204
205
206
207
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 198

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} payment_frequency: #{@payment_frequency.inspect},"\
  " payment_frequency_multiplier: #{@payment_frequency_multiplier.inspect},"\
  " number_of_payments: #{@number_of_payments.inspect}, original_principal:"\
  " #{@original_principal.inspect}, transaction_payee: #{@transaction_payee.inspect}, bills:"\
  " #{@bills.inspect}, scheduled_payments: #{@scheduled_payments.inspect}, charged_interest:"\
  " #{@charged_interest.inspect}, purchase_apr: #{@purchase_apr.inspect}, purchase_timestamp:"\
  " #{@purchase_timestamp.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_purchase_timestampObject



182
183
184
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 182

def to_custom_purchase_timestamp
  DateTimeHelper.to_rfc3339(purchase_timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



187
188
189
190
191
192
193
194
195
# File 'lib/fdx_v660_api/models/buy_now_pay_later_purchase_details.rb', line 187

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} payment_frequency: #{@payment_frequency}, payment_frequency_multiplier:"\
  " #{@payment_frequency_multiplier}, number_of_payments: #{@number_of_payments},"\
  " original_principal: #{@original_principal}, transaction_payee: #{@transaction_payee},"\
  " bills: #{@bills}, scheduled_payments: #{@scheduled_payments}, charged_interest:"\
  " #{@charged_interest}, purchase_apr: #{@purchase_apr}, purchase_timestamp:"\
  " #{@purchase_timestamp}, additional_properties: #{@additional_properties}>"
end