Class: FdxV660Api::PromotionEntity

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

Overview

The promotions originally defined in Ts & Cs or currently active for a promotion on a loan or line of credit account

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(type: SKIP, balance: SKIP, promotion_apr: SKIP, balance_subject_to_interest_rate: SKIP, days_in_billing_cycle: SKIP, interest_charge: SKIP, start_date: SKIP, end_date: SKIP, transaction_date: SKIP, special_terms_end_date: SKIP, balance_subject_to_deferred_interest: SKIP, deferred_interest_charge: SKIP, special_terms_balance: SKIP, additional_properties: nil) ⇒ PromotionEntity

Returns a new instance of PromotionEntity.



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

def initialize(type: SKIP, balance: SKIP, promotion_apr: SKIP,
               balance_subject_to_interest_rate: SKIP,
               days_in_billing_cycle: SKIP, interest_charge: SKIP,
               start_date: SKIP, end_date: SKIP, transaction_date: SKIP,
               special_terms_end_date: SKIP,
               balance_subject_to_deferred_interest: SKIP,
               deferred_interest_charge: SKIP, special_terms_balance: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @type = type unless type == SKIP
  @balance = balance unless balance == SKIP
  @promotion_apr = promotion_apr unless promotion_apr == SKIP
  unless balance_subject_to_interest_rate == SKIP
    @balance_subject_to_interest_rate =
      balance_subject_to_interest_rate
  end
  @days_in_billing_cycle = days_in_billing_cycle unless days_in_billing_cycle == SKIP
  @interest_charge = interest_charge unless interest_charge == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @transaction_date = transaction_date unless transaction_date == SKIP
  @special_terms_end_date = special_terms_end_date unless special_terms_end_date == SKIP
  unless balance_subject_to_deferred_interest == SKIP
    @balance_subject_to_deferred_interest =
      balance_subject_to_deferred_interest
  end
  @deferred_interest_charge = deferred_interest_charge unless deferred_interest_charge == SKIP
  @special_terms_balance = special_terms_balance unless special_terms_balance == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#balanceFloat

Defined or active Promotion balance

Returns:

  • (Float)


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

def balance
  @balance
end

#balance_subject_to_deferred_interestFloat

Defined or active Promotion - Balance Subject to Deferred Interest

Returns:

  • (Float)


55
56
57
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 55

def balance_subject_to_deferred_interest
  @balance_subject_to_deferred_interest
end

#balance_subject_to_interest_rateFloat

Defined or active Promotion balance subject to Interest Rate

Returns:

  • (Float)


27
28
29
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 27

def balance_subject_to_interest_rate
  @balance_subject_to_interest_rate
end

#days_in_billing_cycleInteger

Defined or active Promotion - Days in Billing Cycle

Returns:

  • (Integer)


31
32
33
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 31

def days_in_billing_cycle
  @days_in_billing_cycle
end

#deferred_interest_chargeFloat

Defined or active Promotion - Deferred Interest Charge

Returns:

  • (Float)


59
60
61
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 59

def deferred_interest_charge
  @deferred_interest_charge
end

#end_dateDate

Defined or active Promotion - End Date

Returns:

  • (Date)


43
44
45
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 43

def end_date
  @end_date
end

#interest_chargeFloat

Defined or active Promotion - Interest Charge

Returns:

  • (Float)


35
36
37
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 35

def interest_charge
  @interest_charge
end

#promotion_aprFloat

Current annual percentage rate (APR) for defined or active Promotion

Returns:

  • (Float)


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

def promotion_apr
  @promotion_apr
end

#special_terms_balanceFloat

Defined or active Promotion - Special Terms Balance

Returns:

  • (Float)


63
64
65
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 63

def special_terms_balance
  @special_terms_balance
end

#special_terms_end_dateDate

Defined or active Promotion - Special Terms End Date

Returns:

  • (Date)


51
52
53
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 51

def special_terms_end_date
  @special_terms_end_date
end

#start_dateDate

Defined or active Promotion - Start Date

Returns:

  • (Date)


39
40
41
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 39

def start_date
  @start_date
end

#transaction_dateDate

Defined or active Promotion - Transaction Date

Returns:

  • (Date)


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

def transaction_date
  @transaction_date
end

#typeString

Defined or active Promotion Type

Returns:

  • (String)


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

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : SKIP
  balance = hash.key?('balance') ? hash['balance'] : SKIP
  promotion_apr = hash.key?('promotionApr') ? hash['promotionApr'] : SKIP
  balance_subject_to_interest_rate =
    hash.key?('balanceSubjectToInterestRate') ? hash['balanceSubjectToInterestRate'] : SKIP
  days_in_billing_cycle =
    hash.key?('daysInBillingCycle') ? hash['daysInBillingCycle'] : SKIP
  interest_charge =
    hash.key?('interestCharge') ? hash['interestCharge'] : SKIP
  start_date = hash.key?('startDate') ? hash['startDate'] : SKIP
  end_date = hash.key?('endDate') ? hash['endDate'] : SKIP
  transaction_date =
    hash.key?('transactionDate') ? hash['transactionDate'] : SKIP
  special_terms_end_date =
    hash.key?('specialTermsEndDate') ? hash['specialTermsEndDate'] : SKIP
  balance_subject_to_deferred_interest =
    hash.key?('balanceSubjectToDeferredInterest') ? hash['balanceSubjectToDeferredInterest'] : SKIP
  deferred_interest_charge =
    hash.key?('deferredInterestCharge') ? hash['deferredInterestCharge'] : SKIP
  special_terms_balance =
    hash.key?('specialTermsBalance') ? hash['specialTermsBalance'] : SKIP

  # 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.
  PromotionEntity.new(type: type,
                      balance: balance,
                      promotion_apr: promotion_apr,
                      balance_subject_to_interest_rate: balance_subject_to_interest_rate,
                      days_in_billing_cycle: days_in_billing_cycle,
                      interest_charge: interest_charge,
                      start_date: start_date,
                      end_date: end_date,
                      transaction_date: transaction_date,
                      special_terms_end_date: special_terms_end_date,
                      balance_subject_to_deferred_interest: balance_subject_to_deferred_interest,
                      deferred_interest_charge: deferred_interest_charge,
                      special_terms_balance: special_terms_balance,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 66

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['balance'] = 'balance'
  @_hash['promotion_apr'] = 'promotionApr'
  @_hash['balance_subject_to_interest_rate'] =
    'balanceSubjectToInterestRate'
  @_hash['days_in_billing_cycle'] = 'daysInBillingCycle'
  @_hash['interest_charge'] = 'interestCharge'
  @_hash['start_date'] = 'startDate'
  @_hash['end_date'] = 'endDate'
  @_hash['transaction_date'] = 'transactionDate'
  @_hash['special_terms_end_date'] = 'specialTermsEndDate'
  @_hash['balance_subject_to_deferred_interest'] =
    'balanceSubjectToDeferredInterest'
  @_hash['deferred_interest_charge'] = 'deferredInterestCharge'
  @_hash['special_terms_balance'] = 'specialTermsBalance'
  @_hash
end

.nullablesObject

An array for nullable fields



106
107
108
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 106

def self.nullables
  []
end

.optionalsObject

An array for optional fields



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 87

def self.optionals
  %w[
    type
    balance
    promotion_apr
    balance_subject_to_interest_rate
    days_in_billing_cycle
    interest_charge
    start_date
    end_date
    transaction_date
    special_terms_end_date
    balance_subject_to_deferred_interest
    deferred_interest_charge
    special_terms_balance
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (PromotionEntity | Hash)

    value against the validation is performed.



196
197
198
199
200
201
202
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 196

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.



218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 218

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type.inspect}, balance: #{@balance.inspect}, promotion_apr:"\
  " #{@promotion_apr.inspect}, balance_subject_to_interest_rate:"\
  " #{@balance_subject_to_interest_rate.inspect}, days_in_billing_cycle:"\
  " #{@days_in_billing_cycle.inspect}, interest_charge: #{@interest_charge.inspect},"\
  " start_date: #{@start_date.inspect}, end_date: #{@end_date.inspect}, transaction_date:"\
  " #{@transaction_date.inspect}, special_terms_end_date: #{@special_terms_end_date.inspect},"\
  " balance_subject_to_deferred_interest: #{@balance_subject_to_deferred_interest.inspect},"\
  " deferred_interest_charge: #{@deferred_interest_charge.inspect}, special_terms_balance:"\
  " #{@special_terms_balance.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



205
206
207
208
209
210
211
212
213
214
215
# File 'lib/fdx_v660_api/models/promotion_entity.rb', line 205

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type}, balance: #{@balance}, promotion_apr: #{@promotion_apr},"\
  " balance_subject_to_interest_rate: #{@balance_subject_to_interest_rate},"\
  " days_in_billing_cycle: #{@days_in_billing_cycle}, interest_charge: #{@interest_charge},"\
  " start_date: #{@start_date}, end_date: #{@end_date}, transaction_date:"\
  " #{@transaction_date}, special_terms_end_date: #{@special_terms_end_date},"\
  " balance_subject_to_deferred_interest: #{@balance_subject_to_deferred_interest},"\
  " deferred_interest_charge: #{@deferred_interest_charge}, special_terms_balance:"\
  " #{@special_terms_balance}, additional_properties: #{@additional_properties}>"
end