Class: SplititWebApiV4::OffersResponse
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SplititWebApiV4::OffersResponse
- Defined in:
- lib/splitit_web_api_v4/models/offers_response.rb
Overview
OffersResponse Model.
Instance Attribute Summary collapse
-
#currency ⇒ String
TODO: Write general description for this method.
-
#installment_plan_number ⇒ String
TODO: Write general description for this method.
-
#merchant_order_reference ⇒ String
TODO: Write general description for this method.
-
#offers ⇒ Array[OfferItem]
TODO: Write general description for this method.
-
#payment_method ⇒ OffersPaymentMethodResponse
TODO: Write general description for this method.
-
#purchase_amount ⇒ Float
TODO: Write general description for this method.
-
#purchase_method ⇒ PurchaseMethod
TODO: Write general description for this method.
-
#valid_until ⇒ DateTime
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(purchase_method:, purchase_amount:, installment_plan_number: SKIP, merchant_order_reference: SKIP, currency: SKIP, payment_method: SKIP, offers: SKIP, valid_until: SKIP, additional_properties: nil) ⇒ OffersResponse
constructor
A new instance of OffersResponse.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_valid_until ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(purchase_method:, purchase_amount:, installment_plan_number: SKIP, merchant_order_reference: SKIP, currency: SKIP, payment_method: SKIP, offers: SKIP, valid_until: SKIP, additional_properties: nil) ⇒ OffersResponse
Returns a new instance of OffersResponse.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 76 def initialize(purchase_method:, purchase_amount:, installment_plan_number: SKIP, merchant_order_reference: SKIP, currency: SKIP, payment_method: SKIP, offers: SKIP, valid_until: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @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 @purchase_amount = purchase_amount @currency = currency unless currency == SKIP @payment_method = payment_method unless payment_method == SKIP @offers = offers unless offers == SKIP @valid_until = valid_until unless valid_until == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#currency ⇒ String
TODO: Write general description for this method
31 32 33 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 31 def currency @currency end |
#installment_plan_number ⇒ String
TODO: Write general description for this method
15 16 17 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 15 def installment_plan_number @installment_plan_number end |
#merchant_order_reference ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 19 def merchant_order_reference @merchant_order_reference end |
#offers ⇒ Array[OfferItem]
TODO: Write general description for this method
39 40 41 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 39 def offers @offers end |
#payment_method ⇒ OffersPaymentMethodResponse
TODO: Write general description for this method
35 36 37 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 35 def payment_method @payment_method end |
#purchase_amount ⇒ Float
TODO: Write general description for this method
27 28 29 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 27 def purchase_amount @purchase_amount end |
#purchase_method ⇒ PurchaseMethod
TODO: Write general description for this method
23 24 25 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 23 def purchase_method @purchase_method end |
#valid_until ⇒ DateTime
TODO: Write general description for this method
43 44 45 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 43 def valid_until @valid_until end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 139 140 141 142 143 144 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 96 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. purchase_method = hash.key?('PurchaseMethod') ? hash['PurchaseMethod'] : nil purchase_amount = hash.key?('PurchaseAmount') ? hash['PurchaseAmount'] : 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 payment_method = OffersPaymentMethodResponse.from_hash(hash['PaymentMethod']) if hash['PaymentMethod'] # Parameter is an array, so we need to iterate through it offers = nil unless hash['Offers'].nil? offers = [] hash['Offers'].each do |structure| offers << (OfferItem.from_hash(structure) if structure) end end offers = SKIP unless hash.key?('Offers') valid_until = if hash.key?('ValidUntil') (DateTimeHelper.from_rfc3339(hash['ValidUntil']) if hash['ValidUntil']) 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. OffersResponse.new(purchase_method: purchase_method, purchase_amount: purchase_amount, installment_plan_number: installment_plan_number, merchant_order_reference: merchant_order_reference, currency: currency, payment_method: payment_method, offers: offers, valid_until: valid_until, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['installment_plan_number'] = 'InstallmentPlanNumber' @_hash['merchant_order_reference'] = 'MerchantOrderReference' @_hash['purchase_method'] = 'PurchaseMethod' @_hash['purchase_amount'] = 'PurchaseAmount' @_hash['currency'] = 'Currency' @_hash['payment_method'] = 'PaymentMethod' @_hash['offers'] = 'Offers' @_hash['valid_until'] = 'ValidUntil' @_hash end |
.nullables ⇒ Object
An array for nullable fields
72 73 74 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 72 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 60 def self.optionals %w[ installment_plan_number merchant_order_reference currency payment_method offers valid_until ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
161 162 163 164 165 166 167 168 169 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 161 def inspect class_name = self.class.name.split('::').last "<#{class_name} installment_plan_number: #{@installment_plan_number.inspect},"\ " merchant_order_reference: #{@merchant_order_reference.inspect}, purchase_method:"\ " #{@purchase_method.inspect}, purchase_amount: #{@purchase_amount.inspect}, currency:"\ " #{@currency.inspect}, payment_method: #{@payment_method.inspect}, offers:"\ " #{@offers.inspect}, valid_until: #{@valid_until.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_valid_until ⇒ Object
146 147 148 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 146 def to_custom_valid_until DateTimeHelper.to_rfc3339(valid_until) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
151 152 153 154 155 156 157 158 |
# File 'lib/splitit_web_api_v4/models/offers_response.rb', line 151 def to_s class_name = self.class.name.split('::').last "<#{class_name} installment_plan_number: #{@installment_plan_number},"\ " merchant_order_reference: #{@merchant_order_reference}, purchase_method:"\ " #{@purchase_method}, purchase_amount: #{@purchase_amount}, currency: #{@currency},"\ " payment_method: #{@payment_method}, offers: #{@offers}, valid_until: #{@valid_until},"\ " additional_properties: #{@additional_properties}>" end |