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,165 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
|
4
|
+
|
5
|
+
module MastercardMasterpassMerchant
|
6
|
+
# This class contains additional details for the shopping cart request.
|
7
|
+
class ShoppingCartRequestExtensionPoint
|
8
|
+
include ROXML
|
9
|
+
|
10
|
+
xml_name "ShoppingCartRequestExtensionPoint"
|
11
|
+
|
12
|
+
# @!attribute secondary_origin_url
|
13
|
+
# @return [String] the secondary URL.
|
14
|
+
xml_accessor :secondary_origin_url, :from =>"SecondaryOriginUrl"
|
15
|
+
|
16
|
+
|
17
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
18
|
+
def self.attribute_map
|
19
|
+
{
|
20
|
+
:secondary_origin_url => :SecondaryOriginUrl
|
21
|
+
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(attributes = {})
|
26
|
+
return unless attributes.is_a?(Hash)
|
27
|
+
|
28
|
+
# convert string to symbol for hash key
|
29
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
30
|
+
|
31
|
+
|
32
|
+
if attributes.has_key?(:SecondaryOriginUrl) || attributes.has_key?(:secondary_origin_url)
|
33
|
+
self.secondary_origin_url = attributes[:SecondaryOriginUrl] || attributes[:secondary_origin_url]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
# Check equality by comparing each attribute.
|
42
|
+
def ==(o)
|
43
|
+
return true if self.equal?(o)
|
44
|
+
self.class == o.class &&
|
45
|
+
secondary_origin_url == o.secondary_origin_url
|
46
|
+
end
|
47
|
+
|
48
|
+
# @see the `==` method
|
49
|
+
def eql?(o)
|
50
|
+
self == o
|
51
|
+
end
|
52
|
+
|
53
|
+
# Calculate hash code according to all attributes.
|
54
|
+
def hash
|
55
|
+
[secondary_origin_url].hash
|
56
|
+
end
|
57
|
+
|
58
|
+
# build the object from hash
|
59
|
+
def build_from_hash(attributes)
|
60
|
+
return nil unless attributes.is_a?(Hash)
|
61
|
+
self.class.datatype_map.each_pair do |key, type|
|
62
|
+
if type =~ /^Array<(.*)>/i
|
63
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
64
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
65
|
+
else
|
66
|
+
#TODO show warning in debug mode
|
67
|
+
end
|
68
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
69
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
70
|
+
else
|
71
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
self
|
76
|
+
end
|
77
|
+
|
78
|
+
def _deserialize(type, value)
|
79
|
+
case type.to_sym
|
80
|
+
when :DateTime
|
81
|
+
DateTime.parse(value)
|
82
|
+
when :Date
|
83
|
+
Date.parse(value)
|
84
|
+
when :String
|
85
|
+
value.to_s
|
86
|
+
when :Integer
|
87
|
+
value.to_i
|
88
|
+
when :Float
|
89
|
+
value.to_f
|
90
|
+
when :BOOLEAN
|
91
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
92
|
+
true
|
93
|
+
else
|
94
|
+
false
|
95
|
+
end
|
96
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
97
|
+
inner_type = Regexp.last_match[:inner_type]
|
98
|
+
value.map { |v| _deserialize(inner_type, v) }
|
99
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
100
|
+
k_type = Regexp.last_match[:k_type]
|
101
|
+
v_type = Regexp.last_match[:v_type]
|
102
|
+
{}.tap do |hash|
|
103
|
+
value.each do |k, v|
|
104
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
else # model
|
108
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
109
|
+
_model.build_from_hash(value)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def to_s
|
114
|
+
to_hash.to_s
|
115
|
+
end
|
116
|
+
|
117
|
+
# to_body is an alias to to_body (backward compatibility))
|
118
|
+
def to_body
|
119
|
+
to_hash
|
120
|
+
end
|
121
|
+
|
122
|
+
# return the object in the form of hash
|
123
|
+
def to_hash
|
124
|
+
hash = {}
|
125
|
+
self.class.attribute_map.each_pair do |attr, param|
|
126
|
+
value = self.send(attr)
|
127
|
+
next if value.nil?
|
128
|
+
hash[param] = _to_hash(value)
|
129
|
+
end
|
130
|
+
hash
|
131
|
+
end
|
132
|
+
|
133
|
+
# Method to output non-array value in the form of hash
|
134
|
+
# For object, use to_hash. Otherwise, just return the value
|
135
|
+
def _to_hash(value)
|
136
|
+
if value.is_a?(Array)
|
137
|
+
value.compact.map{ |v| _to_hash(v) }
|
138
|
+
elsif value.is_a?(Hash)
|
139
|
+
{}.tap do |hash|
|
140
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
141
|
+
end
|
142
|
+
elsif value.respond_to? :to_hash
|
143
|
+
value.to_hash
|
144
|
+
else
|
145
|
+
value
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
private
|
151
|
+
def after_parse
|
152
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
153
|
+
end
|
154
|
+
|
155
|
+
# Attribute datatype mapping.
|
156
|
+
def self.datatype_map
|
157
|
+
{
|
158
|
+
:secondary_origin_url => 'String'
|
159
|
+
|
160
|
+
}
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
|
5
|
+
|
6
|
+
module MastercardMasterpassMerchant
|
7
|
+
# This class contains various methods for to get the different values returned by Shopping Cart Service.
|
8
|
+
class ShoppingCartResponse
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name "ShoppingCartResponse"
|
12
|
+
|
13
|
+
# @!attribute o_auth_token
|
14
|
+
# @return [String] the request Token (oauth_token) returned by call to the request_token API.
|
15
|
+
xml_accessor :o_auth_token, :from =>"OAuthToken"
|
16
|
+
|
17
|
+
# @!attribute extension_point
|
18
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
19
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
20
|
+
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:o_auth_token => :OAuthToken ,
|
26
|
+
:extension_point => :ExtensionPoint
|
27
|
+
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(attributes = {})
|
32
|
+
return unless attributes.is_a?(Hash)
|
33
|
+
|
34
|
+
# convert string to symbol for hash key
|
35
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
36
|
+
|
37
|
+
|
38
|
+
if attributes.has_key?(:OAuthToken) || attributes.has_key?(:o_auth_token)
|
39
|
+
self.o_auth_token = attributes[:OAuthToken] || attributes[:o_auth_token]
|
40
|
+
end
|
41
|
+
|
42
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
43
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
# Check equality by comparing each attribute.
|
52
|
+
def ==(o)
|
53
|
+
return true if self.equal?(o)
|
54
|
+
self.class == o.class &&
|
55
|
+
o_auth_token == o.o_auth_token &&
|
56
|
+
extension_point == o.extension_point
|
57
|
+
end
|
58
|
+
|
59
|
+
# @see the `==` method
|
60
|
+
def eql?(o)
|
61
|
+
self == o
|
62
|
+
end
|
63
|
+
|
64
|
+
# Calculate hash code according to all attributes.
|
65
|
+
def hash
|
66
|
+
[o_auth_token, extension_point].hash
|
67
|
+
end
|
68
|
+
|
69
|
+
# build the object from hash
|
70
|
+
def build_from_hash(attributes)
|
71
|
+
return nil unless attributes.is_a?(Hash)
|
72
|
+
self.class.datatype_map.each_pair do |key, type|
|
73
|
+
if type =~ /^Array<(.*)>/i
|
74
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
75
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
76
|
+
else
|
77
|
+
#TODO show warning in debug mode
|
78
|
+
end
|
79
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
80
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
81
|
+
else
|
82
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
def _deserialize(type, value)
|
90
|
+
case type.to_sym
|
91
|
+
when :DateTime
|
92
|
+
DateTime.parse(value)
|
93
|
+
when :Date
|
94
|
+
Date.parse(value)
|
95
|
+
when :String
|
96
|
+
value.to_s
|
97
|
+
when :Integer
|
98
|
+
value.to_i
|
99
|
+
when :Float
|
100
|
+
value.to_f
|
101
|
+
when :BOOLEAN
|
102
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
103
|
+
true
|
104
|
+
else
|
105
|
+
false
|
106
|
+
end
|
107
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
108
|
+
inner_type = Regexp.last_match[:inner_type]
|
109
|
+
value.map { |v| _deserialize(inner_type, v) }
|
110
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
111
|
+
k_type = Regexp.last_match[:k_type]
|
112
|
+
v_type = Regexp.last_match[:v_type]
|
113
|
+
{}.tap do |hash|
|
114
|
+
value.each do |k, v|
|
115
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
else # model
|
119
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
120
|
+
_model.build_from_hash(value)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def to_s
|
125
|
+
to_hash.to_s
|
126
|
+
end
|
127
|
+
|
128
|
+
# to_body is an alias to to_body (backward compatibility))
|
129
|
+
def to_body
|
130
|
+
to_hash
|
131
|
+
end
|
132
|
+
|
133
|
+
# return the object in the form of hash
|
134
|
+
def to_hash
|
135
|
+
hash = {}
|
136
|
+
self.class.attribute_map.each_pair do |attr, param|
|
137
|
+
value = self.send(attr)
|
138
|
+
next if value.nil?
|
139
|
+
hash[param] = _to_hash(value)
|
140
|
+
end
|
141
|
+
hash
|
142
|
+
end
|
143
|
+
|
144
|
+
# Method to output non-array value in the form of hash
|
145
|
+
# For object, use to_hash. Otherwise, just return the value
|
146
|
+
def _to_hash(value)
|
147
|
+
if value.is_a?(Array)
|
148
|
+
value.compact.map{ |v| _to_hash(v) }
|
149
|
+
elsif value.is_a?(Hash)
|
150
|
+
{}.tap do |hash|
|
151
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
152
|
+
end
|
153
|
+
elsif value.respond_to? :to_hash
|
154
|
+
value.to_hash
|
155
|
+
else
|
156
|
+
value
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
private
|
162
|
+
def after_parse
|
163
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
164
|
+
end
|
165
|
+
|
166
|
+
# Attribute datatype mapping.
|
167
|
+
def self.datatype_map
|
168
|
+
{
|
169
|
+
:o_auth_token => 'String',
|
170
|
+
:extension_point => 'ExtensionPoint'
|
171
|
+
|
172
|
+
}
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
|
5
|
+
|
6
|
+
module MastercardMasterpassMerchant
|
7
|
+
# This class contains token request information.
|
8
|
+
class Tokenization
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name "Tokenization"
|
12
|
+
|
13
|
+
# @!attribute f_pan_suffix
|
14
|
+
# @return [String] the pan suffix.
|
15
|
+
xml_accessor :f_pan_suffix, :from =>"FPanSuffix"
|
16
|
+
|
17
|
+
# @!attribute token_requestor_id
|
18
|
+
# @return [String] the token request or id.
|
19
|
+
xml_accessor :token_requestor_id, :from =>"TokenRequestorId"
|
20
|
+
|
21
|
+
# @!attribute extension_point
|
22
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
23
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
24
|
+
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:f_pan_suffix => :FPanSuffix ,
|
30
|
+
:token_requestor_id => :TokenRequestorId ,
|
31
|
+
:extension_point => :ExtensionPoint
|
32
|
+
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(attributes = {})
|
37
|
+
return unless attributes.is_a?(Hash)
|
38
|
+
|
39
|
+
# convert string to symbol for hash key
|
40
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
41
|
+
|
42
|
+
|
43
|
+
if attributes.has_key?(:FPanSuffix) || attributes.has_key?(:f_pan_suffix)
|
44
|
+
self.f_pan_suffix = attributes[:FPanSuffix] || attributes[:f_pan_suffix]
|
45
|
+
end
|
46
|
+
|
47
|
+
if attributes.has_key?(:TokenRequestorId) || attributes.has_key?(:token_requestor_id)
|
48
|
+
self.token_requestor_id = attributes[:TokenRequestorId] || attributes[:token_requestor_id]
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
52
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
# Check equality by comparing each attribute.
|
61
|
+
def ==(o)
|
62
|
+
return true if self.equal?(o)
|
63
|
+
self.class == o.class &&
|
64
|
+
f_pan_suffix == o.f_pan_suffix &&
|
65
|
+
token_requestor_id == o.token_requestor_id &&
|
66
|
+
extension_point == o.extension_point
|
67
|
+
end
|
68
|
+
|
69
|
+
# @see the `==` method
|
70
|
+
def eql?(o)
|
71
|
+
self == o
|
72
|
+
end
|
73
|
+
|
74
|
+
# Calculate hash code according to all attributes.
|
75
|
+
def hash
|
76
|
+
[f_pan_suffix, token_requestor_id, extension_point].hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# build the object from hash
|
80
|
+
def build_from_hash(attributes)
|
81
|
+
return nil unless attributes.is_a?(Hash)
|
82
|
+
self.class.datatype_map.each_pair do |key, type|
|
83
|
+
if type =~ /^Array<(.*)>/i
|
84
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
85
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
86
|
+
else
|
87
|
+
#TODO show warning in debug mode
|
88
|
+
end
|
89
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
90
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
91
|
+
else
|
92
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
self
|
97
|
+
end
|
98
|
+
|
99
|
+
def _deserialize(type, value)
|
100
|
+
case type.to_sym
|
101
|
+
when :DateTime
|
102
|
+
DateTime.parse(value)
|
103
|
+
when :Date
|
104
|
+
Date.parse(value)
|
105
|
+
when :String
|
106
|
+
value.to_s
|
107
|
+
when :Integer
|
108
|
+
value.to_i
|
109
|
+
when :Float
|
110
|
+
value.to_f
|
111
|
+
when :BOOLEAN
|
112
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
113
|
+
true
|
114
|
+
else
|
115
|
+
false
|
116
|
+
end
|
117
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
118
|
+
inner_type = Regexp.last_match[:inner_type]
|
119
|
+
value.map { |v| _deserialize(inner_type, v) }
|
120
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
121
|
+
k_type = Regexp.last_match[:k_type]
|
122
|
+
v_type = Regexp.last_match[:v_type]
|
123
|
+
{}.tap do |hash|
|
124
|
+
value.each do |k, v|
|
125
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
else # model
|
129
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
130
|
+
_model.build_from_hash(value)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def to_s
|
135
|
+
to_hash.to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
# to_body is an alias to to_body (backward compatibility))
|
139
|
+
def to_body
|
140
|
+
to_hash
|
141
|
+
end
|
142
|
+
|
143
|
+
# return the object in the form of hash
|
144
|
+
def to_hash
|
145
|
+
hash = {}
|
146
|
+
self.class.attribute_map.each_pair do |attr, param|
|
147
|
+
value = self.send(attr)
|
148
|
+
next if value.nil?
|
149
|
+
hash[param] = _to_hash(value)
|
150
|
+
end
|
151
|
+
hash
|
152
|
+
end
|
153
|
+
|
154
|
+
# Method to output non-array value in the form of hash
|
155
|
+
# For object, use to_hash. Otherwise, just return the value
|
156
|
+
def _to_hash(value)
|
157
|
+
if value.is_a?(Array)
|
158
|
+
value.compact.map{ |v| _to_hash(v) }
|
159
|
+
elsif value.is_a?(Hash)
|
160
|
+
{}.tap do |hash|
|
161
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
162
|
+
end
|
163
|
+
elsif value.respond_to? :to_hash
|
164
|
+
value.to_hash
|
165
|
+
else
|
166
|
+
value
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
private
|
172
|
+
def after_parse
|
173
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
174
|
+
end
|
175
|
+
|
176
|
+
# Attribute datatype mapping.
|
177
|
+
def self.datatype_map
|
178
|
+
{
|
179
|
+
:f_pan_suffix => 'String',
|
180
|
+
:token_requestor_id => 'String',
|
181
|
+
:extension_point => 'ExtensionPoint'
|
182
|
+
|
183
|
+
}
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
end
|