Class: SplititWebApiV4::OfferItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/splitit_web_api_v4/models/offer_item.rb

Overview

OfferItem Model.

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(total_amount:, total_fees:, number_of_installments:, installment_amount:, first_installment_amount:, offer_id: SKIP, apr: SKIP, currency: SKIP, frequency: SKIP, last_installment_amount: SKIP, inline_content: SKIP, additional_properties: nil) ⇒ OfferItem

Returns a new instance of OfferItem.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 90

def initialize(total_amount:, total_fees:, number_of_installments:,
               installment_amount:, first_installment_amount:,
               offer_id: SKIP, apr: SKIP, currency: SKIP, frequency: SKIP,
               last_installment_amount: SKIP, inline_content: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @offer_id = offer_id unless offer_id == SKIP
  @apr = apr unless apr == SKIP
  @currency = currency unless currency == SKIP
  @total_amount = total_amount
  @total_fees = total_fees
  @number_of_installments = number_of_installments
  @frequency = frequency unless frequency == SKIP
  @installment_amount = installment_amount
  @first_installment_amount = first_installment_amount
  @last_installment_amount = last_installment_amount unless last_installment_amount == SKIP
  @inline_content = inline_content unless inline_content == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#aprAprData

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 18

def apr
  @apr
end

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 22

def currency
  @currency
end

#first_installment_amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


46
47
48
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 46

def first_installment_amount
  @first_installment_amount
end

#frequencyString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 38

def frequency
  @frequency
end

#inline_contentInlineContent

TODO: Write general description for this method

Returns:



54
55
56
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 54

def inline_content
  @inline_content
end

#installment_amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


42
43
44
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 42

def installment_amount
  @installment_amount
end

#last_installment_amountAmountData

TODO: Write general description for this method

Returns:



50
51
52
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 50

def last_installment_amount
  @last_installment_amount
end

#number_of_installmentsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


34
35
36
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 34

def number_of_installments
  @number_of_installments
end

#offer_idString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 14

def offer_id
  @offer_id
end

#total_amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


26
27
28
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 26

def total_amount
  @total_amount
end

#total_feesFloat

TODO: Write general description for this method

Returns:

  • (Float)


30
31
32
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 30

def total_fees
  @total_fees
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 113

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_amount = hash.key?('TotalAmount') ? hash['TotalAmount'] : nil
  total_fees = hash.key?('TotalFees') ? hash['TotalFees'] : nil
  number_of_installments =
    hash.key?('NumberOfInstallments') ? hash['NumberOfInstallments'] : nil
  installment_amount =
    hash.key?('InstallmentAmount') ? hash['InstallmentAmount'] : nil
  first_installment_amount =
    hash.key?('FirstInstallmentAmount') ? hash['FirstInstallmentAmount'] : nil
  offer_id = hash.key?('OfferId') ? hash['OfferId'] : SKIP
  apr = AprData.from_hash(hash['Apr']) if hash['Apr']
  currency = hash.key?('Currency') ? hash['Currency'] : SKIP
  frequency = hash.key?('Frequency') ? hash['Frequency'] : SKIP
  last_installment_amount = AmountData.from_hash(hash['LastInstallmentAmount']) if
    hash['LastInstallmentAmount']
  inline_content = InlineContent.from_hash(hash['InlineContent']) if hash['InlineContent']

  # 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.
  OfferItem.new(total_amount: total_amount,
                total_fees: total_fees,
                number_of_installments: number_of_installments,
                installment_amount: installment_amount,
                first_installment_amount: first_installment_amount,
                offer_id: offer_id,
                apr: apr,
                currency: currency,
                frequency: frequency,
                last_installment_amount: last_installment_amount,
                inline_content: inline_content,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['offer_id'] = 'OfferId'
  @_hash['apr'] = 'Apr'
  @_hash['currency'] = 'Currency'
  @_hash['total_amount'] = 'TotalAmount'
  @_hash['total_fees'] = 'TotalFees'
  @_hash['number_of_installments'] = 'NumberOfInstallments'
  @_hash['frequency'] = 'Frequency'
  @_hash['installment_amount'] = 'InstallmentAmount'
  @_hash['first_installment_amount'] = 'FirstInstallmentAmount'
  @_hash['last_installment_amount'] = 'LastInstallmentAmount'
  @_hash['inline_content'] = 'InlineContent'
  @_hash
end

.nullablesObject

An array for nullable fields



86
87
88
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 86

def self.nullables
  []
end

.optionalsObject

An array for optional fields



74
75
76
77
78
79
80
81
82
83
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 74

def self.optionals
  %w[
    offer_id
    apr
    currency
    frequency
    last_installment_amount
    inline_content
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



167
168
169
170
171
172
173
174
175
176
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 167

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} offer_id: #{@offer_id.inspect}, apr: #{@apr.inspect}, currency:"\
  " #{@currency.inspect}, total_amount: #{@total_amount.inspect}, total_fees:"\
  " #{@total_fees.inspect}, number_of_installments: #{@number_of_installments.inspect},"\
  " frequency: #{@frequency.inspect}, installment_amount: #{@installment_amount.inspect},"\
  " first_installment_amount: #{@first_installment_amount.inspect}, last_installment_amount:"\
  " #{@last_installment_amount.inspect}, inline_content: #{@inline_content.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



156
157
158
159
160
161
162
163
164
# File 'lib/splitit_web_api_v4/models/offer_item.rb', line 156

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} offer_id: #{@offer_id}, apr: #{@apr}, currency: #{@currency}, total_amount:"\
  " #{@total_amount}, total_fees: #{@total_fees}, number_of_installments:"\
  " #{@number_of_installments}, frequency: #{@frequency}, installment_amount:"\
  " #{@installment_amount}, first_installment_amount: #{@first_installment_amount},"\
  " last_installment_amount: #{@last_installment_amount}, inline_content: #{@inline_content},"\
  " additional_properties: #{@additional_properties}>"
end