Class: SplititWebApiV4::AuthorizeResponse

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

Overview

AuthorizeResponse 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(date_created:, plan_status:, purchase_method:, purchase_amount:, total_fees:, total_amount:, installment_plan_number: SKIP, merchant_order_reference: SKIP, currency: SKIP, apr: SKIP, authorization: SKIP, payment_method: SKIP, installments: SKIP, metadata: SKIP, additional_properties: nil) ⇒ AuthorizeResponse

Returns a new instance of AuthorizeResponse.



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

def initialize(date_created:, plan_status:, purchase_method:,
               purchase_amount:, total_fees:, total_amount:,
               installment_plan_number: SKIP,
               merchant_order_reference: SKIP, currency: SKIP, apr: SKIP,
               authorization: SKIP, payment_method: SKIP,
               installments: SKIP, metadata: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @date_created = date_created
  @plan_status = plan_status
  @installment_plan_number = installment_plan_number unless installment_plan_number == SKIP
  @merchant_order_reference = merchant_order_reference unless merchant_order_reference == SKIP
  @purchase_method = purchase_method
  @currency = currency unless currency == SKIP
  @purchase_amount = purchase_amount
  @total_fees = total_fees
  @total_amount = total_amount
  @apr = apr unless apr == SKIP
  @authorization = authorization unless authorization == SKIP
  @payment_method = payment_method unless payment_method == SKIP
  @installments = installments unless installments == SKIP
  @metadata =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#aprAprData

TODO: Write general description for this method

Returns:



51
52
53
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 51

def apr
  @apr
end

#authorizationAuthorizeAuthorizationData

TODO: Write general description for this method



55
56
57
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 55

def authorization
  @authorization
end

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


35
36
37
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 35

def currency
  @currency
end

#date_createdDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


15
16
17
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 15

def date_created
  @date_created
end

#installment_plan_numberString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 23

def installment_plan_number
  @installment_plan_number
end

#installmentsArray[InstallmentItem]

TODO: Write general description for this method

Returns:



63
64
65
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 63

def installments
  @installments
end

#merchant_order_referenceString

TODO: Write general description for this method

Returns:

  • (String)


27
28
29
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 27

def merchant_order_reference
  @merchant_order_reference
end

#metadataArray[MetadataItem]

TODO: Write general description for this method

Returns:



67
68
69
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 67

def 
  @metadata
end

#payment_methodPaymentMethodData

TODO: Write general description for this method

Returns:



59
60
61
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 59

def payment_method
  @payment_method
end

#plan_statusInstallmentPlanStatus

TODO: Write general description for this method



19
20
21
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 19

def plan_status
  @plan_status
end

#purchase_amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


39
40
41
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 39

def purchase_amount
  @purchase_amount
end

#purchase_methodPurchaseMethod

TODO: Write general description for this method

Returns:



31
32
33
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 31

def purchase_method
  @purchase_method
end

#total_amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


47
48
49
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 47

def total_amount
  @total_amount
end

#total_feesFloat

TODO: Write general description for this method

Returns:

  • (Float)


43
44
45
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 43

def total_fees
  @total_fees
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  date_created = if hash.key?('DateCreated')
                   (DateTimeHelper.from_rfc3339(hash['DateCreated']) if hash['DateCreated'])
                 end
  plan_status = hash.key?('PlanStatus') ? hash['PlanStatus'] : nil
  purchase_method =
    hash.key?('PurchaseMethod') ? hash['PurchaseMethod'] : nil
  purchase_amount =
    hash.key?('PurchaseAmount') ? hash['PurchaseAmount'] : nil
  total_fees = hash.key?('TotalFees') ? hash['TotalFees'] : nil
  total_amount = hash.key?('TotalAmount') ? hash['TotalAmount'] : nil
  installment_plan_number =
    hash.key?('InstallmentPlanNumber') ? hash['InstallmentPlanNumber'] : SKIP
  merchant_order_reference =
    hash.key?('MerchantOrderReference') ? hash['MerchantOrderReference'] : SKIP
  currency = hash.key?('Currency') ? hash['Currency'] : SKIP
  apr = AprData.from_hash(hash['Apr']) if hash['Apr']
  authorization = AuthorizeAuthorizationData.from_hash(hash['Authorization']) if
    hash['Authorization']
  payment_method = PaymentMethodData.from_hash(hash['PaymentMethod']) if hash['PaymentMethod']
  # Parameter is an array, so we need to iterate through it
  installments = nil
  unless hash['Installments'].nil?
    installments = []
    hash['Installments'].each do |structure|
      installments << (InstallmentItem.from_hash(structure) if structure)
    end
  end

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

   = SKIP unless hash.key?('Metadata')

  # 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.
  AuthorizeResponse.new(date_created: date_created,
                        plan_status: plan_status,
                        purchase_method: purchase_method,
                        purchase_amount: purchase_amount,
                        total_fees: total_fees,
                        total_amount: total_amount,
                        installment_plan_number: installment_plan_number,
                        merchant_order_reference: merchant_order_reference,
                        currency: currency,
                        apr: apr,
                        authorization: authorization,
                        payment_method: payment_method,
                        installments: installments,
                        metadata: ,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 70

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['date_created'] = 'DateCreated'
  @_hash['plan_status'] = 'PlanStatus'
  @_hash['installment_plan_number'] = 'InstallmentPlanNumber'
  @_hash['merchant_order_reference'] = 'MerchantOrderReference'
  @_hash['purchase_method'] = 'PurchaseMethod'
  @_hash['currency'] = 'Currency'
  @_hash['purchase_amount'] = 'PurchaseAmount'
  @_hash['total_fees'] = 'TotalFees'
  @_hash['total_amount'] = 'TotalAmount'
  @_hash['apr'] = 'Apr'
  @_hash['authorization'] = 'Authorization'
  @_hash['payment_method'] = 'PaymentMethod'
  @_hash['installments'] = 'Installments'
  @_hash['metadata'] = 'Metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



104
105
106
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 104

def self.nullables
  []
end

.optionalsObject

An array for optional fields



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 90

def self.optionals
  %w[
    installment_plan_number
    merchant_order_reference
    currency
    apr
    authorization
    payment_method
    installments
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



222
223
224
225
226
227
228
229
230
231
232
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 222

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} date_created: #{@date_created.inspect}, plan_status:"\
  " #{@plan_status.inspect}, installment_plan_number: #{@installment_plan_number.inspect},"\
  " merchant_order_reference: #{@merchant_order_reference.inspect}, purchase_method:"\
  " #{@purchase_method.inspect}, currency: #{@currency.inspect}, purchase_amount:"\
  " #{@purchase_amount.inspect}, total_fees: #{@total_fees.inspect}, total_amount:"\
  " #{@total_amount.inspect}, apr: #{@apr.inspect}, authorization: #{@authorization.inspect},"\
  " payment_method: #{@payment_method.inspect}, installments: #{@installments.inspect},"\
  " metadata: #{@metadata.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_date_createdObject



205
206
207
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 205

def to_custom_date_created
  DateTimeHelper.to_rfc3339(date_created)
end

#to_sObject

Provides a human-readable string representation of the object.



210
211
212
213
214
215
216
217
218
219
# File 'lib/splitit_web_api_v4/models/authorize_response.rb', line 210

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} date_created: #{@date_created}, plan_status: #{@plan_status},"\
  " installment_plan_number: #{@installment_plan_number}, merchant_order_reference:"\
  " #{@merchant_order_reference}, purchase_method: #{@purchase_method}, currency:"\
  " #{@currency}, purchase_amount: #{@purchase_amount}, total_fees: #{@total_fees},"\
  " total_amount: #{@total_amount}, apr: #{@apr}, authorization: #{@authorization},"\
  " payment_method: #{@payment_method}, installments: #{@installments}, metadata:"\
  " #{@metadata}, additional_properties: #{@additional_properties}>"
end