mastercard_masterpass_merchant 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +24 -0
  3. data/README.md +74 -0
  4. data/lib/mastercard_masterpass_merchant.rb +182 -0
  5. data/lib/mastercard_masterpass_merchant/api/checkout_api.rb +41 -0
  6. data/lib/mastercard_masterpass_merchant/api/decryption_api.rb +40 -0
  7. data/lib/mastercard_masterpass_merchant/api/express_checkout_api.rb +42 -0
  8. data/lib/mastercard_masterpass_merchant/api/merchant_initialization_api.rb +40 -0
  9. data/lib/mastercard_masterpass_merchant/api/postback_api.rb +39 -0
  10. data/lib/mastercard_masterpass_merchant/api/precheckout_data_api.rb +42 -0
  11. data/lib/mastercard_masterpass_merchant/api/session_key_signing_api.rb +40 -0
  12. data/lib/mastercard_masterpass_merchant/api/shopping_cart_api.rb +40 -0
  13. data/lib/mastercard_masterpass_merchant/models/acceptance_option.rb +177 -0
  14. data/lib/mastercard_masterpass_merchant/models/address.rb +243 -0
  15. data/lib/mastercard_masterpass_merchant/models/address_extension_point.rb +176 -0
  16. data/lib/mastercard_masterpass_merchant/models/authentication_options.rb +265 -0
  17. data/lib/mastercard_masterpass_merchant/models/base_card.rb +221 -0
  18. data/lib/mastercard_masterpass_merchant/models/brands.rb +165 -0
  19. data/lib/mastercard_masterpass_merchant/models/card.rb +244 -0
  20. data/lib/mastercard_masterpass_merchant/models/card_extension.rb +189 -0
  21. data/lib/mastercard_masterpass_merchant/models/card_type.rb +174 -0
  22. data/lib/mastercard_masterpass_merchant/models/card_types.rb +166 -0
  23. data/lib/mastercard_masterpass_merchant/models/checkout.rb +259 -0
  24. data/lib/mastercard_masterpass_merchant/models/checkout_dsrp.rb +210 -0
  25. data/lib/mastercard_masterpass_merchant/models/checkout_extension.rb +259 -0
  26. data/lib/mastercard_masterpass_merchant/models/contact.rb +275 -0
  27. data/lib/mastercard_masterpass_merchant/models/date_of_birth.rb +199 -0
  28. data/lib/mastercard_masterpass_merchant/models/decryption_request.rb +199 -0
  29. data/lib/mastercard_masterpass_merchant/models/decryption_response.rb +165 -0
  30. data/lib/mastercard_masterpass_merchant/models/detail.rb +176 -0
  31. data/lib/mastercard_masterpass_merchant/models/details.rb +176 -0
  32. data/lib/mastercard_masterpass_merchant/models/dsrp.rb +199 -0
  33. data/lib/mastercard_masterpass_merchant/models/dsrp_extension.rb +189 -0
  34. data/lib/mastercard_masterpass_merchant/models/dsrp_options.rb +188 -0
  35. data/lib/mastercard_masterpass_merchant/models/error.rb +222 -0
  36. data/lib/mastercard_masterpass_merchant/models/errors.rb +174 -0
  37. data/lib/mastercard_masterpass_merchant/models/express_checkout_request.rb +276 -0
  38. data/lib/mastercard_masterpass_merchant/models/express_checkout_response.rb +201 -0
  39. data/lib/mastercard_masterpass_merchant/models/extension_point.rb +163 -0
  40. data/lib/mastercard_masterpass_merchant/models/installment.rb +221 -0
  41. data/lib/mastercard_masterpass_merchant/models/installment_option.rb +198 -0
  42. data/lib/mastercard_masterpass_merchant/models/installment_options.rb +166 -0
  43. data/lib/mastercard_masterpass_merchant/models/installments.rb +176 -0
  44. data/lib/mastercard_masterpass_merchant/models/issuers.rb +165 -0
  45. data/lib/mastercard_masterpass_merchant/models/merchant_initialization_extension.rb +201 -0
  46. data/lib/mastercard_masterpass_merchant/models/merchant_initialization_request.rb +199 -0
  47. data/lib/mastercard_masterpass_merchant/models/merchant_initialization_response.rb +177 -0
  48. data/lib/mastercard_masterpass_merchant/models/merchant_initialization_response_extension.rb +165 -0
  49. data/lib/mastercard_masterpass_merchant/models/merchant_transaction.rb +274 -0
  50. data/lib/mastercard_masterpass_merchant/models/merchant_transactions.rb +176 -0
  51. data/lib/mastercard_masterpass_merchant/models/option.rb +197 -0
  52. data/lib/mastercard_masterpass_merchant/models/pairing_data_type.rb +186 -0
  53. data/lib/mastercard_masterpass_merchant/models/pairing_data_types.rb +188 -0
  54. data/lib/mastercard_masterpass_merchant/models/payment_acceptance.rb +166 -0
  55. data/lib/mastercard_masterpass_merchant/models/payment_acceptance_types_extension.rb +166 -0
  56. data/lib/mastercard_masterpass_merchant/models/payment_options_extensions.rb +178 -0
  57. data/lib/mastercard_masterpass_merchant/models/precheckout_card.rb +288 -0
  58. data/lib/mastercard_masterpass_merchant/models/precheckout_cards.rb +188 -0
  59. data/lib/mastercard_masterpass_merchant/models/precheckout_data.rb +259 -0
  60. data/lib/mastercard_masterpass_merchant/models/precheckout_data_request.rb +178 -0
  61. data/lib/mastercard_masterpass_merchant/models/precheckout_data_response.rb +211 -0
  62. data/lib/mastercard_masterpass_merchant/models/precheckout_reward_program.rb +243 -0
  63. data/lib/mastercard_masterpass_merchant/models/precheckout_shipping_address.rb +298 -0
  64. data/lib/mastercard_masterpass_merchant/models/precheckout_shipping_addresses.rb +188 -0
  65. data/lib/mastercard_masterpass_merchant/models/private_data.rb +177 -0
  66. data/lib/mastercard_masterpass_merchant/models/private_datas.rb +166 -0
  67. data/lib/mastercard_masterpass_merchant/models/reward_program.rb +221 -0
  68. data/lib/mastercard_masterpass_merchant/models/reward_programs.rb +188 -0
  69. data/lib/mastercard_masterpass_merchant/models/risk_decisioning.rb +178 -0
  70. data/lib/mastercard_masterpass_merchant/models/session_key_signing_request.rb +199 -0
  71. data/lib/mastercard_masterpass_merchant/models/session_key_signing_response.rb +210 -0
  72. data/lib/mastercard_masterpass_merchant/models/shipping_address.rb +265 -0
  73. data/lib/mastercard_masterpass_merchant/models/shopping_cart.rb +210 -0
  74. data/lib/mastercard_masterpass_merchant/models/shopping_cart_item.rb +210 -0
  75. data/lib/mastercard_masterpass_merchant/models/shopping_cart_request.rb +189 -0
  76. data/lib/mastercard_masterpass_merchant/models/shopping_cart_request_extension_point.rb +165 -0
  77. data/lib/mastercard_masterpass_merchant/models/shopping_cart_response.rb +177 -0
  78. data/lib/mastercard_masterpass_merchant/models/tokenization.rb +188 -0
  79. data/lib/mastercard_masterpass_merchant/models/types.rb +174 -0
  80. data/lib/mastercard_masterpass_merchant/models/wallet.rb +177 -0
  81. data/lib/mastercard_masterpass_merchant/tracker/sdk_api_tracker.rb +57 -0
  82. data/lib/mastercard_masterpass_merchant/version.rb +3 -0
  83. metadata +240 -0
