mastercard_masterpass_merchant 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +24 -0
- data/README.md +74 -0
- data/lib/mastercard_masterpass_merchant.rb +182 -0
- data/lib/mastercard_masterpass_merchant/api/checkout_api.rb +41 -0
- data/lib/mastercard_masterpass_merchant/api/decryption_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/api/express_checkout_api.rb +42 -0
- data/lib/mastercard_masterpass_merchant/api/merchant_initialization_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/api/postback_api.rb +39 -0
- data/lib/mastercard_masterpass_merchant/api/precheckout_data_api.rb +42 -0
- data/lib/mastercard_masterpass_merchant/api/session_key_signing_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/api/shopping_cart_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/models/acceptance_option.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/address.rb +243 -0
- data/lib/mastercard_masterpass_merchant/models/address_extension_point.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/authentication_options.rb +265 -0
- data/lib/mastercard_masterpass_merchant/models/base_card.rb +221 -0
- data/lib/mastercard_masterpass_merchant/models/brands.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/card.rb +244 -0
- data/lib/mastercard_masterpass_merchant/models/card_extension.rb +189 -0
- data/lib/mastercard_masterpass_merchant/models/card_type.rb +174 -0
- data/lib/mastercard_masterpass_merchant/models/card_types.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/checkout.rb +259 -0
- data/lib/mastercard_masterpass_merchant/models/checkout_dsrp.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/checkout_extension.rb +259 -0
- data/lib/mastercard_masterpass_merchant/models/contact.rb +275 -0
- data/lib/mastercard_masterpass_merchant/models/date_of_birth.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/decryption_request.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/decryption_response.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/detail.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/details.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/dsrp.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/dsrp_extension.rb +189 -0
- data/lib/mastercard_masterpass_merchant/models/dsrp_options.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/error.rb +222 -0
- data/lib/mastercard_masterpass_merchant/models/errors.rb +174 -0
- data/lib/mastercard_masterpass_merchant/models/express_checkout_request.rb +276 -0
- data/lib/mastercard_masterpass_merchant/models/express_checkout_response.rb +201 -0
- data/lib/mastercard_masterpass_merchant/models/extension_point.rb +163 -0
- data/lib/mastercard_masterpass_merchant/models/installment.rb +221 -0
- data/lib/mastercard_masterpass_merchant/models/installment_option.rb +198 -0
- data/lib/mastercard_masterpass_merchant/models/installment_options.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/installments.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/issuers.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_extension.rb +201 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_request.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_response.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_response_extension.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_transaction.rb +274 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_transactions.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/option.rb +197 -0
- data/lib/mastercard_masterpass_merchant/models/pairing_data_type.rb +186 -0
- data/lib/mastercard_masterpass_merchant/models/pairing_data_types.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/payment_acceptance.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/payment_acceptance_types_extension.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/payment_options_extensions.rb +178 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_card.rb +288 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_cards.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_data.rb +259 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_data_request.rb +178 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_data_response.rb +211 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_reward_program.rb +243 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_shipping_address.rb +298 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_shipping_addresses.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/private_data.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/private_datas.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/reward_program.rb +221 -0
- data/lib/mastercard_masterpass_merchant/models/reward_programs.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/risk_decisioning.rb +178 -0
- data/lib/mastercard_masterpass_merchant/models/session_key_signing_request.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/session_key_signing_response.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/shipping_address.rb +265 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_item.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_request.rb +189 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_request_extension_point.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_response.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/tokenization.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/types.rb +174 -0
- data/lib/mastercard_masterpass_merchant/models/wallet.rb +177 -0
- data/lib/mastercard_masterpass_merchant/tracker/sdk_api_tracker.rb +57 -0
- data/lib/mastercard_masterpass_merchant/version.rb +3 -0
- metadata +240 -0
@@ -0,0 +1,276 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
|
5
|
+
|
6
|
+
module MastercardMasterpassMerchant
|
7
|
+
# This class contains methods require for express checkout request.
|
8
|
+
class ExpressCheckoutRequest
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name "ExpressCheckoutRequest"
|
12
|
+
|
13
|
+
# @!attribute merchant_checkout_id
|
14
|
+
# @return [String] the merchant checkout id.
|
15
|
+
xml_accessor :merchant_checkout_id, :from =>"MerchantCheckoutId"
|
16
|
+
|
17
|
+
# @!attribute precheckout_transaction_id
|
18
|
+
# @return [String] the unique id of the transaction.
|
19
|
+
xml_accessor :precheckout_transaction_id, :from =>"PrecheckoutTransactionId"
|
20
|
+
|
21
|
+
# @!attribute currency_code
|
22
|
+
# @return [String] the currency code as ISO 4217 standard (for example, USD).
|
23
|
+
xml_accessor :currency_code, :from =>"CurrencyCode"
|
24
|
+
|
25
|
+
# @!attribute order_amount
|
26
|
+
# @return [Integer] the order amount of the transaction.
|
27
|
+
xml_accessor :order_amount, :from =>"OrderAmount"
|
28
|
+
|
29
|
+
# @!attribute card_id
|
30
|
+
# @return [String] the id assigned to the card.
|
31
|
+
xml_accessor :card_id, :from =>"CardId"
|
32
|
+
|
33
|
+
# @!attribute digital_goods
|
34
|
+
# @return [BOOLEAN] the digital goods flag. Set to true if it's a digital good and no shipping is required (for example, digital music, online games, and so on); optional.
|
35
|
+
xml_accessor :digital_goods, :from =>"DigitalGoods"
|
36
|
+
|
37
|
+
# @!attribute shipping_address_id
|
38
|
+
# @return [String] the id assigned to the shipping address.
|
39
|
+
xml_accessor :shipping_address_id, :from =>"ShippingAddressId"
|
40
|
+
|
41
|
+
# @!attribute reward_program_id
|
42
|
+
# @return [String] the id assigned to the reward program.
|
43
|
+
xml_accessor :reward_program_id, :from =>"RewardProgramId"
|
44
|
+
|
45
|
+
# @!attribute advanced_checkout_override
|
46
|
+
# @return [BOOLEAN] the advanced checkout override flag. Set to true to override and disable 3-D Secure for current transaction.
|
47
|
+
xml_accessor :advanced_checkout_override, :from =>"AdvancedCheckoutOverride"
|
48
|
+
|
49
|
+
# @!attribute origin_url
|
50
|
+
# @return [String] the URL that the merchant is using to initialize the Lightbox.
|
51
|
+
xml_accessor :origin_url, :from =>"OriginUrl"
|
52
|
+
|
53
|
+
# @!attribute extension_point
|
54
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
55
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
56
|
+
|
57
|
+
|
58
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
59
|
+
def self.attribute_map
|
60
|
+
{
|
61
|
+
:merchant_checkout_id => :MerchantCheckoutId ,
|
62
|
+
:precheckout_transaction_id => :PrecheckoutTransactionId ,
|
63
|
+
:currency_code => :CurrencyCode ,
|
64
|
+
:order_amount => :OrderAmount ,
|
65
|
+
:card_id => :CardId ,
|
66
|
+
:digital_goods => :DigitalGoods ,
|
67
|
+
:shipping_address_id => :ShippingAddressId ,
|
68
|
+
:reward_program_id => :RewardProgramId ,
|
69
|
+
:advanced_checkout_override => :AdvancedCheckoutOverride ,
|
70
|
+
:origin_url => :OriginUrl ,
|
71
|
+
:extension_point => :ExtensionPoint
|
72
|
+
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def initialize(attributes = {})
|
77
|
+
return unless attributes.is_a?(Hash)
|
78
|
+
|
79
|
+
# convert string to symbol for hash key
|
80
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
81
|
+
|
82
|
+
|
83
|
+
if attributes.has_key?(:MerchantCheckoutId) || attributes.has_key?(:merchant_checkout_id)
|
84
|
+
self.merchant_checkout_id = attributes[:MerchantCheckoutId] || attributes[:merchant_checkout_id]
|
85
|
+
end
|
86
|
+
|
87
|
+
if attributes.has_key?(:PrecheckoutTransactionId) || attributes.has_key?(:precheckout_transaction_id)
|
88
|
+
self.precheckout_transaction_id = attributes[:PrecheckoutTransactionId] || attributes[:precheckout_transaction_id]
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.has_key?(:CurrencyCode) || attributes.has_key?(:currency_code)
|
92
|
+
self.currency_code = attributes[:CurrencyCode] || attributes[:currency_code]
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.has_key?(:OrderAmount) || attributes.has_key?(:order_amount)
|
96
|
+
self.order_amount = attributes[:OrderAmount] || attributes[:order_amount]
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.has_key?(:CardId) || attributes.has_key?(:card_id)
|
100
|
+
self.card_id = attributes[:CardId] || attributes[:card_id]
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.has_key?(:DigitalGoods) || attributes.has_key?(:digital_goods)
|
104
|
+
self.digital_goods = attributes[:DigitalGoods] || attributes[:digital_goods]
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.has_key?(:ShippingAddressId) || attributes.has_key?(:shipping_address_id)
|
108
|
+
self.shipping_address_id = attributes[:ShippingAddressId] || attributes[:shipping_address_id]
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.has_key?(:RewardProgramId) || attributes.has_key?(:reward_program_id)
|
112
|
+
self.reward_program_id = attributes[:RewardProgramId] || attributes[:reward_program_id]
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.has_key?(:AdvancedCheckoutOverride) || attributes.has_key?(:advanced_checkout_override)
|
116
|
+
self.advanced_checkout_override = attributes[:AdvancedCheckoutOverride] || attributes[:advanced_checkout_override]
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.has_key?(:OriginUrl) || attributes.has_key?(:origin_url)
|
120
|
+
self.origin_url = attributes[:OriginUrl] || attributes[:origin_url]
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
124
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
# Check equality by comparing each attribute.
|
133
|
+
def ==(o)
|
134
|
+
return true if self.equal?(o)
|
135
|
+
self.class == o.class &&
|
136
|
+
merchant_checkout_id == o.merchant_checkout_id &&
|
137
|
+
precheckout_transaction_id == o.precheckout_transaction_id &&
|
138
|
+
currency_code == o.currency_code &&
|
139
|
+
order_amount == o.order_amount &&
|
140
|
+
card_id == o.card_id &&
|
141
|
+
digital_goods == o.digital_goods &&
|
142
|
+
shipping_address_id == o.shipping_address_id &&
|
143
|
+
reward_program_id == o.reward_program_id &&
|
144
|
+
advanced_checkout_override == o.advanced_checkout_override &&
|
145
|
+
origin_url == o.origin_url &&
|
146
|
+
extension_point == o.extension_point
|
147
|
+
end
|
148
|
+
|
149
|
+
# @see the `==` method
|
150
|
+
def eql?(o)
|
151
|
+
self == o
|
152
|
+
end
|
153
|
+
|
154
|
+
# Calculate hash code according to all attributes.
|
155
|
+
def hash
|
156
|
+
[merchant_checkout_id, precheckout_transaction_id, currency_code, order_amount, card_id, digital_goods, shipping_address_id, reward_program_id, advanced_checkout_override, origin_url, extension_point].hash
|
157
|
+
end
|
158
|
+
|
159
|
+
# build the object from hash
|
160
|
+
def build_from_hash(attributes)
|
161
|
+
return nil unless attributes.is_a?(Hash)
|
162
|
+
self.class.datatype_map.each_pair do |key, type|
|
163
|
+
if type =~ /^Array<(.*)>/i
|
164
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
165
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
166
|
+
else
|
167
|
+
#TODO show warning in debug mode
|
168
|
+
end
|
169
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
170
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
171
|
+
else
|
172
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
self
|
177
|
+
end
|
178
|
+
|
179
|
+
def _deserialize(type, value)
|
180
|
+
case type.to_sym
|
181
|
+
when :DateTime
|
182
|
+
DateTime.parse(value)
|
183
|
+
when :Date
|
184
|
+
Date.parse(value)
|
185
|
+
when :String
|
186
|
+
value.to_s
|
187
|
+
when :Integer
|
188
|
+
value.to_i
|
189
|
+
when :Float
|
190
|
+
value.to_f
|
191
|
+
when :BOOLEAN
|
192
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
193
|
+
true
|
194
|
+
else
|
195
|
+
false
|
196
|
+
end
|
197
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
198
|
+
inner_type = Regexp.last_match[:inner_type]
|
199
|
+
value.map { |v| _deserialize(inner_type, v) }
|
200
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
201
|
+
k_type = Regexp.last_match[:k_type]
|
202
|
+
v_type = Regexp.last_match[:v_type]
|
203
|
+
{}.tap do |hash|
|
204
|
+
value.each do |k, v|
|
205
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
else # model
|
209
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
210
|
+
_model.build_from_hash(value)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def to_s
|
215
|
+
to_hash.to_s
|
216
|
+
end
|
217
|
+
|
218
|
+
# to_body is an alias to to_body (backward compatibility))
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# return the object in the form of hash
|
224
|
+
def to_hash
|
225
|
+
hash = {}
|
226
|
+
self.class.attribute_map.each_pair do |attr, param|
|
227
|
+
value = self.send(attr)
|
228
|
+
next if value.nil?
|
229
|
+
hash[param] = _to_hash(value)
|
230
|
+
end
|
231
|
+
hash
|
232
|
+
end
|
233
|
+
|
234
|
+
# Method to output non-array value in the form of hash
|
235
|
+
# For object, use to_hash. Otherwise, just return the value
|
236
|
+
def _to_hash(value)
|
237
|
+
if value.is_a?(Array)
|
238
|
+
value.compact.map{ |v| _to_hash(v) }
|
239
|
+
elsif value.is_a?(Hash)
|
240
|
+
{}.tap do |hash|
|
241
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
242
|
+
end
|
243
|
+
elsif value.respond_to? :to_hash
|
244
|
+
value.to_hash
|
245
|
+
else
|
246
|
+
value
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
|
251
|
+
private
|
252
|
+
def after_parse
|
253
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
254
|
+
end
|
255
|
+
|
256
|
+
# Attribute datatype mapping.
|
257
|
+
def self.datatype_map
|
258
|
+
{
|
259
|
+
:merchant_checkout_id => 'String',
|
260
|
+
:precheckout_transaction_id => 'String',
|
261
|
+
:currency_code => 'String',
|
262
|
+
:order_amount => 'Integer',
|
263
|
+
:card_id => 'String',
|
264
|
+
:digital_goods => 'BOOLEAN',
|
265
|
+
:shipping_address_id => 'String',
|
266
|
+
:reward_program_id => 'String',
|
267
|
+
:advanced_checkout_override => 'BOOLEAN',
|
268
|
+
:origin_url => 'String',
|
269
|
+
:extension_point => 'ExtensionPoint'
|
270
|
+
|
271
|
+
}
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
|
276
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/checkout'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/errors'
|
5
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
6
|
+
|
7
|
+
|
8
|
+
module MastercardMasterpassMerchant
|
9
|
+
# This class contains methods require for express checkout response.
|
10
|
+
class ExpressCheckoutResponse
|
11
|
+
include ROXML
|
12
|
+
|
13
|
+
xml_name "ExpressCheckoutResponse"
|
14
|
+
|
15
|
+
# @!attribute checkout
|
16
|
+
# @return [Checkout] the checkout details.
|
17
|
+
xml_accessor :checkout, :from =>"Checkout",:as => Checkout
|
18
|
+
|
19
|
+
# @!attribute long_access_token
|
20
|
+
# @return [String] the long access token.
|
21
|
+
xml_accessor :long_access_token, :from =>"LongAccessToken"
|
22
|
+
|
23
|
+
# @!attribute errors
|
24
|
+
# @return [Errors] the errors information.
|
25
|
+
xml_accessor :errors, :from =>"Errors",:as => Errors
|
26
|
+
|
27
|
+
# @!attribute extension_point
|
28
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
29
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
30
|
+
|
31
|
+
|
32
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
33
|
+
def self.attribute_map
|
34
|
+
{
|
35
|
+
:checkout => :Checkout ,
|
36
|
+
:long_access_token => :LongAccessToken ,
|
37
|
+
:errors => :Errors ,
|
38
|
+
:extension_point => :ExtensionPoint
|
39
|
+
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(attributes = {})
|
44
|
+
return unless attributes.is_a?(Hash)
|
45
|
+
|
46
|
+
# convert string to symbol for hash key
|
47
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
48
|
+
|
49
|
+
|
50
|
+
if attributes.has_key?(:Checkout) || attributes.has_key?(:checkout)
|
51
|
+
self.checkout = attributes[:Checkout] || attributes[:checkout]
|
52
|
+
end
|
53
|
+
|
54
|
+
if attributes.has_key?(:LongAccessToken) || attributes.has_key?(:long_access_token)
|
55
|
+
self.long_access_token = attributes[:LongAccessToken] || attributes[:long_access_token]
|
56
|
+
end
|
57
|
+
|
58
|
+
if attributes.has_key?(:Errors) || attributes.has_key?(:errors)
|
59
|
+
self.errors = attributes[:Errors] || attributes[:errors]
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
63
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
# Check equality by comparing each attribute.
|
72
|
+
def ==(o)
|
73
|
+
return true if self.equal?(o)
|
74
|
+
self.class == o.class &&
|
75
|
+
checkout == o.checkout &&
|
76
|
+
long_access_token == o.long_access_token &&
|
77
|
+
errors == o.errors &&
|
78
|
+
extension_point == o.extension_point
|
79
|
+
end
|
80
|
+
|
81
|
+
# @see the `==` method
|
82
|
+
def eql?(o)
|
83
|
+
self == o
|
84
|
+
end
|
85
|
+
|
86
|
+
# Calculate hash code according to all attributes.
|
87
|
+
def hash
|
88
|
+
[checkout, long_access_token, errors, extension_point].hash
|
89
|
+
end
|
90
|
+
|
91
|
+
# build the object from hash
|
92
|
+
def build_from_hash(attributes)
|
93
|
+
return nil unless attributes.is_a?(Hash)
|
94
|
+
self.class.datatype_map.each_pair do |key, type|
|
95
|
+
if type =~ /^Array<(.*)>/i
|
96
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
97
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
98
|
+
else
|
99
|
+
#TODO show warning in debug mode
|
100
|
+
end
|
101
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
102
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
103
|
+
else
|
104
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
def _deserialize(type, value)
|
112
|
+
case type.to_sym
|
113
|
+
when :DateTime
|
114
|
+
DateTime.parse(value)
|
115
|
+
when :Date
|
116
|
+
Date.parse(value)
|
117
|
+
when :String
|
118
|
+
value.to_s
|
119
|
+
when :Integer
|
120
|
+
value.to_i
|
121
|
+
when :Float
|
122
|
+
value.to_f
|
123
|
+
when :BOOLEAN
|
124
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
125
|
+
true
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
130
|
+
inner_type = Regexp.last_match[:inner_type]
|
131
|
+
value.map { |v| _deserialize(inner_type, v) }
|
132
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
133
|
+
k_type = Regexp.last_match[:k_type]
|
134
|
+
v_type = Regexp.last_match[:v_type]
|
135
|
+
{}.tap do |hash|
|
136
|
+
value.each do |k, v|
|
137
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
else # model
|
141
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
142
|
+
_model.build_from_hash(value)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def to_s
|
147
|
+
to_hash.to_s
|
148
|
+
end
|
149
|
+
|
150
|
+
# to_body is an alias to to_body (backward compatibility))
|
151
|
+
def to_body
|
152
|
+
to_hash
|
153
|
+
end
|
154
|
+
|
155
|
+
# return the object in the form of hash
|
156
|
+
def to_hash
|
157
|
+
hash = {}
|
158
|
+
self.class.attribute_map.each_pair do |attr, param|
|
159
|
+
value = self.send(attr)
|
160
|
+
next if value.nil?
|
161
|
+
hash[param] = _to_hash(value)
|
162
|
+
end
|
163
|
+
hash
|
164
|
+
end
|
165
|
+
|
166
|
+
# Method to output non-array value in the form of hash
|
167
|
+
# For object, use to_hash. Otherwise, just return the value
|
168
|
+
def _to_hash(value)
|
169
|
+
if value.is_a?(Array)
|
170
|
+
value.compact.map{ |v| _to_hash(v) }
|
171
|
+
elsif value.is_a?(Hash)
|
172
|
+
{}.tap do |hash|
|
173
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
174
|
+
end
|
175
|
+
elsif value.respond_to? :to_hash
|
176
|
+
value.to_hash
|
177
|
+
else
|
178
|
+
value
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
private
|
184
|
+
def after_parse
|
185
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
186
|
+
end
|
187
|
+
|
188
|
+
# Attribute datatype mapping.
|
189
|
+
def self.datatype_map
|
190
|
+
{
|
191
|
+
:checkout => 'Checkout',
|
192
|
+
:long_access_token => 'String',
|
193
|
+
:errors => 'Errors',
|
194
|
+
:extension_point => 'ExtensionPoint'
|
195
|
+
|
196
|
+
}
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
end
|