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,197 @@
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 option details for merchant initialization request during DSRP.
8
+ class Option
9
+ include ROXML
10
+
11
+ xml_name "Option"
12
+
13
+ # @!attribute brand_id
14
+ # @return [String] the brand id required for DSRP transactions. Identifies the card brands for which DSRP is desired. Currently, the only valid card ID is: master
15
+ xml_accessor :brand_id, :from =>"BrandId"
16
+
17
+ # @!attribute acceptance_type
18
+ # @return [String] the acceptance type required for DSRPtransactions. Indicates the type(s) of cryptograms the merchant or service provider can accept. Valid types are: UCAF and/or ICC (see descriptions that follow). MasterPass passes the most secure selection (ICC) if both acceptance types are indicated.
19
+ xml_accessor :acceptance_type, :from =>"AcceptanceType"
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
+ :brand_id => :BrandId ,
30
+ :acceptance_type => :AcceptanceType ,
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?(:BrandId) || attributes.has_key?(:brand_id)
44
+ self.brand_id = attributes[:BrandId] || attributes[:brand_id]
45
+ end
46
+
47
+ if attributes.has_key?(:AcceptanceType) || attributes.has_key?(:acceptance_type)
48
+ self.acceptance_type = attributes[:AcceptanceType] || attributes[:acceptance_type]
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
+ # Custom attribute writer method checking allowed values (enum).
61
+ def acceptance_type=(acceptance_type)
62
+ allowed_values = ["NONE", "ICC", "UCAF"]
63
+ if acceptance_type && !allowed_values.include?(acceptance_type)
64
+ fail "invalid value for 'acceptance_type', must be one of #{allowed_values}"
65
+ end
66
+ @acceptance_type = acceptance_type
67
+ end
68
+
69
+ # Check equality by comparing each attribute.
70
+ def ==(o)
71
+ return true if self.equal?(o)
72
+ self.class == o.class &&
73
+ brand_id == o.brand_id &&
74
+ acceptance_type == o.acceptance_type &&
75
+ extension_point == o.extension_point
76
+ end
77
+
78
+ # @see the `==` method
79
+ def eql?(o)
80
+ self == o
81
+ end
82
+
83
+ # Calculate hash code according to all attributes.
84
+ def hash
85
+ [brand_id, acceptance_type, extension_point].hash
86
+ end
87
+
88
+ # build the object from hash
89
+ def build_from_hash(attributes)
90
+ return nil unless attributes.is_a?(Hash)
91
+ self.class.datatype_map.each_pair do |key, type|
92
+ if type =~ /^Array<(.*)>/i
93
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
94
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
95
+ else
96
+ #TODO show warning in debug mode
97
+ end
98
+ elsif !attributes[self.class.attribute_map[key]].nil?
99
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
100
+ else
101
+ # data not found in attributes(hash), not an issue as the data can be optional
102
+ end
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ def _deserialize(type, value)
109
+ case type.to_sym
110
+ when :DateTime
111
+ DateTime.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :BOOLEAN
121
+ if value =~ /^(true|t|yes|y|1)$/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+ when /\AArray<(?<inner_type>.+)>\z/
127
+ inner_type = Regexp.last_match[:inner_type]
128
+ value.map { |v| _deserialize(inner_type, v) }
129
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
130
+ k_type = Regexp.last_match[:k_type]
131
+ v_type = Regexp.last_match[:v_type]
132
+ {}.tap do |hash|
133
+ value.each do |k, v|
134
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
135
+ end
136
+ end
137
+ else # model
138
+ _model = MastercardMasterpassMerchant.const_get(type).new
139
+ _model.build_from_hash(value)
140
+ end
141
+ end
142
+
143
+ def to_s
144
+ to_hash.to_s
145
+ end
146
+
147
+ # to_body is an alias to to_body (backward compatibility))
148
+ def to_body
149
+ to_hash
150
+ end
151
+
152
+ # return the object in the form of hash
153
+ def to_hash
154
+ hash = {}
155
+ self.class.attribute_map.each_pair do |attr, param|
156
+ value = self.send(attr)
157
+ next if value.nil?
158
+ hash[param] = _to_hash(value)
159
+ end
160
+ hash
161
+ end
162
+
163
+ # Method to output non-array value in the form of hash
164
+ # For object, use to_hash. Otherwise, just return the value
165
+ def _to_hash(value)
166
+ if value.is_a?(Array)
167
+ value.compact.map{ |v| _to_hash(v) }
168
+ elsif value.is_a?(Hash)
169
+ {}.tap do |hash|
170
+ value.each { |k, v| hash[k] = _to_hash(v) }
171
+ end
172
+ elsif value.respond_to? :to_hash
173
+ value.to_hash
174
+ else
175
+ value
176
+ end
177
+ end
178
+
179
+
180
+ private
181
+ def after_parse
182
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
183
+ end
184
+
185
+ # Attribute datatype mapping.
186
+ def self.datatype_map
187
+ {
188
+ :brand_id => 'String',
189
+ :acceptance_type => 'String',
190
+ :extension_point => 'ExtensionPoint'
191
+
192
+ }
193
+ end
194
+ end
195
+
196
+
197
+ end
@@ -0,0 +1,186 @@
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 to set different pairing data types.
8
+ class PairingDataType
9
+ include ROXML
10
+
11
+ xml_name "PairingDataType"
12
+
13
+ # @!attribute type
14
+ # @return [String] the different pairing data types like Card, Address, Reward Program and Profile.
15
+ xml_accessor :type, :from =>"Type"
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
+ :type => :Type ,
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?(:Type) || attributes.has_key?(:type)
39
+ self.type = attributes[:Type] || attributes[:type]
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
+ # Custom attribute writer method checking allowed values (enum).
52
+ def type=(type)
53
+ allowed_values = ["CARD", "ADDRESS", "REWARD_PROGRAM", "PROFILE"]
54
+ if type && !allowed_values.include?(type)
55
+ fail "invalid value for 'type', must be one of #{allowed_values}"
56
+ end
57
+ @type = type
58
+ end
59
+
60
+ # Check equality by comparing each attribute.
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ type == o.type &&
65
+ extension_point == o.extension_point
66
+ end
67
+
68
+ # @see the `==` method
69
+ def eql?(o)
70
+ self == o
71
+ end
72
+
73
+ # Calculate hash code according to all attributes.
74
+ def hash
75
+ [type, extension_point].hash
76
+ end
77
+
78
+ # build the object from hash
79
+ def build_from_hash(attributes)
80
+ return nil unless attributes.is_a?(Hash)
81
+ self.class.datatype_map.each_pair do |key, type|
82
+ if type =~ /^Array<(.*)>/i
83
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
84
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
85
+ else
86
+ #TODO show warning in debug mode
87
+ end
88
+ elsif !attributes[self.class.attribute_map[key]].nil?
89
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
90
+ else
91
+ # data not found in attributes(hash), not an issue as the data can be optional
92
+ end
93
+ end
94
+
95
+ self
96
+ end
97
+
98
+ def _deserialize(type, value)
99
+ case type.to_sym
100
+ when :DateTime
101
+ DateTime.parse(value)
102
+ when :Date
103
+ Date.parse(value)
104
+ when :String
105
+ value.to_s
106
+ when :Integer
107
+ value.to_i
108
+ when :Float
109
+ value.to_f
110
+ when :BOOLEAN
111
+ if value =~ /^(true|t|yes|y|1)$/i
112
+ true
113
+ else
114
+ false
115
+ end
116
+ when /\AArray<(?<inner_type>.+)>\z/
117
+ inner_type = Regexp.last_match[:inner_type]
118
+ value.map { |v| _deserialize(inner_type, v) }
119
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
120
+ k_type = Regexp.last_match[:k_type]
121
+ v_type = Regexp.last_match[:v_type]
122
+ {}.tap do |hash|
123
+ value.each do |k, v|
124
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
125
+ end
126
+ end
127
+ else # model
128
+ _model = MastercardMasterpassMerchant.const_get(type).new
129
+ _model.build_from_hash(value)
130
+ end
131
+ end
132
+
133
+ def to_s
134
+ to_hash.to_s
135
+ end
136
+
137
+ # to_body is an alias to to_body (backward compatibility))
138
+ def to_body
139
+ to_hash
140
+ end
141
+
142
+ # return the object in the form of hash
143
+ def to_hash
144
+ hash = {}
145
+ self.class.attribute_map.each_pair do |attr, param|
146
+ value = self.send(attr)
147
+ next if value.nil?
148
+ hash[param] = _to_hash(value)
149
+ end
150
+ hash
151
+ end
152
+
153
+ # Method to output non-array value in the form of hash
154
+ # For object, use to_hash. Otherwise, just return the value
155
+ def _to_hash(value)
156
+ if value.is_a?(Array)
157
+ value.compact.map{ |v| _to_hash(v) }
158
+ elsif value.is_a?(Hash)
159
+ {}.tap do |hash|
160
+ value.each { |k, v| hash[k] = _to_hash(v) }
161
+ end
162
+ elsif value.respond_to? :to_hash
163
+ value.to_hash
164
+ else
165
+ value
166
+ end
167
+ end
168
+
169
+
170
+ private
171
+ def after_parse
172
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
173
+ end
174
+
175
+ # Attribute datatype mapping.
176
+ def self.datatype_map
177
+ {
178
+ :type => 'String',
179
+ :extension_point => 'ExtensionPoint'
180
+
181
+ }
182
+ end
183
+ end
184
+
185
+
186
+ end
@@ -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/pairing_data_type'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ # This class contains methods for different pairing data types arrays.
9
+ class PairingDataTypes
10
+ include ROXML
11
+
12
+ xml_name "PairingDataTypes"
13
+
14
+ # @!attribute pairing_data_type
15
+ # @return [Array<PairingDataType>] the pairing data type.
16
+ xml_accessor :pairing_data_type, :from =>"PairingDataType", :as =>[PairingDataType]
17
+
18
+ # @!attribute extension_point
19
+ # @return [ExtensionPoint] the ExtensionPoint for future enhancement.
20
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
21
+
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :pairing_data_type => :PairingDataType ,
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?(:PairingDataType) || attributes.has_key?(:pairing_data_type)
40
+ self.pairing_data_type = attributes[:PairingDataType] || attributes[:pairing_data_type]
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 pairing_data_type
51
+ # @param value
52
+ def pairing_data_type=(value)
53
+ if (value.is_a?(Array))
54
+ @pairing_data_type = value
55
+ else
56
+ @pairing_data_type = [] if !@pairing_data_type
57
+ @pairing_data_type.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
+ pairing_data_type == o.pairing_data_type &&
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
+ [pairing_data_type, 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
+ :pairing_data_type => 'Array<PairingDataType>',
181
+ :extension_point => 'ExtensionPoint'
182
+
183
+ }
184
+ end
185
+ end
186
+
187
+
188
+ end