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,39 @@
1
+ require 'uri'
2
+ require 'mastercard_core_sdk'
3
+ require_relative '../../mastercard_masterpass_merchant/models/merchant_transactions'
4
+
5
+
6
+ module MastercardMasterpassMerchant
7
+ module Api
8
+
9
+ class PostbackApi
10
+ include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
11
+ include MastercardMasterpassMerchant::Tracker
12
+
13
+
14
+ # Postback Service
15
+ # This is the final step of MasterPass transaction. MasterPass transaction is a service call from the merchant to MasterPass,communicating the result of the transaction (success or failure). This is a mandatory step. Abandoned transactions do not need to be reported. The <TransactionId> value should be the value from the <TransactionId> element of the Checkout XML returned in the Checkout request.
16
+ # @param merchant_transactions Merchant transactions details.
17
+ # @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
18
+ # @return [MerchantTransactions]
19
+ def self.create(merchant_transactions, api_config = nil)
20
+ path = "/masterpass/v6/transaction"
21
+ service_request = ServiceRequest.new
22
+
23
+
24
+ service_request.body = merchant_transactions
25
+
26
+ service_request.content_type = "application/xml"
27
+ api_client = ApiClient.new(api_config)
28
+ api_client.api_tracker = SdkApiTracker.new
29
+ api_client.error_handler = ErrorHandler.new
30
+ return api_client.call(path, service_request, "POST",MerchantTransactions)
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
37
+
38
+
39
+
@@ -0,0 +1,42 @@
1
+ require 'uri'
2
+ require 'mastercard_core_sdk'
3
+ require_relative '../../mastercard_masterpass_merchant/models/precheckout_data_response'
4
+ require_relative '../../mastercard_masterpass_merchant/models/precheckout_data_request'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ module Api
9
+
10
+ class PrecheckoutDataApi
11
+ include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
12
+ include MastercardMasterpassMerchant::Tracker
13
+
14
+
15
+ # Precheckout Data Service.
16
+ # MasterPass provides merchants with the ability to request a paired consumer's data (card alias, shipping addresses, reward program, and profile information) prior to the actual MasterPass checkout. This gives the merchant the ability to provide the consumer the opportunity to preselect their checkout options before completing the checkout. If, for any reason, the precheckout call gets rejected at MasterPass (merchant requests data that the consumer did not originally consent to, if the pairing has been deleted by the user, if the Long Access token has expired, and so on), the merchant has to request pairing again.
17
+ # @param oauth_token Long access token, which is used to retrieve precheckout data.
18
+ # @param precheckout_data_request PreCheckout Data Request.
19
+ # @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
20
+ # @return [PrecheckoutDataResponse]
21
+ def self.create(oauth_token, precheckout_data_request, api_config = nil)
22
+ path = "/masterpass/v6/precheckout"
23
+ service_request = ServiceRequest.new
24
+
25
+ service_request.headers["oauth_token"] = oauth_token
26
+
27
+ service_request.body = precheckout_data_request
28
+
29
+ service_request.content_type = "application/xml"
30
+ api_client = ApiClient.new(api_config)
31
+ api_client.api_tracker = SdkApiTracker.new
32
+ api_client.error_handler = ErrorHandler.new
33
+ return api_client.call(path, service_request, "POST",PrecheckoutDataResponse)
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
40
+
41
+
42
+
@@ -0,0 +1,40 @@
1
+ require 'uri'
2
+ require 'mastercard_core_sdk'
3
+ require_relative '../../mastercard_masterpass_merchant/models/session_key_signing_response'
4
+ require_relative '../../mastercard_masterpass_merchant/models/session_key_signing_request'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ module Api
9
+
10
+ class SessionKeySigningApi
11
+ include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
12
+ include MastercardMasterpassMerchant::Tracker
13
+
14
+
15
+ # Session Key Signing
16
+ # Session Key Signing Android SDK.
17
+ # @param session_key_signing_request Session Key Signing request.
18
+ # @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
19
+ # @return [SessionKeySigningResponse]
20
+ def self.create(session_key_signing_request, api_config = nil)
21
+ path = "/masterpass/v6/sessionkeysigning"
22
+ service_request = ServiceRequest.new
23
+
24
+
25
+ service_request.body = session_key_signing_request
26
+
27
+ service_request.content_type = "application/xml"
28
+ api_client = ApiClient.new(api_config)
29
+ api_client.api_tracker = SdkApiTracker.new
30
+ api_client.error_handler = ErrorHandler.new
31
+ return api_client.call(path, service_request, "POST",SessionKeySigningResponse)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+
40
+
@@ -0,0 +1,40 @@
1
+ require 'uri'
2
+ require 'mastercard_core_sdk'
3
+ require_relative '../../mastercard_masterpass_merchant/models/shopping_cart_response'
4
+ require_relative '../../mastercard_masterpass_merchant/models/shopping_cart_request'
5
+
6
+
7
+ module MastercardMasterpassMerchant
8
+ module Api
9
+
10
+ class ShoppingCartApi
11
+ include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions
12
+ include MastercardMasterpassMerchant::Tracker
13
+
14
+
15
+ # ShoppingCart service
16
+ # This service used to enables shopping cart data to be displayed to users as they proceed through the MasterPass login and checkout.Merchants must call the Shopping Cart service before invoking the MasterPass UI for checkout.
17
+ # @param shopping_cart_request Shopping Cart Request.
18
+ # @param api_config Optional ApiConfig object specifying configuration : consumer key, private key, host URL.
19
+ # @return [ShoppingCartResponse]
20
+ def self.create(shopping_cart_request, api_config = nil)
21
+ path = "/masterpass/v6/shopping-cart"
22
+ service_request = ServiceRequest.new
23
+
24
+
25
+ service_request.body = shopping_cart_request
26
+
27
+ service_request.content_type = "application/xml"
28
+ api_client = ApiClient.new(api_config)
29
+ api_client.api_tracker = SdkApiTracker.new
30
+ api_client.error_handler = ErrorHandler.new
31
+ return api_client.call(path, service_request, "POST",ShoppingCartResponse)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+
40
+
@@ -0,0 +1,177 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/types'
4
+
5
+
6
+ module MastercardMasterpassMerchant
7
+ # This class contains methods to set acceptance options.
8
+ class AcceptanceOption
9
+ include ROXML
10
+
11
+ xml_name "AcceptanceOption"
12
+
13
+ # @!attribute brand_id
14
+ # @return [String] the brand id.
15
+ xml_accessor :brand_id, :from =>"BrandId"
16
+
17
+ # @!attribute types
18
+ # @return [Types] the types.
19
+ xml_accessor :types, :from =>"Types",:as => Types
20
+
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :brand_id => :BrandId ,
26
+ :types => :Types
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?(:BrandId) || attributes.has_key?(:brand_id)
39
+ self.brand_id = attributes[:BrandId] || attributes[:brand_id]
40
+ end
41
+
42
+ if attributes.has_key?(:Types) || attributes.has_key?(:types)
43
+ self.types = attributes[:Types] || attributes[:types]
44
+ end
45
+
46
+ end
47
+
48
+
49
+
50
+
51
+ # Check equality by comparing each attribute.
52
+ def ==(o)
53
+ return true if self.equal?(o)
54
+ self.class == o.class &&
55
+ brand_id == o.brand_id &&
56
+ types == o.types
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
+ [brand_id, types].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
+ :brand_id => 'String',
170
+ :types => 'Types'
171
+
172
+ }
173
+ end
174
+ end
175
+
176
+
177
+ end
@@ -0,0 +1,243 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/address_extension_point'
4
+
5
+
6
+ module MastercardMasterpassMerchant
7
+ # This class contains methods to get consumer address details.
8
+ class Address
9
+ include ROXML
10
+
11
+ xml_name "Address"
12
+
13
+ # @!attribute city
14
+ # @return [String] the cardholder's city.
15
+ xml_accessor :city, :from =>"City"
16
+
17
+ # @!attribute country
18
+ # @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.
19
+ xml_accessor :country, :from =>"Country"
20
+
21
+ # @!attribute country_subdivision
22
+ # @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
23
+ xml_accessor :country_subdivision, :from =>"CountrySubdivision"
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 line2
30
+ # @return [String] the address line 2 used for Apt Number, Suite Number, and so on.
31
+ xml_accessor :line2, :from =>"Line2"
32
+
33
+ # @!attribute line3
34
+ # @return [String] the address line 3 used to enter remaining address information if it does not fit in Line 1 and Line 2.
35
+ xml_accessor :line3, :from =>"Line3"
36
+
37
+ # @!attribute postal_code
38
+ # @return [String] the postal code or zip code appended to mailing address for the purpose of sorting mail.
39
+ xml_accessor :postal_code, :from =>"PostalCode"
40
+
41
+ # @!attribute extension_point
42
+ # @return [AddressExtensionPoint] the AddressExtensionPoint for additional information.
43
+ xml_accessor :extension_point, :from =>"ExtensionPoint",:as => AddressExtensionPoint
44
+
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :city => :City ,
50
+ :country => :Country ,
51
+ :country_subdivision => :CountrySubdivision ,
52
+ :line1 => :Line1 ,
53
+ :line2 => :Line2 ,
54
+ :line3 => :Line3 ,
55
+ :postal_code => :PostalCode ,
56
+ :extension_point => :ExtensionPoint
57
+
58
+ }
59
+ end
60
+
61
+ def initialize(attributes = {})
62
+ return unless attributes.is_a?(Hash)
63
+
64
+ # convert string to symbol for hash key
65
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
66
+
67
+
68
+ if attributes.has_key?(:City) || attributes.has_key?(:city)
69
+ self.city = attributes[:City] || attributes[:city]
70
+ end
71
+
72
+ if attributes.has_key?(:Country) || attributes.has_key?(:country)
73
+ self.country = attributes[:Country] || attributes[:country]
74
+ end
75
+
76
+ if attributes.has_key?(:CountrySubdivision) || attributes.has_key?(:country_subdivision)
77
+ self.country_subdivision = attributes[:CountrySubdivision] || attributes[:country_subdivision]
78
+ end
79
+
80
+ if attributes.has_key?(:Line1) || attributes.has_key?(:line1)
81
+ self.line1 = attributes[:Line1] || attributes[:line1]
82
+ end
83
+
84
+ if attributes.has_key?(:Line2) || attributes.has_key?(:line2)
85
+ self.line2 = attributes[:Line2] || attributes[:line2]
86
+ end
87
+
88
+ if attributes.has_key?(:Line3) || attributes.has_key?(:line3)
89
+ self.line3 = attributes[:Line3] || attributes[:line3]
90
+ end
91
+
92
+ if attributes.has_key?(:PostalCode) || attributes.has_key?(:postal_code)
93
+ self.postal_code = attributes[:PostalCode] || attributes[:postal_code]
94
+ end
95
+
96
+ if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
97
+ self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
98
+ end
99
+
100
+ end
101
+
102
+
103
+
104
+
105
+ # Check equality by comparing each attribute.
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ city == o.city &&
110
+ country == o.country &&
111
+ country_subdivision == o.country_subdivision &&
112
+ line1 == o.line1 &&
113
+ line2 == o.line2 &&
114
+ line3 == o.line3 &&
115
+ postal_code == o.postal_code &&
116
+ extension_point == o.extension_point
117
+ end
118
+
119
+ # @see the `==` method
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculate hash code according to all attributes.
125
+ def hash
126
+ [city, country, country_subdivision, line1, line2, line3, postal_code, extension_point].hash
127
+ end
128
+
129
+ # build the object from hash
130
+ def build_from_hash(attributes)
131
+ return nil unless attributes.is_a?(Hash)
132
+ self.class.datatype_map.each_pair do |key, type|
133
+ if type =~ /^Array<(.*)>/i
134
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
135
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
136
+ else
137
+ #TODO show warning in debug mode
138
+ end
139
+ elsif !attributes[self.class.attribute_map[key]].nil?
140
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
141
+ else
142
+ # data not found in attributes(hash), not an issue as the data can be optional
143
+ end
144
+ end
145
+
146
+ self
147
+ end
148
+
149
+ def _deserialize(type, value)
150
+ case type.to_sym
151
+ when :DateTime
152
+ DateTime.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :BOOLEAN
162
+ if value =~ /^(true|t|yes|y|1)$/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ _model = MastercardMasterpassMerchant.const_get(type).new
180
+ _model.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_body (backward compatibility))
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # return the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ next if value.nil?
199
+ hash[param] = _to_hash(value)
200
+ end
201
+ hash
202
+ end
203
+
204
+ # Method to output non-array value in the form of hash
205
+ # For object, use to_hash. Otherwise, just return the value
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map{ |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to? :to_hash
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+
220
+
221
+ private
222
+ def after_parse
223
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
224
+ end
225
+
226
+ # Attribute datatype mapping.
227
+ def self.datatype_map
228
+ {
229
+ :city => 'String',
230
+ :country => 'String',
231
+ :country_subdivision => 'String',
232
+ :line1 => 'String',
233
+ :line2 => 'String',
234
+ :line3 => 'String',
235
+ :postal_code => 'String',
236
+ :extension_point => 'AddressExtensionPoint'
237
+
238
+ }
239
+ end
240
+ end
241
+
242
+
243
+ end