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