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,210 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/extension_point'
4
+ require_relative '../../mastercard_masterpass_merchant/models/shopping_cart_item'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ # This class contains various methods for to set different shopping cart parameters required for Shopping Cart Service.
9
+ class ShoppingCart
10
+ include ROXML
11
+
12
+ xml_name "ShoppingCart"
13
+
14
+ # @!attribute currency_code
15
+ # @return [String] the currency code defined by ISO 4217. Its should be exactly three characters, such as, USD for US Dollars. All MonetaryValues will be modified by the CurrencyCode.
16
+ xml_accessor :currency_code, :from =>"CurrencyCode"
17
+
18
+ # @!attribute subtotal
19
+ # @return [Integer] the total sum of all the items in the cart excluding shipping, handling and tax. Integer without the decimal, for example, USD 119.00 will be 11900.
20
+ xml_accessor :subtotal, :from =>"Subtotal"
21
+
22
+ # @!attribute shopping_cart_item
23
+ # @return [Array<ShoppingCartItem>] the details of a single shopping cart item.
24
+ xml_accessor :shopping_cart_item, :from =>"ShoppingCartItem", :as =>[ShoppingCartItem]
25
+
26
+ # @!attribute extension_point
27
+ # @return [ExtensionPoint] the ExtensionPoint for future enhancement.
28
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :currency_code => :CurrencyCode ,
35
+ :subtotal => :Subtotal ,
36
+ :shopping_cart_item => :ShoppingCartItem ,
37
+ :extension_point => :ExtensionPoint
38
+
39
+ }
40
+ end
41
+
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
47
+
48
+
49
+ if attributes.has_key?(:CurrencyCode) || attributes.has_key?(:currency_code)
50
+ self.currency_code = attributes[:CurrencyCode] || attributes[:currency_code]
51
+ end
52
+
53
+ if attributes.has_key?(:Subtotal) || attributes.has_key?(:subtotal)
54
+ self.subtotal = attributes[:Subtotal] || attributes[:subtotal]
55
+ end
56
+
57
+ if attributes.has_key?(:ShoppingCartItem) || attributes.has_key?(:shopping_cart_item)
58
+ self.shopping_cart_item = attributes[:ShoppingCartItem] || attributes[:shopping_cart_item]
59
+ end
60
+
61
+ if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
62
+ self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
63
+ end
64
+
65
+ end
66
+
67
+
68
+ # Overriding setter method shopping_cart_item
69
+ # @param value
70
+ def shopping_cart_item=(value)
71
+ if (value.is_a?(Array))
72
+ @shopping_cart_item = value
73
+ else
74
+ @shopping_cart_item = [] if !@shopping_cart_item
75
+ @shopping_cart_item.push value
76
+ end
77
+ end
78
+
79
+
80
+ # Check equality by comparing each attribute.
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ currency_code == o.currency_code &&
85
+ subtotal == o.subtotal &&
86
+ shopping_cart_item == o.shopping_cart_item &&
87
+ extension_point == o.extension_point
88
+ end
89
+
90
+ # @see the `==` method
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculate hash code according to all attributes.
96
+ def hash
97
+ [currency_code, subtotal, shopping_cart_item, extension_point].hash
98
+ end
99
+
100
+ # build the object from hash
101
+ def build_from_hash(attributes)
102
+ return nil unless attributes.is_a?(Hash)
103
+ self.class.datatype_map.each_pair do |key, type|
104
+ if type =~ /^Array<(.*)>/i
105
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
106
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
107
+ else
108
+ #TODO show warning in debug mode
109
+ end
110
+ elsif !attributes[self.class.attribute_map[key]].nil?
111
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
112
+ else
113
+ # data not found in attributes(hash), not an issue as the data can be optional
114
+ end
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ def _deserialize(type, value)
121
+ case type.to_sym
122
+ when :DateTime
123
+ DateTime.parse(value)
124
+ when :Date
125
+ Date.parse(value)
126
+ when :String
127
+ value.to_s
128
+ when :Integer
129
+ value.to_i
130
+ when :Float
131
+ value.to_f
132
+ when :BOOLEAN
133
+ if value =~ /^(true|t|yes|y|1)$/i
134
+ true
135
+ else
136
+ false
137
+ end
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ _model = MastercardMasterpassMerchant.const_get(type).new
151
+ _model.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ def to_s
156
+ to_hash.to_s
157
+ end
158
+
159
+ # to_body is an alias to to_body (backward compatibility))
160
+ def to_body
161
+ to_hash
162
+ end
163
+
164
+ # return the object in the form of hash
165
+ def to_hash
166
+ hash = {}
167
+ self.class.attribute_map.each_pair do |attr, param|
168
+ value = self.send(attr)
169
+ next if value.nil?
170
+ hash[param] = _to_hash(value)
171
+ end
172
+ hash
173
+ end
174
+
175
+ # Method to output non-array value in the form of hash
176
+ # For object, use to_hash. Otherwise, just return the value
177
+ def _to_hash(value)
178
+ if value.is_a?(Array)
179
+ value.compact.map{ |v| _to_hash(v) }
180
+ elsif value.is_a?(Hash)
181
+ {}.tap do |hash|
182
+ value.each { |k, v| hash[k] = _to_hash(v) }
183
+ end
184
+ elsif value.respond_to? :to_hash
185
+ value.to_hash
186
+ else
187
+ value
188
+ end
189
+ end
190
+
191
+
192
+ private
193
+ def after_parse
194
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
195
+ end
196
+
197
+ # Attribute datatype mapping.
198
+ def self.datatype_map
199
+ {
200
+ :currency_code => 'String',
201
+ :subtotal => 'Integer',
202
+ :shopping_cart_item => 'Array<ShoppingCartItem>',
203
+ :extension_point => 'ExtensionPoint'
204
+
205
+ }
206
+ end
207
+ end
208
+
209
+
210
+ end
@@ -0,0 +1,210 @@
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 set shopping cart items required for Shopping Cart Service.
8
+ class ShoppingCartItem
9
+ include ROXML
10
+
11
+ xml_name "ShoppingCartItem"
12
+
13
+ # @!attribute description
14
+ # @return [String] the description shopping cart item.
15
+ xml_accessor :description, :from =>"Description"
16
+
17
+ # @!attribute quantity
18
+ # @return [Integer] the number of shopping cart item.
19
+ xml_accessor :quantity, :from =>"Quantity"
20
+
21
+ # @!attribute value
22
+ # @return [Integer] the price or monetary value of a single shopping cart item. Cost * Quantity. Integer without decimal, for example, USD 100.00 is 10000.
23
+ xml_accessor :value, :from =>"Value"
24
+
25
+ # @!attribute image_url
26
+ # @return [String] the image URL of the shopping cart item.
27
+ xml_accessor :image_url, :from =>"ImageURL"
28
+
29
+ # @!attribute extension_point
30
+ # @return [ExtensionPoint] the ExtensionPoint for future enhancement.
31
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
32
+
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :description => :Description ,
38
+ :quantity => :Quantity ,
39
+ :value => :Value ,
40
+ :image_url => :ImageURL ,
41
+ :extension_point => :ExtensionPoint
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?(:Description) || attributes.has_key?(:description)
54
+ self.description = attributes[:Description] || attributes[:description]
55
+ end
56
+
57
+ if attributes.has_key?(:Quantity) || attributes.has_key?(:quantity)
58
+ self.quantity = attributes[:Quantity] || attributes[:quantity]
59
+ end
60
+
61
+ if attributes.has_key?(:Value) || attributes.has_key?(:value)
62
+ self.value = attributes[:Value] || attributes[:value]
63
+ end
64
+
65
+ if attributes.has_key?(:ImageURL) || attributes.has_key?(:image_url)
66
+ self.image_url = attributes[:ImageURL] || attributes[:image_url]
67
+ end
68
+
69
+ if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
70
+ self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
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
+ description == o.description &&
83
+ quantity == o.quantity &&
84
+ value == o.value &&
85
+ image_url == o.image_url &&
86
+ extension_point == o.extension_point
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
+ [description, quantity, value, image_url, extension_point].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
+ :description => 'String',
200
+ :quantity => 'Integer',
201
+ :value => 'Integer',
202
+ :image_url => 'String',
203
+ :extension_point => 'ExtensionPoint'
204
+
205
+ }
206
+ end
207
+ end
208
+
209
+
210
+ end
@@ -0,0 +1,189 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/shopping_cart'
4
+ require_relative '../../mastercard_masterpass_merchant/models/shopping_cart_request_extension_point'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ # This class contains various methods for to set different shopping cart request parameters required for Shopping Cart Service.
9
+ class ShoppingCartRequest
10
+ include ROXML
11
+
12
+ xml_name "ShoppingCartRequest"
13
+
14
+ # @!attribute o_auth_token
15
+ # @return [String] the request Token (oauth_token) returned by call to the request_token API.
16
+ xml_accessor :o_auth_token, :from =>"OAuthToken"
17
+
18
+ # @!attribute shopping_cart
19
+ # @return [ShoppingCart] the Shopping Cart details.
20
+ xml_accessor :shopping_cart, :from =>"ShoppingCart",:as => ShoppingCart
21
+
22
+ # @!attribute extension_point
23
+ # @return [ShoppingCartRequestExtensionPoint] the ExtensionPoint for future enhancement.
24
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ShoppingCartRequestExtensionPoint
25
+
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :o_auth_token => :OAuthToken ,
31
+ :shopping_cart => :ShoppingCart ,
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?(:OAuthToken) || attributes.has_key?(:o_auth_token)
45
+ self.o_auth_token = attributes[:OAuthToken] || attributes[:o_auth_token]
46
+ end
47
+
48
+ if attributes.has_key?(:ShoppingCart) || attributes.has_key?(:shopping_cart)
49
+ self.shopping_cart = attributes[:ShoppingCart] || attributes[:shopping_cart]
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
+ o_auth_token == o.o_auth_token &&
66
+ shopping_cart == o.shopping_cart &&
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
+ [o_auth_token, shopping_cart, 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
+ :o_auth_token => 'String',
181
+ :shopping_cart => 'ShoppingCart',
182
+ :extension_point => 'ShoppingCartRequestExtensionPoint'
183
+
184
+ }
185
+ end
186
+ end
187
+
188
+
189
+ end