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,199 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/extension_point'
4
+
5
+
6
+ module MastercardMasterpassMerchant
7
+ # the decryption service request for android SDK.
8
+ class SessionKeySigningRequest
9
+ include ROXML
10
+
11
+ xml_name "SessionKeySigningRequest"
12
+
13
+ # @!attribute app_id
14
+ # @return [String] the AppId details.
15
+ xml_accessor :app_id, :from =>"AppId"
16
+
17
+ # @!attribute app_version
18
+ # @return [String] the AppVersion details.
19
+ xml_accessor :app_version, :from =>"AppVersion"
20
+
21
+ # @!attribute app_signing_public_key
22
+ # @return [String] the AppSigningPublicKey details.
23
+ xml_accessor :app_signing_public_key, :from =>"AppSigningPublicKey"
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
+ :app_id => :AppId ,
34
+ :app_version => :AppVersion ,
35
+ :app_signing_public_key => :AppSigningPublicKey ,
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?(:AppId) || attributes.has_key?(:app_id)
49
+ self.app_id = attributes[:AppId] || attributes[:app_id]
50
+ end
51
+
52
+ if attributes.has_key?(:AppVersion) || attributes.has_key?(:app_version)
53
+ self.app_version = attributes[:AppVersion] || attributes[:app_version]
54
+ end
55
+
56
+ if attributes.has_key?(:AppSigningPublicKey) || attributes.has_key?(:app_signing_public_key)
57
+ self.app_signing_public_key = attributes[:AppSigningPublicKey] || attributes[:app_signing_public_key]
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
+ app_id == o.app_id &&
74
+ app_version == o.app_version &&
75
+ app_signing_public_key == o.app_signing_public_key &&
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
+ [app_id, app_version, app_signing_public_key, 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
+ :app_id => 'String',
190
+ :app_version => 'String',
191
+ :app_signing_public_key => 'String',
192
+ :extension_point => 'ExtensionPoint'
193
+
194
+ }
195
+ end
196
+ end
197
+
198
+
199
+ 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
+ # the decryption service response for android SDK.
8
+ class SessionKeySigningResponse
9
+ include ROXML
10
+
11
+ xml_name "SessionKeySigningResponse"
12
+
13
+ # @!attribute app_id
14
+ # @return [String] the AppId details.
15
+ xml_accessor :app_id, :from =>"AppId"
16
+
17
+ # @!attribute app_version
18
+ # @return [String] the AppVersion details.
19
+ xml_accessor :app_version, :from =>"AppVersion"
20
+
21
+ # @!attribute app_signing_public_key
22
+ # @return [String] the AppSigningPublicKey details.
23
+ xml_accessor :app_signing_public_key, :from =>"AppSigningPublicKey"
24
+
25
+ # @!attribute session_signature
26
+ # @return [String] the SessionSignature details.
27
+ xml_accessor :session_signature, :from =>"SessionSignature"
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
+ :app_id => :AppId ,
38
+ :app_version => :AppVersion ,
39
+ :app_signing_public_key => :AppSigningPublicKey ,
40
+ :session_signature => :SessionSignature ,
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?(:AppId) || attributes.has_key?(:app_id)
54
+ self.app_id = attributes[:AppId] || attributes[:app_id]
55
+ end
56
+
57
+ if attributes.has_key?(:AppVersion) || attributes.has_key?(:app_version)
58
+ self.app_version = attributes[:AppVersion] || attributes[:app_version]
59
+ end
60
+
61
+ if attributes.has_key?(:AppSigningPublicKey) || attributes.has_key?(:app_signing_public_key)
62
+ self.app_signing_public_key = attributes[:AppSigningPublicKey] || attributes[:app_signing_public_key]
63
+ end
64
+
65
+ if attributes.has_key?(:SessionSignature) || attributes.has_key?(:session_signature)
66
+ self.session_signature = attributes[:SessionSignature] || attributes[:session_signature]
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
+ app_id == o.app_id &&
83
+ app_version == o.app_version &&
84
+ app_signing_public_key == o.app_signing_public_key &&
85
+ session_signature == o.session_signature &&
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
+ [app_id, app_version, app_signing_public_key, session_signature, 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
+ :app_id => 'String',
200
+ :app_version => 'String',
201
+ :app_signing_public_key => 'String',
202
+ :session_signature => 'String',
203
+ :extension_point => 'ExtensionPoint'
204
+
205
+ }
206
+ end
207
+ end
208
+
209
+
210
+ end
@@ -0,0 +1,265 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/address'
4
+ require_relative '../../mastercard_masterpass_merchant/models/address_extension_point'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ class ShippingAddress
9
+ include ROXML
10
+
11
+ xml_name "ShippingAddress"
12
+
13
+ # @!attribute recipient_phone_number
14
+ # @return [String] the phone number of the person set to receive the shipped order.
15
+ xml_accessor :recipient_phone_number, :from =>"RecipientPhoneNumber"
16
+
17
+ # @!attribute line3
18
+ # @return [String] the address line 3 used to enter remaining address information if it does not fit in Line 1 and Line 2.
19
+ xml_accessor :line3, :from =>"Line3"
20
+
21
+ # @!attribute line2
22
+ # @return [String] the address line 2 used for Apt Number, Suite Number, and so on.
23
+ xml_accessor :line2, :from =>"Line2"
24
+
25
+ # @!attribute line1
26
+ # @return [String] the address line 1 used for Street number and Street Name.
27
+ xml_accessor :line1, :from =>"Line1"
28
+
29
+ # @!attribute postal_code
30
+ # @return [String] the postal code or zip code appended to mailing address for the purpose of sorting mail.
31
+ xml_accessor :postal_code, :from =>"PostalCode"
32
+
33
+ # @!attribute country_subdivision
34
+ # @return [String] the cardholder's country subdivision. Defined by ISO 3166-1 alpha-2 digit code, for example, US-VA is Virginia, US-OH is Ohio
35
+ xml_accessor :country_subdivision, :from =>"CountrySubdivision"
36
+
37
+ # @!attribute recipient_name
38
+ # @return [String] the name of person set to receive the shipped order.
39
+ xml_accessor :recipient_name, :from =>"RecipientName"
40
+
41
+ # @!attribute extension_point
42
+ # @return [AddressExtensionPoint] the AddressExtensionPoint for additional information.
43
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => AddressExtensionPoint
44
+
45
+ # @!attribute country
46
+ # @return [String] the cardholder's country. Defined by ISO 3166-1 alpha-2 digit country codes, for example, US is United States, AU is Australia, CA is Canada, GB is United Kingdom, and so on.
47
+ xml_accessor :country, :from =>"Country"
48
+
49
+ # @!attribute city
50
+ # @return [String] the cardholder's city.
51
+ xml_accessor :city, :from =>"City"
52
+
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :recipient_phone_number => :RecipientPhoneNumber ,
58
+ :line3 => :Line3 ,
59
+ :line2 => :Line2 ,
60
+ :line1 => :Line1 ,
61
+ :postal_code => :PostalCode ,
62
+ :country_subdivision => :CountrySubdivision ,
63
+ :recipient_name => :RecipientName ,
64
+ :extension_point => :ExtensionPoint ,
65
+ :country => :Country ,
66
+ :city => :City
67
+
68
+ }
69
+ end
70
+
71
+ def initialize(attributes = {})
72
+ return unless attributes.is_a?(Hash)
73
+
74
+ # convert string to symbol for hash key
75
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
76
+
77
+
78
+ if attributes.has_key?(:RecipientPhoneNumber) || attributes.has_key?(:recipient_phone_number)
79
+ self.recipient_phone_number = attributes[:RecipientPhoneNumber] || attributes[:recipient_phone_number]
80
+ end
81
+
82
+ if attributes.has_key?(:Line3) || attributes.has_key?(:line3)
83
+ self.line3 = attributes[:Line3] || attributes[:line3]
84
+ end
85
+
86
+ if attributes.has_key?(:Line2) || attributes.has_key?(:line2)
87
+ self.line2 = attributes[:Line2] || attributes[:line2]
88
+ end
89
+
90
+ if attributes.has_key?(:Line1) || attributes.has_key?(:line1)
91
+ self.line1 = attributes[:Line1] || attributes[:line1]
92
+ end
93
+
94
+ if attributes.has_key?(:PostalCode) || attributes.has_key?(:postal_code)
95
+ self.postal_code = attributes[:PostalCode] || attributes[:postal_code]
96
+ end
97
+
98
+ if attributes.has_key?(:CountrySubdivision) || attributes.has_key?(:country_subdivision)
99
+ self.country_subdivision = attributes[:CountrySubdivision] || attributes[:country_subdivision]
100
+ end
101
+
102
+ if attributes.has_key?(:RecipientName) || attributes.has_key?(:recipient_name)
103
+ self.recipient_name = attributes[:RecipientName] || attributes[:recipient_name]
104
+ end
105
+
106
+ if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
107
+ self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
108
+ end
109
+
110
+ if attributes.has_key?(:Country) || attributes.has_key?(:country)
111
+ self.country = attributes[:Country] || attributes[:country]
112
+ end
113
+
114
+ if attributes.has_key?(:City) || attributes.has_key?(:city)
115
+ self.city = attributes[:City] || attributes[:city]
116
+ end
117
+
118
+ end
119
+
120
+
121
+
122
+
123
+ # Check equality by comparing each attribute.
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ recipient_phone_number == o.recipient_phone_number &&
128
+ line3 == o.line3 &&
129
+ line2 == o.line2 &&
130
+ line1 == o.line1 &&
131
+ postal_code == o.postal_code &&
132
+ country_subdivision == o.country_subdivision &&
133
+ recipient_name == o.recipient_name &&
134
+ extension_point == o.extension_point &&
135
+ country == o.country &&
136
+ city == o.city
137
+ end
138
+
139
+ # @see the `==` method
140
+ def eql?(o)
141
+ self == o
142
+ end
143
+
144
+ # Calculate hash code according to all attributes.
145
+ def hash
146
+ [recipient_phone_number, line3, line2, line1, postal_code, country_subdivision, recipient_name, extension_point, country, city].hash
147
+ end
148
+
149
+ # build the object from hash
150
+ def build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+ self.class.datatype_map.each_pair do |key, type|
153
+ if type =~ /^Array<(.*)>/i
154
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
155
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
156
+ else
157
+ #TODO show warning in debug mode
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ else
162
+ # data not found in attributes(hash), not an issue as the data can be optional
163
+ end
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ def _deserialize(type, value)
170
+ case type.to_sym
171
+ when :DateTime
172
+ DateTime.parse(value)
173
+ when :Date
174
+ Date.parse(value)
175
+ when :String
176
+ value.to_s
177
+ when :Integer
178
+ value.to_i
179
+ when :Float
180
+ value.to_f
181
+ when :BOOLEAN
182
+ if value =~ /^(true|t|yes|y|1)$/i
183
+ true
184
+ else
185
+ false
186
+ end
187
+ when /\AArray<(?<inner_type>.+)>\z/
188
+ inner_type = Regexp.last_match[:inner_type]
189
+ value.map { |v| _deserialize(inner_type, v) }
190
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
191
+ k_type = Regexp.last_match[:k_type]
192
+ v_type = Regexp.last_match[:v_type]
193
+ {}.tap do |hash|
194
+ value.each do |k, v|
195
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
196
+ end
197
+ end
198
+ else # model
199
+ _model = MastercardMasterpassMerchant.const_get(type).new
200
+ _model.build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_body (backward compatibility))
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # return the object in the form of hash
214
+ def to_hash
215
+ hash = {}
216
+ self.class.attribute_map.each_pair do |attr, param|
217
+ value = self.send(attr)
218
+ next if value.nil?
219
+ hash[param] = _to_hash(value)
220
+ end
221
+ hash
222
+ end
223
+
224
+ # Method to output non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map{ |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+
240
+
241
+ private
242
+ def after_parse
243
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
244
+ end
245
+
246
+ # Attribute datatype mapping.
247
+ def self.datatype_map
248
+ {
249
+ :recipient_phone_number => 'String',
250
+ :line3 => 'String',
251
+ :line2 => 'String',
252
+ :line1 => 'String',
253
+ :postal_code => 'String',
254
+ :country_subdivision => 'String',
255
+ :recipient_name => 'String',
256
+ :extension_point => 'AddressExtensionPoint',
257
+ :country => 'String',
258
+ :city => 'String'
259
+
260
+ }
261
+ end
262
+ end
263
+
264
+
265
+ end