Class: SplititWebApiV4::PaymentLinkRequest

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

Overview

PaymentLinkRequest 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(amount:, currency:, purchase_method:, shopper_details:, merchant_order_reference: SKIP, merchant_details: SKIP, checkout_url_validity: SKIP, metadata: SKIP, redirect_urls: SKIP, processing_data: SKIP, three_ds: SKIP, additional_properties: nil) ⇒ PaymentLinkRequest

Returns a new instance of PaymentLinkRequest.



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

def initialize(amount:, currency:, purchase_method:, shopper_details:,
               merchant_order_reference: SKIP, merchant_details: SKIP,
               checkout_url_validity: SKIP, metadata: SKIP,
               redirect_urls: SKIP, processing_data: SKIP, three_ds: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount = amount
  @currency = currency
  @merchant_order_reference = merchant_order_reference unless merchant_order_reference == SKIP
  @purchase_method = purchase_method
  @shopper_details = shopper_details
  @merchant_details = merchant_details unless merchant_details == SKIP
  @checkout_url_validity = checkout_url_validity unless checkout_url_validity == SKIP
  @metadata =  unless  == SKIP
  @redirect_urls = redirect_urls unless redirect_urls == SKIP
  @processing_data = processing_data unless processing_data == SKIP
  @three_ds = three_ds unless three_ds == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def amount
  @amount
end

#checkout_url_validityDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def checkout_url_validity
  @checkout_url_validity
end

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


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

def currency
  @currency
end

#merchant_detailsOffersMerchantDetails

TODO: Write general description for this method



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

def merchant_details
  @merchant_details
end

#merchant_order_referenceString

TODO: Write general description for this method

Returns:

  • (String)


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

def merchant_order_reference
  @merchant_order_reference
end

#metadataArray[MetadataItem]

TODO: Write general description for this method

Returns:



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

def 
  @metadata
end

#processing_dataProcessingData

TODO: Write general description for this method

Returns:



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

def processing_data
  @processing_data
end

#purchase_methodPurchaseMethod

TODO: Write general description for this method

Returns:



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

def purchase_method
  @purchase_method
end

#redirect_urlsRedirectUrls

TODO: Write general description for this method

Returns:



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

def redirect_urls
  @redirect_urls
end

#shopper_detailsOffersShopperDetails

TODO: Write general description for this method



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

def shopper_details
  @shopper_details
end

#three_dsThreeDsExecute

TODO: Write general description for this method

Returns:



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

def three_ds
  @three_ds
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/splitit_web_api_v4/models/payment_link_request.rb', line 115

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('Amount') ? hash['Amount'] : nil
  currency = hash.key?('Currency') ? hash['Currency'] : nil
  purchase_method =
    hash.key?('PurchaseMethod') ? hash['PurchaseMethod'] : nil
  shopper_details = OffersShopperDetails.from_hash(hash['ShopperDetails']) if
    hash['ShopperDetails']
  merchant_order_reference =
    hash.key?('MerchantOrderReference') ? hash['MerchantOrderReference'] : SKIP
  merchant_details = OffersMerchantDetails.from_hash(hash['MerchantDetails']) if
    hash['MerchantDetails']
  checkout_url_validity = if hash.key?('CheckoutUrlValidity')
                            (DateTimeHelper.from_rfc3339(hash['CheckoutUrlValidity']) if hash['CheckoutUrlValidity'])
                          else
                            SKIP
                          end
  # 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')
  redirect_urls = RedirectUrls.from_hash(hash['RedirectUrls']) if hash['RedirectUrls']
  processing_data = ProcessingData.from_hash(hash['ProcessingData']) if hash['ProcessingData']
  three_ds = ThreeDsExecute.from_hash(hash['ThreeDS']) if hash['ThreeDS']

  # 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.
  PaymentLinkRequest.new(amount: amount,
                         currency: currency,
                         purchase_method: purchase_method,
                         shopper_details: shopper_details,
                         merchant_order_reference: merchant_order_reference,
                         merchant_details: merchant_details,
                         checkout_url_validity: checkout_url_validity,
                         metadata: ,
                         redirect_urls: redirect_urls,
                         processing_data: processing_data,
                         three_ds: three_ds,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'Amount'
  @_hash['currency'] = 'Currency'
  @_hash['merchant_order_reference'] = 'MerchantOrderReference'
  @_hash['purchase_method'] = 'PurchaseMethod'
  @_hash['shopper_details'] = 'ShopperDetails'
  @_hash['merchant_details'] = 'MerchantDetails'
  @_hash['checkout_url_validity'] = 'CheckoutUrlValidity'
  @_hash['metadata'] = 'Metadata'
  @_hash['redirect_urls'] = 'RedirectUrls'
  @_hash['processing_data'] = 'ProcessingData'
  @_hash['three_ds'] = 'ThreeDS'
  @_hash
end

.nullablesObject

An array for nullable fields



88
89
90
# File 'lib/splitit_web_api_v4/models/payment_link_request.rb', line 88

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    merchant_order_reference
    merchant_details
    checkout_url_validity
    metadata
    redirect_urls
    processing_data
    three_ds
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



186
187
188
189
190
191
192
193
194
195
# File 'lib/splitit_web_api_v4/models/payment_link_request.rb', line 186

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, currency: #{@currency.inspect},"\
  " merchant_order_reference: #{@merchant_order_reference.inspect}, purchase_method:"\
  " #{@purchase_method.inspect}, shopper_details: #{@shopper_details.inspect},"\
  " merchant_details: #{@merchant_details.inspect}, checkout_url_validity:"\
  " #{@checkout_url_validity.inspect}, metadata: #{@metadata.inspect}, redirect_urls:"\
  " #{@redirect_urls.inspect}, processing_data: #{@processing_data.inspect}, three_ds:"\
  " #{@three_ds.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_checkout_url_validityObject



170
171
172
# File 'lib/splitit_web_api_v4/models/payment_link_request.rb', line 170

def to_custom_checkout_url_validity
  DateTimeHelper.to_rfc3339(checkout_url_validity)
end

#to_sObject

Provides a human-readable string representation of the object.



175
176
177
178
179
180
181
182
183
# File 'lib/splitit_web_api_v4/models/payment_link_request.rb', line 175

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, currency: #{@currency}, merchant_order_reference:"\
  " #{@merchant_order_reference}, purchase_method: #{@purchase_method}, shopper_details:"\
  " #{@shopper_details}, merchant_details: #{@merchant_details}, checkout_url_validity:"\
  " #{@checkout_url_validity}, metadata: #{@metadata}, redirect_urls: #{@redirect_urls},"\
  " processing_data: #{@processing_data}, three_ds: #{@three_ds}, additional_properties:"\
  " #{@additional_properties}>"
end