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,210 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/dsrp'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
5
|
+
|
6
|
+
|
7
|
+
module MastercardMasterpassMerchant
|
8
|
+
class CheckoutDSRP
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name "CheckoutDSRP"
|
12
|
+
|
13
|
+
# @!attribute eci
|
14
|
+
# @return [String] the electronic commerce indicator (ECI) value (DE 48 SE 42 position 3). Present only when DSRP data type is UCAF. For MasterCard brand cards, value is: 02Authenticated by ACS (Card Issuer Liability)
|
15
|
+
xml_accessor :eci, :from =>"Eci"
|
16
|
+
|
17
|
+
# @!attribute dsrp_data_type
|
18
|
+
# @return [String] the type of cryptogram generated by the consumers MasterPass wallet. MasterPass passes the most secure selection (ICC) if the merchant or service provider has indicated they can accept both types (UCAF, ICC).
|
19
|
+
xml_accessor :dsrp_data_type, :from =>"DSRPDataType"
|
20
|
+
|
21
|
+
# @!attribute dsrp_data
|
22
|
+
# @return [String] the DSRP cryptogram generated by the consumers MasterPass wallet.
|
23
|
+
xml_accessor :dsrp_data, :from =>"DSRPData"
|
24
|
+
|
25
|
+
# @!attribute extension_point
|
26
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
27
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
28
|
+
|
29
|
+
# @!attribute unpredictable_number
|
30
|
+
# @return [String] the encoded EMV-quality random number generated by either the merchant or MasterPass.
|
31
|
+
xml_accessor :unpredictable_number, :from =>"UnpredictableNumber"
|
32
|
+
|
33
|
+
|
34
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
35
|
+
def self.attribute_map
|
36
|
+
{
|
37
|
+
:eci => :Eci ,
|
38
|
+
:dsrp_data_type => :DSRPDataType ,
|
39
|
+
:dsrp_data => :DSRPData ,
|
40
|
+
:extension_point => :ExtensionPoint ,
|
41
|
+
:unpredictable_number => :UnpredictableNumber
|
42
|
+
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(attributes = {})
|
47
|
+
return unless attributes.is_a?(Hash)
|
48
|
+
|
49
|
+
# convert string to symbol for hash key
|
50
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
51
|
+
|
52
|
+
|
53
|
+
if attributes.has_key?(:Eci) || attributes.has_key?(:eci)
|
54
|
+
self.eci = attributes[:Eci] || attributes[:eci]
|
55
|
+
end
|
56
|
+
|
57
|
+
if attributes.has_key?(:DSRPDataType) || attributes.has_key?(:dsrp_data_type)
|
58
|
+
self.dsrp_data_type = attributes[:DSRPDataType] || attributes[:dsrp_data_type]
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes.has_key?(:DSRPData) || attributes.has_key?(:dsrp_data)
|
62
|
+
self.dsrp_data = attributes[:DSRPData] || attributes[:dsrp_data]
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
66
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes.has_key?(:UnpredictableNumber) || attributes.has_key?(:unpredictable_number)
|
70
|
+
self.unpredictable_number = attributes[:UnpredictableNumber] || attributes[:unpredictable_number]
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
# Check equality by comparing each attribute.
|
79
|
+
def ==(o)
|
80
|
+
return true if self.equal?(o)
|
81
|
+
self.class == o.class &&
|
82
|
+
eci == o.eci &&
|
83
|
+
dsrp_data_type == o.dsrp_data_type &&
|
84
|
+
dsrp_data == o.dsrp_data &&
|
85
|
+
extension_point == o.extension_point &&
|
86
|
+
unpredictable_number == o.unpredictable_number
|
87
|
+
end
|
88
|
+
|
89
|
+
# @see the `==` method
|
90
|
+
def eql?(o)
|
91
|
+
self == o
|
92
|
+
end
|
93
|
+
|
94
|
+
# Calculate hash code according to all attributes.
|
95
|
+
def hash
|
96
|
+
[eci, dsrp_data_type, dsrp_data, extension_point, unpredictable_number].hash
|
97
|
+
end
|
98
|
+
|
99
|
+
# build the object from hash
|
100
|
+
def build_from_hash(attributes)
|
101
|
+
return nil unless attributes.is_a?(Hash)
|
102
|
+
self.class.datatype_map.each_pair do |key, type|
|
103
|
+
if type =~ /^Array<(.*)>/i
|
104
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
105
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
106
|
+
else
|
107
|
+
#TODO show warning in debug mode
|
108
|
+
end
|
109
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
110
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
111
|
+
else
|
112
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
self
|
117
|
+
end
|
118
|
+
|
119
|
+
def _deserialize(type, value)
|
120
|
+
case type.to_sym
|
121
|
+
when :DateTime
|
122
|
+
DateTime.parse(value)
|
123
|
+
when :Date
|
124
|
+
Date.parse(value)
|
125
|
+
when :String
|
126
|
+
value.to_s
|
127
|
+
when :Integer
|
128
|
+
value.to_i
|
129
|
+
when :Float
|
130
|
+
value.to_f
|
131
|
+
when :BOOLEAN
|
132
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
133
|
+
true
|
134
|
+
else
|
135
|
+
false
|
136
|
+
end
|
137
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
138
|
+
inner_type = Regexp.last_match[:inner_type]
|
139
|
+
value.map { |v| _deserialize(inner_type, v) }
|
140
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
141
|
+
k_type = Regexp.last_match[:k_type]
|
142
|
+
v_type = Regexp.last_match[:v_type]
|
143
|
+
{}.tap do |hash|
|
144
|
+
value.each do |k, v|
|
145
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
else # model
|
149
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
150
|
+
_model.build_from_hash(value)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def to_s
|
155
|
+
to_hash.to_s
|
156
|
+
end
|
157
|
+
|
158
|
+
# to_body is an alias to to_body (backward compatibility))
|
159
|
+
def to_body
|
160
|
+
to_hash
|
161
|
+
end
|
162
|
+
|
163
|
+
# return the object in the form of hash
|
164
|
+
def to_hash
|
165
|
+
hash = {}
|
166
|
+
self.class.attribute_map.each_pair do |attr, param|
|
167
|
+
value = self.send(attr)
|
168
|
+
next if value.nil?
|
169
|
+
hash[param] = _to_hash(value)
|
170
|
+
end
|
171
|
+
hash
|
172
|
+
end
|
173
|
+
|
174
|
+
# Method to output non-array value in the form of hash
|
175
|
+
# For object, use to_hash. Otherwise, just return the value
|
176
|
+
def _to_hash(value)
|
177
|
+
if value.is_a?(Array)
|
178
|
+
value.compact.map{ |v| _to_hash(v) }
|
179
|
+
elsif value.is_a?(Hash)
|
180
|
+
{}.tap do |hash|
|
181
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
182
|
+
end
|
183
|
+
elsif value.respond_to? :to_hash
|
184
|
+
value.to_hash
|
185
|
+
else
|
186
|
+
value
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
private
|
192
|
+
def after_parse
|
193
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
194
|
+
end
|
195
|
+
|
196
|
+
# Attribute datatype mapping.
|
197
|
+
def self.datatype_map
|
198
|
+
{
|
199
|
+
:eci => 'String',
|
200
|
+
:dsrp_data_type => 'String',
|
201
|
+
:dsrp_data => 'String',
|
202
|
+
:extension_point => 'ExtensionPoint',
|
203
|
+
:unpredictable_number => 'String'
|
204
|
+
|
205
|
+
}
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
end
|
@@ -0,0 +1,259 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/checkout_dsrp'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
5
|
+
require_relative '../../mastercard_masterpass_merchant/models/installment_option'
|
6
|
+
require_relative '../../mastercard_masterpass_merchant/models/private_datas'
|
7
|
+
require_relative '../../mastercard_masterpass_merchant/models/risk_decisioning'
|
8
|
+
require_relative '../../mastercard_masterpass_merchant/models/tokenization'
|
9
|
+
|
10
|
+
|
11
|
+
module MastercardMasterpassMerchant
|
12
|
+
# This class contains methods require to set checkout details during DSRP.
|
13
|
+
class CheckoutExtension
|
14
|
+
include ROXML
|
15
|
+
|
16
|
+
xml_name "CheckoutExtension"
|
17
|
+
|
18
|
+
# @!attribute card_verification_status
|
19
|
+
# @return [String] the card verification status.
|
20
|
+
xml_accessor :card_verification_status, :from =>"CardVerificationStatus"
|
21
|
+
|
22
|
+
# @!attribute login_authentication_method
|
23
|
+
# @return [String] the login authentication method.
|
24
|
+
xml_accessor :login_authentication_method, :from =>"LoginAuthenticationMethod"
|
25
|
+
|
26
|
+
# @!attribute risk_decisioning
|
27
|
+
# @return [RiskDecisioning] the risk decisioning data.
|
28
|
+
xml_accessor :risk_decisioning, :from =>"RiskDecisioning",:as => RiskDecisioning
|
29
|
+
|
30
|
+
# @!attribute dsrp
|
31
|
+
# @return [CheckoutDSRP] the DSRP data.
|
32
|
+
xml_accessor :dsrp, :from =>"DSRP",:as => CheckoutDSRP
|
33
|
+
|
34
|
+
# @!attribute private_datas
|
35
|
+
# @return [PrivateDatas] the private data details.
|
36
|
+
xml_accessor :private_datas, :from =>"PrivateDatas",:as => PrivateDatas
|
37
|
+
|
38
|
+
# @!attribute installment_option
|
39
|
+
# @return [InstallmentOption] the installment options details.
|
40
|
+
xml_accessor :installment_option, :from =>"InstallmentOption",:as => InstallmentOption
|
41
|
+
|
42
|
+
# @!attribute tokenization
|
43
|
+
# @return [Tokenization] the token details.
|
44
|
+
xml_accessor :tokenization, :from =>"Tokenization",:as => Tokenization
|
45
|
+
|
46
|
+
# @!attribute payment_account_reference
|
47
|
+
# @return [String] the payment account reference.
|
48
|
+
xml_accessor :payment_account_reference, :from =>"PaymentAccountReference"
|
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
|
+
:card_verification_status => :CardVerificationStatus ,
|
59
|
+
:login_authentication_method => :LoginAuthenticationMethod ,
|
60
|
+
:risk_decisioning => :RiskDecisioning ,
|
61
|
+
:dsrp => :DSRP ,
|
62
|
+
:private_datas => :PrivateDatas ,
|
63
|
+
:installment_option => :InstallmentOption ,
|
64
|
+
:tokenization => :Tokenization ,
|
65
|
+
:payment_account_reference => :PaymentAccountReference ,
|
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?(:CardVerificationStatus) || attributes.has_key?(:card_verification_status)
|
79
|
+
self.card_verification_status = attributes[:CardVerificationStatus] || attributes[:card_verification_status]
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.has_key?(:LoginAuthenticationMethod) || attributes.has_key?(:login_authentication_method)
|
83
|
+
self.login_authentication_method = attributes[:LoginAuthenticationMethod] || attributes[:login_authentication_method]
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.has_key?(:RiskDecisioning) || attributes.has_key?(:risk_decisioning)
|
87
|
+
self.risk_decisioning = attributes[:RiskDecisioning] || attributes[:risk_decisioning]
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.has_key?(:DSRP) || attributes.has_key?(:dsrp)
|
91
|
+
self.dsrp = attributes[:DSRP] || attributes[:dsrp]
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.has_key?(:PrivateDatas) || attributes.has_key?(:private_datas)
|
95
|
+
self.private_datas = attributes[:PrivateDatas] || attributes[:private_datas]
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.has_key?(:InstallmentOption) || attributes.has_key?(:installment_option)
|
99
|
+
self.installment_option = attributes[:InstallmentOption] || attributes[:installment_option]
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.has_key?(:Tokenization) || attributes.has_key?(:tokenization)
|
103
|
+
self.tokenization = attributes[:Tokenization] || attributes[:tokenization]
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.has_key?(:PaymentAccountReference) || attributes.has_key?(:payment_account_reference)
|
107
|
+
self.payment_account_reference = attributes[:PaymentAccountReference] || attributes[:payment_account_reference]
|
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
|
+
card_verification_status == o.card_verification_status &&
|
124
|
+
login_authentication_method == o.login_authentication_method &&
|
125
|
+
risk_decisioning == o.risk_decisioning &&
|
126
|
+
dsrp == o.dsrp &&
|
127
|
+
private_datas == o.private_datas &&
|
128
|
+
installment_option == o.installment_option &&
|
129
|
+
tokenization == o.tokenization &&
|
130
|
+
payment_account_reference == o.payment_account_reference &&
|
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
|
+
[card_verification_status, login_authentication_method, risk_decisioning, dsrp, private_datas, installment_option, tokenization, payment_account_reference, 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
|
+
:card_verification_status => 'String',
|
245
|
+
:login_authentication_method => 'String',
|
246
|
+
:risk_decisioning => 'RiskDecisioning',
|
247
|
+
:dsrp => 'CheckoutDSRP',
|
248
|
+
:private_datas => 'PrivateDatas',
|
249
|
+
:installment_option => 'InstallmentOption',
|
250
|
+
:tokenization => 'Tokenization',
|
251
|
+
:payment_account_reference => 'String',
|
252
|
+
:extension_point => 'ExtensionPoint'
|
253
|
+
|
254
|
+
}
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
|
259
|
+
end
|