@@ -0,0 +1,176 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/detail'
4
+
5
+
6
+ module MastercardMasterpassMerchant
7
+ # The error details.
8
+ class Details
9
+ include ROXML
10
+
11
+ xml_name "Details"
12
+
13
+ # @!attribute detail
14
+ # @return [Array<Detail>] the error detail.
15
+ xml_accessor :detail, :from =>"Detail", :as =>[Detail]
16
+
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :detail => :Detail
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?(:Detail) || attributes.has_key?(:detail)
34
+ self.detail = attributes[:Detail] || attributes[:detail]
35
+ end
36
+
37
+ end
38
+
39
+
40
+ # Overriding setter method detail
41
+ # @param value
42
+ def detail=(value)
43
+ if (value.is_a?(Array))
44
+ @detail = value
45
+ else
46
+ @detail = [] if !@detail
47
+ @detail.push value
48
+ end
49
+ end
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
+ detail == o.detail
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
+ [detail].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
+ :detail => 'Array<Detail>'
170
+
171
+ }
172
+ end
173
+ end
174
+
175
+
176
+ end
@@ -0,0 +1,199 @@
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 DSRP details during DSRP checkout.
8
+ class DSRP
9
+ include ROXML
10
+
11
+ xml_name "DSRP"
12
+
13
+ # @!attribute dsrp_data
14
+ # @return [String] the DSRP cryptogram generated by the consumers MasterPass wallet.
15
+ xml_accessor :dsrp_data, :from =>"DSRPData"
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 unpredictable_number
22
+ # @return [String] the encoded EMV-quality random number generated by either the merchant or MasterPass.
23
+ xml_accessor :unpredictable_number, :from =>"UnpredictableNumber"
24
+
25
+ # @!attribute extension_point
26
+ # @return [ExtensionPoint] the ExtensionPoint for future enhancement.
27
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
28
+
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :dsrp_data => :DSRPData ,
34
+ :dsrp_data_type => :DSRPDataType ,
35
+ :unpredictable_number => :UnpredictableNumber ,
36
+ :extension_point => :ExtensionPoint
37
+
38
+ }
39
+ end
40
+
41
+ def initialize(attributes = {})
42
+ return unless attributes.is_a?(Hash)
43
+
44
+ # convert string to symbol for hash key
45
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
46
+
47
+
48
+ if attributes.has_key?(:DSRPData) || attributes.has_key?(:dsrp_data)
49
+ self.dsrp_data = attributes[:DSRPData] || attributes[:dsrp_data]
50
+ end
51
+
52
+ if attributes.has_key?(:DSRPDataType) || attributes.has_key?(:dsrp_data_type)
53
+ self.dsrp_data_type = attributes[:DSRPDataType] || attributes[:dsrp_data_type]
54
+ end
55
+
56
+ if attributes.has_key?(:UnpredictableNumber) || attributes.has_key?(:unpredictable_number)
57
+ self.unpredictable_number = attributes[:UnpredictableNumber] || attributes[:unpredictable_number]
58
+ end
59
+
60
+ if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
61
+ self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
62
+ end
63
+
64
+ end
65
+
66
+
67
+
68
+
69
+ # Check equality by comparing each attribute.
70
+ def ==(o)
71
+ return true if self.equal?(o)
72
+ self.class == o.class &&
73
+ dsrp_data == o.dsrp_data &&
74
+ dsrp_data_type == o.dsrp_data_type &&
75
+ unpredictable_number == o.unpredictable_number &&
76
+ extension_point == o.extension_point
77
+ end
78
+
79
+ # @see the `==` method
80
+ def eql?(o)
81
+ self == o
82
+ end
83
+
84
+ # Calculate hash code according to all attributes.
85
+ def hash
86
+ [dsrp_data, dsrp_data_type, unpredictable_number, extension_point].hash
87
+ end
88
+
89
+ # build the object from hash
90
+ def build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ self.class.datatype_map.each_pair do |key, type|
93
+ if type =~ /^Array<(.*)>/i
94
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
95
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
96
+ else
97
+ #TODO show warning in debug mode
98
+ end
99
+ elsif !attributes[self.class.attribute_map[key]].nil?
100
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
101
+ else
102
+ # data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+ end
105
+
106
+ self
107
+ end
108
+
109
+ def _deserialize(type, value)
110
+ case type.to_sym
111
+ when :DateTime
112
+ DateTime.parse(value)
113
+ when :Date
114
+ Date.parse(value)
115
+ when :String
116
+ value.to_s
117
+ when :Integer
118
+ value.to_i
119
+ when :Float
120
+ value.to_f
121
+ when :BOOLEAN
122
+ if value =~ /^(true|t|yes|y|1)$/i
123
+ true
124
+ else
125
+ false
126
+ end
127
+ when /\AArray<(?<inner_type>.+)>\z/
128
+ inner_type = Regexp.last_match[:inner_type]
129
+ value.map { |v| _deserialize(inner_type, v) }
130
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
131
+ k_type = Regexp.last_match[:k_type]
132
+ v_type = Regexp.last_match[:v_type]
133
+ {}.tap do |hash|
134
+ value.each do |k, v|
135
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
136
+ end
137
+ end
138
+ else # model
139
+ _model = MastercardMasterpassMerchant.const_get(type).new
140
+ _model.build_from_hash(value)
141
+ end
142
+ end
143
+
144
+ def to_s
145
+ to_hash.to_s
146
+ end
147
+
148
+ # to_body is an alias to to_body (backward compatibility))
149
+ def to_body
150
+ to_hash
151
+ end
152
+
153
+ # return the object in the form of hash
154
+ def to_hash
155
+ hash = {}
156
+ self.class.attribute_map.each_pair do |attr, param|
157
+ value = self.send(attr)
158
+ next if value.nil?
159
+ hash[param] = _to_hash(value)
160
+ end
161
+ hash
162
+ end
163
+
164
+ # Method to output non-array value in the form of hash
165
+ # For object, use to_hash. Otherwise, just return the value
166
+ def _to_hash(value)
167
+ if value.is_a?(Array)
168
+ value.compact.map{ |v| _to_hash(v) }
169
+ elsif value.is_a?(Hash)
170
+ {}.tap do |hash|
171
+ value.each { |k, v| hash[k] = _to_hash(v) }
172
+ end
173
+ elsif value.respond_to? :to_hash
174
+ value.to_hash
175
+ else
176
+ value
177
+ end
178
+ end
179
+
180
+
181
+ private
182
+ def after_parse
183
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
184
+ end
185
+
186
+ # Attribute datatype mapping.
187
+ def self.datatype_map
188
+ {
189
+ :dsrp_data => 'String',
190
+ :dsrp_data_type => 'String',
191
+ :unpredictable_number => 'String',
192
+ :extension_point => 'ExtensionPoint'
193
+
194
+ }
195
+ end
196
+ end
197
+
198
+
199
+ end
@@ -0,0 +1,189 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/dsrp_options'
4
+ require_relative '../../mastercard_masterpass_merchant/models/extension_point'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ # This class contains methods require to set DSRP extension for merchant initialization request during DSRP.
9
+ class DSRPExtension
10
+ include ROXML
11
+
12
+ xml_name "DSRPExtension"
13
+
14
+ # @!attribute dsrp_options
15
+ # @return [DSRPOptions] the DSRP options details.
16
+ xml_accessor :dsrp_options, :from =>"DSRPOptions",:as => DSRPOptions
17
+
18
+ # @!attribute unpredictable_number
19
+ # @return [String] the unpredictable number. EMVquality random number generated by the merchant, service provider, or,if null,by MasterPass and Base64 encoded
20
+ xml_accessor :unpredictable_number, :from =>"UnpredictableNumber"
21
+
22
+ # @!attribute extension_point
23
+ # @return [ExtensionPoint] the ExtensionPoint for future enhancement.
24
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
25
+
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :dsrp_options => :DSRPOptions ,
31
+ :unpredictable_number => :UnpredictableNumber ,
32
+ :extension_point => :ExtensionPoint
33
+
34
+ }
35
+ end
36
+
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
42
+
43
+
44
+ if attributes.has_key?(:DSRPOptions) || attributes.has_key?(:dsrp_options)
45
+ self.dsrp_options = attributes[:DSRPOptions] || attributes[:dsrp_options]
46
+ end
47
+
48
+ if attributes.has_key?(:UnpredictableNumber) || attributes.has_key?(:unpredictable_number)
49
+ self.unpredictable_number = attributes[:UnpredictableNumber] || attributes[:unpredictable_number]
50
+ end
51
+
52
+ if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
53
+ self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
54
+ end
55
+
56
+ end
57
+
58
+
59
+
60
+
61
+ # Check equality by comparing each attribute.
62
+ def ==(o)
63
+ return true if self.equal?(o)
64
+ self.class == o.class &&
65
+ dsrp_options == o.dsrp_options &&
66
+ unpredictable_number == o.unpredictable_number &&
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
+ [dsrp_options, unpredictable_number, 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
+ :dsrp_options => 'DSRPOptions',
181
+ :unpredictable_number => 'String',
182
+ :extension_point => 'ExtensionPoint'
183
+
184
+ }
185
+ end
186
+ end
187
+
188
+
189
+ end