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,259 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/contact'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/errors'
|
5
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
6
|
+
require_relative '../../mastercard_masterpass_merchant/models/precheckout_cards'
|
7
|
+
require_relative '../../mastercard_masterpass_merchant/models/precheckout_shipping_addresses'
|
8
|
+
require_relative '../../mastercard_masterpass_merchant/models/reward_programs'
|
9
|
+
|
10
|
+
|
11
|
+
module MastercardMasterpassMerchant
|
12
|
+
# This class contains different methods for different types of precheckout data like card, contact, shipping address and reward program details.
|
13
|
+
class PrecheckoutData
|
14
|
+
include ROXML
|
15
|
+
|
16
|
+
xml_name "PrecheckoutData"
|
17
|
+
|
18
|
+
# @!attribute cards
|
19
|
+
# @return [PrecheckoutCards] the cards.
|
20
|
+
xml_accessor :cards, :from =>"Cards",:as => PrecheckoutCards
|
21
|
+
|
22
|
+
# @!attribute contact
|
23
|
+
# @return [Contact] the contact details.
|
24
|
+
xml_accessor :contact, :from =>"Contact",:as => Contact
|
25
|
+
|
26
|
+
# @!attribute shipping_addresses
|
27
|
+
# @return [PrecheckoutShippingAddresses] the shipping address details.
|
28
|
+
xml_accessor :shipping_addresses, :from =>"ShippingAddresses",:as => PrecheckoutShippingAddresses
|
29
|
+
|
30
|
+
# @!attribute reward_programs
|
31
|
+
# @return [RewardPrograms] the reward program details.
|
32
|
+
xml_accessor :reward_programs, :from =>"RewardPrograms",:as => RewardPrograms
|
33
|
+
|
34
|
+
# @!attribute wallet_name
|
35
|
+
# @return [String] the wallet name.
|
36
|
+
xml_accessor :wallet_name, :from =>"WalletName"
|
37
|
+
|
38
|
+
# @!attribute precheckout_transaction_id
|
39
|
+
# @return [String] the precheckout transaction id.
|
40
|
+
xml_accessor :precheckout_transaction_id, :from =>"PrecheckoutTransactionId"
|
41
|
+
|
42
|
+
# @!attribute consumer_wallet_id
|
43
|
+
# @return [String] the consumer wallet id.
|
44
|
+
xml_accessor :consumer_wallet_id, :from =>"ConsumerWalletId"
|
45
|
+
|
46
|
+
# @!attribute errors
|
47
|
+
# @return [Errors] the errors information.
|
48
|
+
xml_accessor :errors, :from =>"Errors",:as => Errors
|
49
|
+
|
50
|
+
# @!attribute extension_point
|
51
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
52
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
53
|
+
|
54
|
+
|
55
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
56
|
+
def self.attribute_map
|
57
|
+
{
|
58
|
+
:cards => :Cards ,
|
59
|
+
:contact => :Contact ,
|
60
|
+
:shipping_addresses => :ShippingAddresses ,
|
61
|
+
:reward_programs => :RewardPrograms ,
|
62
|
+
:wallet_name => :WalletName ,
|
63
|
+
:precheckout_transaction_id => :PrecheckoutTransactionId ,
|
64
|
+
:consumer_wallet_id => :ConsumerWalletId ,
|
65
|
+
:errors => :Errors ,
|
66
|
+
:extension_point => :ExtensionPoint
|
67
|
+
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def initialize(attributes = {})
|
72
|
+
return unless attributes.is_a?(Hash)
|
73
|
+
|
74
|
+
# convert string to symbol for hash key
|
75
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
76
|
+
|
77
|
+
|
78
|
+
if attributes.has_key?(:Cards) || attributes.has_key?(:cards)
|
79
|
+
self.cards = attributes[:Cards] || attributes[:cards]
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.has_key?(:Contact) || attributes.has_key?(:contact)
|
83
|
+
self.contact = attributes[:Contact] || attributes[:contact]
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.has_key?(:ShippingAddresses) || attributes.has_key?(:shipping_addresses)
|
87
|
+
self.shipping_addresses = attributes[:ShippingAddresses] || attributes[:shipping_addresses]
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.has_key?(:RewardPrograms) || attributes.has_key?(:reward_programs)
|
91
|
+
self.reward_programs = attributes[:RewardPrograms] || attributes[:reward_programs]
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.has_key?(:WalletName) || attributes.has_key?(:wallet_name)
|
95
|
+
self.wallet_name = attributes[:WalletName] || attributes[:wallet_name]
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.has_key?(:PrecheckoutTransactionId) || attributes.has_key?(:precheckout_transaction_id)
|
99
|
+
self.precheckout_transaction_id = attributes[:PrecheckoutTransactionId] || attributes[:precheckout_transaction_id]
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.has_key?(:ConsumerWalletId) || attributes.has_key?(:consumer_wallet_id)
|
103
|
+
self.consumer_wallet_id = attributes[:ConsumerWalletId] || attributes[:consumer_wallet_id]
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.has_key?(:Errors) || attributes.has_key?(:errors)
|
107
|
+
self.errors = attributes[:Errors] || attributes[:errors]
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
111
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
# Check equality by comparing each attribute.
|
120
|
+
def ==(o)
|
121
|
+
return true if self.equal?(o)
|
122
|
+
self.class == o.class &&
|
123
|
+
cards == o.cards &&
|
124
|
+
contact == o.contact &&
|
125
|
+
shipping_addresses == o.shipping_addresses &&
|
126
|
+
reward_programs == o.reward_programs &&
|
127
|
+
wallet_name == o.wallet_name &&
|
128
|
+
precheckout_transaction_id == o.precheckout_transaction_id &&
|
129
|
+
consumer_wallet_id == o.consumer_wallet_id &&
|
130
|
+
errors == o.errors &&
|
131
|
+
extension_point == o.extension_point
|
132
|
+
end
|
133
|
+
|
134
|
+
# @see the `==` method
|
135
|
+
def eql?(o)
|
136
|
+
self == o
|
137
|
+
end
|
138
|
+
|
139
|
+
# Calculate hash code according to all attributes.
|
140
|
+
def hash
|
141
|
+
[cards, contact, shipping_addresses, reward_programs, wallet_name, precheckout_transaction_id, consumer_wallet_id, errors, extension_point].hash
|
142
|
+
end
|
143
|
+
|
144
|
+
# build the object from hash
|
145
|
+
def build_from_hash(attributes)
|
146
|
+
return nil unless attributes.is_a?(Hash)
|
147
|
+
self.class.datatype_map.each_pair do |key, type|
|
148
|
+
if type =~ /^Array<(.*)>/i
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
151
|
+
else
|
152
|
+
#TODO show warning in debug mode
|
153
|
+
end
|
154
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
155
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
156
|
+
else
|
157
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
self
|
162
|
+
end
|
163
|
+
|
164
|
+
def _deserialize(type, value)
|
165
|
+
case type.to_sym
|
166
|
+
when :DateTime
|
167
|
+
DateTime.parse(value)
|
168
|
+
when :Date
|
169
|
+
Date.parse(value)
|
170
|
+
when :String
|
171
|
+
value.to_s
|
172
|
+
when :Integer
|
173
|
+
value.to_i
|
174
|
+
when :Float
|
175
|
+
value.to_f
|
176
|
+
when :BOOLEAN
|
177
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
178
|
+
true
|
179
|
+
else
|
180
|
+
false
|
181
|
+
end
|
182
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
183
|
+
inner_type = Regexp.last_match[:inner_type]
|
184
|
+
value.map { |v| _deserialize(inner_type, v) }
|
185
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
186
|
+
k_type = Regexp.last_match[:k_type]
|
187
|
+
v_type = Regexp.last_match[:v_type]
|
188
|
+
{}.tap do |hash|
|
189
|
+
value.each do |k, v|
|
190
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
else # model
|
194
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
195
|
+
_model.build_from_hash(value)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def to_s
|
200
|
+
to_hash.to_s
|
201
|
+
end
|
202
|
+
|
203
|
+
# to_body is an alias to to_body (backward compatibility))
|
204
|
+
def to_body
|
205
|
+
to_hash
|
206
|
+
end
|
207
|
+
|
208
|
+
# return the object in the form of hash
|
209
|
+
def to_hash
|
210
|
+
hash = {}
|
211
|
+
self.class.attribute_map.each_pair do |attr, param|
|
212
|
+
value = self.send(attr)
|
213
|
+
next if value.nil?
|
214
|
+
hash[param] = _to_hash(value)
|
215
|
+
end
|
216
|
+
hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Method to output non-array value in the form of hash
|
220
|
+
# For object, use to_hash. Otherwise, just return the value
|
221
|
+
def _to_hash(value)
|
222
|
+
if value.is_a?(Array)
|
223
|
+
value.compact.map{ |v| _to_hash(v) }
|
224
|
+
elsif value.is_a?(Hash)
|
225
|
+
{}.tap do |hash|
|
226
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
227
|
+
end
|
228
|
+
elsif value.respond_to? :to_hash
|
229
|
+
value.to_hash
|
230
|
+
else
|
231
|
+
value
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
private
|
237
|
+
def after_parse
|
238
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
239
|
+
end
|
240
|
+
|
241
|
+
# Attribute datatype mapping.
|
242
|
+
def self.datatype_map
|
243
|
+
{
|
244
|
+
:cards => 'PrecheckoutCards',
|
245
|
+
:contact => 'Contact',
|
246
|
+
:shipping_addresses => 'PrecheckoutShippingAddresses',
|
247
|
+
:reward_programs => 'RewardPrograms',
|
248
|
+
:wallet_name => 'String',
|
249
|
+
:precheckout_transaction_id => 'String',
|
250
|
+
:consumer_wallet_id => 'String',
|
251
|
+
:errors => 'Errors',
|
252
|
+
:extension_point => 'ExtensionPoint'
|
253
|
+
|
254
|
+
}
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
|
259
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/pairing_data_types'
|
5
|
+
|
6
|
+
|
7
|
+
module MastercardMasterpassMerchant
|
8
|
+
# This class contains methods to set different parameters required to get the details of pairing details during precheckout.
|
9
|
+
class PrecheckoutDataRequest
|
10
|
+
include ROXML
|
11
|
+
|
12
|
+
xml_name "PrecheckoutDataRequest"
|
13
|
+
|
14
|
+
# @!attribute pairing_data_types
|
15
|
+
# @return [PairingDataTypes] the paring data types.
|
16
|
+
xml_accessor :pairing_data_types, :from =>"PairingDataTypes",:as => PairingDataTypes
|
17
|
+
|
18
|
+
# @!attribute extension_point
|
19
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
20
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
21
|
+
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:pairing_data_types => :PairingDataTypes ,
|
27
|
+
:extension_point => :ExtensionPoint
|
28
|
+
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(attributes = {})
|
33
|
+
return unless attributes.is_a?(Hash)
|
34
|
+
|
35
|
+
# convert string to symbol for hash key
|
36
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
37
|
+
|
38
|
+
|
39
|
+
if attributes.has_key?(:PairingDataTypes) || attributes.has_key?(:pairing_data_types)
|
40
|
+
self.pairing_data_types = attributes[:PairingDataTypes] || attributes[:pairing_data_types]
|
41
|
+
end
|
42
|
+
|
43
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
44
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
# Check equality by comparing each attribute.
|
53
|
+
def ==(o)
|
54
|
+
return true if self.equal?(o)
|
55
|
+
self.class == o.class &&
|
56
|
+
pairing_data_types == o.pairing_data_types &&
|
57
|
+
extension_point == o.extension_point
|
58
|
+
end
|
59
|
+
|
60
|
+
# @see the `==` method
|
61
|
+
def eql?(o)
|
62
|
+
self == o
|
63
|
+
end
|
64
|
+
|
65
|
+
# Calculate hash code according to all attributes.
|
66
|
+
def hash
|
67
|
+
[pairing_data_types, extension_point].hash
|
68
|
+
end
|
69
|
+
|
70
|
+
# build the object from hash
|
71
|
+
def build_from_hash(attributes)
|
72
|
+
return nil unless attributes.is_a?(Hash)
|
73
|
+
self.class.datatype_map.each_pair do |key, type|
|
74
|
+
if type =~ /^Array<(.*)>/i
|
75
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
76
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
77
|
+
else
|
78
|
+
#TODO show warning in debug mode
|
79
|
+
end
|
80
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
81
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
82
|
+
else
|
83
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
def _deserialize(type, value)
|
91
|
+
case type.to_sym
|
92
|
+
when :DateTime
|
93
|
+
DateTime.parse(value)
|
94
|
+
when :Date
|
95
|
+
Date.parse(value)
|
96
|
+
when :String
|
97
|
+
value.to_s
|
98
|
+
when :Integer
|
99
|
+
value.to_i
|
100
|
+
when :Float
|
101
|
+
value.to_f
|
102
|
+
when :BOOLEAN
|
103
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
104
|
+
true
|
105
|
+
else
|
106
|
+
false
|
107
|
+
end
|
108
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
109
|
+
inner_type = Regexp.last_match[:inner_type]
|
110
|
+
value.map { |v| _deserialize(inner_type, v) }
|
111
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
112
|
+
k_type = Regexp.last_match[:k_type]
|
113
|
+
v_type = Regexp.last_match[:v_type]
|
114
|
+
{}.tap do |hash|
|
115
|
+
value.each do |k, v|
|
116
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
else # model
|
120
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
121
|
+
_model.build_from_hash(value)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def to_s
|
126
|
+
to_hash.to_s
|
127
|
+
end
|
128
|
+
|
129
|
+
# to_body is an alias to to_body (backward compatibility))
|
130
|
+
def to_body
|
131
|
+
to_hash
|
132
|
+
end
|
133
|
+
|
134
|
+
# return the object in the form of hash
|
135
|
+
def to_hash
|
136
|
+
hash = {}
|
137
|
+
self.class.attribute_map.each_pair do |attr, param|
|
138
|
+
value = self.send(attr)
|
139
|
+
next if value.nil?
|
140
|
+
hash[param] = _to_hash(value)
|
141
|
+
end
|
142
|
+
hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Method to output non-array value in the form of hash
|
146
|
+
# For object, use to_hash. Otherwise, just return the value
|
147
|
+
def _to_hash(value)
|
148
|
+
if value.is_a?(Array)
|
149
|
+
value.compact.map{ |v| _to_hash(v) }
|
150
|
+
elsif value.is_a?(Hash)
|
151
|
+
{}.tap do |hash|
|
152
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
153
|
+
end
|
154
|
+
elsif value.respond_to? :to_hash
|
155
|
+
value.to_hash
|
156
|
+
else
|
157
|
+
value
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
private
|
163
|
+
def after_parse
|
164
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
165
|
+
end
|
166
|
+
|
167
|
+
# Attribute datatype mapping.
|
168
|
+
def self.datatype_map
|
169
|
+
{
|
170
|
+
:pairing_data_types => 'PairingDataTypes',
|
171
|
+
:extension_point => 'ExtensionPoint'
|
172
|
+
|
173
|
+
}
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/precheckout_data'
|
5
|
+
|
6
|
+
|
7
|
+
module MastercardMasterpassMerchant
|
8
|
+
# This class returns the precheckout data.
|
9
|
+
class PrecheckoutDataResponse
|
10
|
+
include ROXML
|
11
|
+
|
12
|
+
xml_name "PrecheckoutDataResponse"
|
13
|
+
|
14
|
+
# @!attribute precheckout_data
|
15
|
+
# @return [PrecheckoutData] the precheckout data details.
|
16
|
+
xml_accessor :precheckout_data, :from =>"PrecheckoutData",:as => PrecheckoutData
|
17
|
+
|
18
|
+
# @!attribute wallet_partner_logo_url
|
19
|
+
# @return [String] the wallet partner logo url.
|
20
|
+
xml_accessor :wallet_partner_logo_url, :from =>"WalletPartnerLogoUrl"
|
21
|
+
|
22
|
+
# @!attribute masterpass_logo_url
|
23
|
+
# @return [String] the MasterPass logo url.
|
24
|
+
xml_accessor :masterpass_logo_url, :from =>"MasterpassLogoUrl"
|
25
|
+
|
26
|
+
# @!attribute long_access_token
|
27
|
+
# @return [String] the long access token.
|
28
|
+
xml_accessor :long_access_token, :from =>"LongAccessToken"
|
29
|
+
|
30
|
+
# @!attribute extension_point
|
31
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
32
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
33
|
+
|
34
|
+
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
36
|
+
def self.attribute_map
|
37
|
+
{
|
38
|
+
:precheckout_data => :PrecheckoutData ,
|
39
|
+
:wallet_partner_logo_url => :WalletPartnerLogoUrl ,
|
40
|
+
:masterpass_logo_url => :MasterpassLogoUrl ,
|
41
|
+
:long_access_token => :LongAccessToken ,
|
42
|
+
:extension_point => :ExtensionPoint
|
43
|
+
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(attributes = {})
|
48
|
+
return unless attributes.is_a?(Hash)
|
49
|
+
|
50
|
+
# convert string to symbol for hash key
|
51
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
52
|
+
|
53
|
+
|
54
|
+
if attributes.has_key?(:PrecheckoutData) || attributes.has_key?(:precheckout_data)
|
55
|
+
self.precheckout_data = attributes[:PrecheckoutData] || attributes[:precheckout_data]
|
56
|
+
end
|
57
|
+
|
58
|
+
if attributes.has_key?(:WalletPartnerLogoUrl) || attributes.has_key?(:wallet_partner_logo_url)
|
59
|
+
self.wallet_partner_logo_url = attributes[:WalletPartnerLogoUrl] || attributes[:wallet_partner_logo_url]
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:MasterpassLogoUrl) || attributes.has_key?(:masterpass_logo_url)
|
63
|
+
self.masterpass_logo_url = attributes[:MasterpassLogoUrl] || attributes[:masterpass_logo_url]
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:LongAccessToken) || attributes.has_key?(:long_access_token)
|
67
|
+
self.long_access_token = attributes[:LongAccessToken] || attributes[:long_access_token]
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
71
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
# Check equality by comparing each attribute.
|
80
|
+
def ==(o)
|
81
|
+
return true if self.equal?(o)
|
82
|
+
self.class == o.class &&
|
83
|
+
precheckout_data == o.precheckout_data &&
|
84
|
+
wallet_partner_logo_url == o.wallet_partner_logo_url &&
|
85
|
+
masterpass_logo_url == o.masterpass_logo_url &&
|
86
|
+
long_access_token == o.long_access_token &&
|
87
|
+
extension_point == o.extension_point
|
88
|
+
end
|
89
|
+
|
90
|
+
# @see the `==` method
|
91
|
+
def eql?(o)
|
92
|
+
self == o
|
93
|
+
end
|
94
|
+
|
95
|
+
# Calculate hash code according to all attributes.
|
96
|
+
def hash
|
97
|
+
[precheckout_data, wallet_partner_logo_url, masterpass_logo_url, long_access_token, extension_point].hash
|
98
|
+
end
|
99
|
+
|
100
|
+
# build the object from hash
|
101
|
+
def build_from_hash(attributes)
|
102
|
+
return nil unless attributes.is_a?(Hash)
|
103
|
+
self.class.datatype_map.each_pair do |key, type|
|
104
|
+
if type =~ /^Array<(.*)>/i
|
105
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
106
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
107
|
+
else
|
108
|
+
#TODO show warning in debug mode
|
109
|
+
end
|
110
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
111
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
112
|
+
else
|
113
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
def _deserialize(type, value)
|
121
|
+
case type.to_sym
|
122
|
+
when :DateTime
|
123
|
+
DateTime.parse(value)
|
124
|
+
when :Date
|
125
|
+
Date.parse(value)
|
126
|
+
when :String
|
127
|
+
value.to_s
|
128
|
+
when :Integer
|
129
|
+
value.to_i
|
130
|
+
when :Float
|
131
|
+
value.to_f
|
132
|
+
when :BOOLEAN
|
133
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
134
|
+
true
|
135
|
+
else
|
136
|
+
false
|
137
|
+
end
|
138
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
139
|
+
inner_type = Regexp.last_match[:inner_type]
|
140
|
+
value.map { |v| _deserialize(inner_type, v) }
|
141
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
142
|
+
k_type = Regexp.last_match[:k_type]
|
143
|
+
v_type = Regexp.last_match[:v_type]
|
144
|
+
{}.tap do |hash|
|
145
|
+
value.each do |k, v|
|
146
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
else # model
|
150
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
151
|
+
_model.build_from_hash(value)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def to_s
|
156
|
+
to_hash.to_s
|
157
|
+
end
|
158
|
+
|
159
|
+
# to_body is an alias to to_body (backward compatibility))
|
160
|
+
def to_body
|
161
|
+
to_hash
|
162
|
+
end
|
163
|
+
|
164
|
+
# return the object in the form of hash
|
165
|
+
def to_hash
|
166
|
+
hash = {}
|
167
|
+
self.class.attribute_map.each_pair do |attr, param|
|
168
|
+
value = self.send(attr)
|
169
|
+
next if value.nil?
|
170
|
+
hash[param] = _to_hash(value)
|
171
|
+
end
|
172
|
+
hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Method to output non-array value in the form of hash
|
176
|
+
# For object, use to_hash. Otherwise, just return the value
|
177
|
+
def _to_hash(value)
|
178
|
+
if value.is_a?(Array)
|
179
|
+
value.compact.map{ |v| _to_hash(v) }
|
180
|
+
elsif value.is_a?(Hash)
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
183
|
+
end
|
184
|
+
elsif value.respond_to? :to_hash
|
185
|
+
value.to_hash
|
186
|
+
else
|
187
|
+
value
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
private
|
193
|
+
def after_parse
|
194
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
195
|
+
end
|
196
|
+
|
197
|
+
# Attribute datatype mapping.
|
198
|
+
def self.datatype_map
|
199
|
+
{
|
200
|
+
:precheckout_data => 'PrecheckoutData',
|
201
|
+
:wallet_partner_logo_url => 'String',
|
202
|
+
:masterpass_logo_url => 'String',
|
203
|
+
:long_access_token => 'String',
|
204
|
+
:extension_point => 'ExtensionPoint'
|
205
|
+
|
206
|
+
}
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
end
|