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,163 @@
1
+ require 'date'
2
+ require 'roxml'
3
+
4
+
5
+ module MastercardMasterpassMerchant
6
+ # This class contains methods require to set additional details.
7
+ class ExtensionPoint
8
+ include ROXML
9
+
10
+ xml_name "ExtensionPoint"
11
+
12
+ xml_accessor :any, :from =>"any"
13
+
14
+
15
+ # Attribute mapping from ruby-style variable name to JSON key.
16
+ def self.attribute_map
17
+ {
18
+ :any => :any
19
+
20
+ }
21
+ end
22
+
23
+ def initialize(attributes = {})
24
+ return unless attributes.is_a?(Hash)
25
+
26
+ # convert string to symbol for hash key
27
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
28
+
29
+
30
+ if attributes.has_key?(:any) || attributes.has_key?(:any)
31
+ self.any = attributes[:any] || attributes[:any]
32
+ end
33
+
34
+ end
35
+
36
+
37
+
38
+
39
+ # Check equality by comparing each attribute.
40
+ def ==(o)
41
+ return true if self.equal?(o)
42
+ self.class == o.class &&
43
+ any == o.any
44
+ end
45
+
46
+ # @see the `==` method
47
+ def eql?(o)
48
+ self == o
49
+ end
50
+
51
+ # Calculate hash code according to all attributes.
52
+ def hash
53
+ [any].hash
54
+ end
55
+
56
+ # build the object from hash
57
+ def build_from_hash(attributes)
58
+ return nil unless attributes.is_a?(Hash)
59
+ self.class.datatype_map.each_pair do |key, type|
60
+ if type =~ /^Array<(.*)>/i
61
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
62
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
63
+ else
64
+ #TODO show warning in debug mode
65
+ end
66
+ elsif !attributes[self.class.attribute_map[key]].nil?
67
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
68
+ else
69
+ # data not found in attributes(hash), not an issue as the data can be optional
70
+ end
71
+ end
72
+
73
+ self
74
+ end
75
+
76
+ def _deserialize(type, value)
77
+ case type.to_sym
78
+ when :DateTime
79
+ DateTime.parse(value)
80
+ when :Date
81
+ Date.parse(value)
82
+ when :String
83
+ value.to_s
84
+ when :Integer
85
+ value.to_i
86
+ when :Float
87
+ value.to_f
88
+ when :BOOLEAN
89
+ if value =~ /^(true|t|yes|y|1)$/i
90
+ true
91
+ else
92
+ false
93
+ end
94
+ when /\AArray<(?<inner_type>.+)>\z/
95
+ inner_type = Regexp.last_match[:inner_type]
96
+ value.map { |v| _deserialize(inner_type, v) }
97
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
98
+ k_type = Regexp.last_match[:k_type]
99
+ v_type = Regexp.last_match[:v_type]
100
+ {}.tap do |hash|
101
+ value.each do |k, v|
102
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
103
+ end
104
+ end
105
+ else # model
106
+ _model = MastercardMasterpassMerchant.const_get(type).new
107
+ _model.build_from_hash(value)
108
+ end
109
+ end
110
+
111
+ def to_s
112
+ to_hash.to_s
113
+ end
114
+
115
+ # to_body is an alias to to_body (backward compatibility))
116
+ def to_body
117
+ to_hash
118
+ end
119
+
120
+ # return the object in the form of hash
121
+ def to_hash
122
+ hash = {}
123
+ self.class.attribute_map.each_pair do |attr, param|
124
+ value = self.send(attr)
125
+ next if value.nil?
126
+ hash[param] = _to_hash(value)
127
+ end
128
+ hash
129
+ end
130
+
131
+ # Method to output non-array value in the form of hash
132
+ # For object, use to_hash. Otherwise, just return the value
133
+ def _to_hash(value)
134
+ if value.is_a?(Array)
135
+ value.compact.map{ |v| _to_hash(v) }
136
+ elsif value.is_a?(Hash)
137
+ {}.tap do |hash|
138
+ value.each { |k, v| hash[k] = _to_hash(v) }
139
+ end
140
+ elsif value.respond_to? :to_hash
141
+ value.to_hash
142
+ else
143
+ value
144
+ end
145
+ end
146
+
147
+
148
+ private
149
+ def after_parse
150
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
151
+ end
152
+
153
+ # Attribute datatype mapping.
154
+ def self.datatype_map
155
+ {
156
+ :any => 'Object'
157
+
158
+ }
159
+ end
160
+ end
161
+
162
+
163
+ end
@@ -0,0 +1,221 @@
1
+ require 'date'
2
+ require 'roxml'
3
+ require_relative '../../mastercard_masterpass_merchant/models/brands'
4
+ require_relative '../../mastercard_masterpass_merchant/models/installment_options'
5
+ require_relative '../../mastercard_masterpass_merchant/models/issuers'
6
+
7
+
8
+ module MastercardMasterpassMerchant
9
+ # This class contains methods regarding installment.
10
+ class Installment
11
+ include ROXML
12
+
13
+ xml_name "Installment"
14
+
15
+ # @!attribute brands
16
+ # @return [Brands] the brand details.
17
+ xml_accessor :brands, :from =>"Brands",:as => Brands
18
+
19
+ # @!attribute issuers
20
+ # @return [Issuers] the issuers details.
21
+ xml_accessor :issuers, :from =>"Issuers",:as => Issuers
22
+
23
+ # @!attribute currency_code
24
+ # @return [String] the currency code.
25
+ xml_accessor :currency_code, :from =>"CurrencyCode"
26
+
27
+ # @!attribute shipping_calculation
28
+ # @return [String] the shipping calculation types.
29
+ xml_accessor :shipping_calculation, :from =>"ShippingCalculation"
30
+
31
+ # @!attribute installment_options
32
+ # @return [InstallmentOptions] the installment options.
33
+ xml_accessor :installment_options, :from =>"InstallmentOptions",:as => InstallmentOptions
34
+
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :brands => :Brands ,
40
+ :issuers => :Issuers ,
41
+ :currency_code => :CurrencyCode ,
42
+ :shipping_calculation => :ShippingCalculation ,
43
+ :installment_options => :InstallmentOptions
44
+
45
+ }
46
+ end
47
+
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
53
+
54
+
55
+ if attributes.has_key?(:Brands) || attributes.has_key?(:brands)
56
+ self.brands = attributes[:Brands] || attributes[:brands]
57
+ end
58
+
59
+ if attributes.has_key?(:Issuers) || attributes.has_key?(:issuers)
60
+ self.issuers = attributes[:Issuers] || attributes[:issuers]
61
+ end
62
+
63
+ if attributes.has_key?(:CurrencyCode) || attributes.has_key?(:currency_code)
64
+ self.currency_code = attributes[:CurrencyCode] || attributes[:currency_code]
65
+ end
66
+
67
+ if attributes.has_key?(:ShippingCalculation) || attributes.has_key?(:shipping_calculation)
68
+ self.shipping_calculation = attributes[:ShippingCalculation] || attributes[:shipping_calculation]
69
+ end
70
+
71
+ if attributes.has_key?(:InstallmentOptions) || attributes.has_key?(:installment_options)
72
+ self.installment_options = attributes[:InstallmentOptions] || attributes[:installment_options]
73
+ end
74
+
75
+ end
76
+
77
+
78
+
79
+
80
+ # Custom attribute writer method checking allowed values (enum).
81
+ def shipping_calculation=(shipping_calculation)
82
+ allowed_values = ["FREE_SHIPPING", "SHIPPING_INCLUDED", "SHIPPING_NOT_INCLUDED"]
83
+ if shipping_calculation && !allowed_values.include?(shipping_calculation)
84
+ fail "invalid value for 'shipping_calculation', must be one of #{allowed_values}"
85
+ end
86
+ @shipping_calculation = shipping_calculation
87
+ end
88
+
89
+ # Check equality by comparing each attribute.
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ brands == o.brands &&
94
+ issuers == o.issuers &&
95
+ currency_code == o.currency_code &&
96
+ shipping_calculation == o.shipping_calculation &&
97
+ installment_options == o.installment_options
98
+ end
99
+
100
+ # @see the `==` method
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculate hash code according to all attributes.
106
+ def hash
107
+ [brands, issuers, currency_code, shipping_calculation, installment_options].hash
108
+ end
109
+
110
+ # build the object from hash
111
+ def build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ self.class.datatype_map.each_pair do |key, type|
114
+ if type =~ /^Array<(.*)>/i
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
117
+ else
118
+ #TODO show warning in debug mode
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ else
123
+ # data not found in attributes(hash), not an issue as the data can be optional
124
+ end
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ def _deserialize(type, value)
131
+ case type.to_sym
132
+ when :DateTime
133
+ DateTime.parse(value)
134
+ when :Date
135
+ Date.parse(value)
136
+ when :String
137
+ value.to_s
138
+ when :Integer
139
+ value.to_i
140
+ when :Float
141
+ value.to_f
142
+ when :BOOLEAN
143
+ if value =~ /^(true|t|yes|y|1)$/i
144
+ true
145
+ else
146
+ false
147
+ end
148
+ when /\AArray<(?<inner_type>.+)>\z/
149
+ inner_type = Regexp.last_match[:inner_type]
150
+ value.map { |v| _deserialize(inner_type, v) }
151
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
152
+ k_type = Regexp.last_match[:k_type]
153
+ v_type = Regexp.last_match[:v_type]
154
+ {}.tap do |hash|
155
+ value.each do |k, v|
156
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
157
+ end
158
+ end
159
+ else # model
160
+ _model = MastercardMasterpassMerchant.const_get(type).new
161
+ _model.build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ def to_s
166
+ to_hash.to_s
167
+ end
168
+
169
+ # to_body is an alias to to_body (backward compatibility))
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # return the object in the form of hash
175
+ def to_hash
176
+ hash = {}
177
+ self.class.attribute_map.each_pair do |attr, param|
178
+ value = self.send(attr)
179
+ next if value.nil?
180
+ hash[param] = _to_hash(value)
181
+ end
182
+ hash
183
+ end
184
+
185
+ # Method to output non-array value in the form of hash
186
+ # For object, use to_hash. Otherwise, just return the value
187
+ def _to_hash(value)
188
+ if value.is_a?(Array)
189
+ value.compact.map{ |v| _to_hash(v) }
190
+ elsif value.is_a?(Hash)
191
+ {}.tap do |hash|
192
+ value.each { |k, v| hash[k] = _to_hash(v) }
193
+ end
194
+ elsif value.respond_to? :to_hash
195
+ value.to_hash
196
+ else
197
+ value
198
+ end
199
+ end
200
+
201
+
202
+ private
203
+ def after_parse
204
+ self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
205
+ end
206
+
207
+ # Attribute datatype mapping.
208
+ def self.datatype_map
209
+ {
210
+ :brands => 'Brands',
211
+ :issuers => 'Issuers',
212
+ :currency_code => 'String',
213
+ :shipping_calculation => 'String',
214
+ :installment_options => 'InstallmentOptions'
215
+
216
+ }
217
+ end
218
+ end
219
+
220
+
221
+ end
@@ -0,0 +1,198 @@
1
+ require 'date'
2
+ require 'roxml'
3
+
4
+
5
+ module MastercardMasterpassMerchant
6
+ # This class contains methods require to set installment details.
7
+ class InstallmentOption
8
+ include ROXML
9
+
10
+ xml_name "InstallmentOption"
11
+
12
+ # @!attribute number_of_installments
13
+ # @return [Integer] the number of installments.
14
+ xml_accessor :number_of_installments, :from =>"NumberOfInstallments"
15
+
16
+ # @!attribute price_per_installment
17
+ # @return [Integer] the price per installment.
18
+ xml_accessor :price_per_installment, :from =>"PricePerInstallment"
19
+
20
+ # @!attribute interest_rate
21
+ # @return [String] the interest rate.
22
+ xml_accessor :interest_rate, :from =>"InterestRate"
23
+
24
+ # @!attribute currency_code
25
+ # @return [String] the currency code.
26
+ xml_accessor :currency_code, :from =>"CurrencyCode"
27
+
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :number_of_installments => :NumberOfInstallments ,
33
+ :price_per_installment => :PricePerInstallment ,
34
+ :interest_rate => :InterestRate ,
35
+ :currency_code => :CurrencyCode
36
+
37
+ }
38
+ end
39
+
40
+ def initialize(attributes = {})
41
+ return unless attributes.is_a?(Hash)
42
+
43
+ # convert string to symbol for hash key
44
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
45
+
46
+
47
+ if attributes.has_key?(:NumberOfInstallments) || attributes.has_key?(:number_of_installments)
48
+ self.number_of_installments = attributes[:NumberOfInstallments] || attributes[:number_of_installments]
49
+ end
50
+
51
+ if attributes.has_key?(:PricePerInstallment) || attributes.has_key?(:price_per_installment)
52
+ self.price_per_installment = attributes[:PricePerInstallment] || attributes[:price_per_installment]
53
+ end
54
+
55
+ if attributes.has_key?(:InterestRate) || attributes.has_key?(:interest_rate)
56
+ self.interest_rate = attributes[:InterestRate] || attributes[:interest_rate]
57
+ end
58
+
59
+ if attributes.has_key?(:CurrencyCode) || attributes.has_key?(:currency_code)
60
+ self.currency_code = attributes[:CurrencyCode] || attributes[:currency_code]
61
+ end
62
+
63
+ end
64
+
65
+
66
+
67
+
68
+ # Check equality by comparing each attribute.
69
+ def ==(o)
70
+ return true if self.equal?(o)
71
+ self.class == o.class &&
72
+ number_of_installments == o.number_of_installments &&
73
+ price_per_installment == o.price_per_installment &&
74
+ interest_rate == o.interest_rate &&
75
+ currency_code == o.currency_code
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
+ [number_of_installments, price_per_installment, interest_rate, currency_code].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
+ :number_of_installments => 'Integer',
189
+ :price_per_installment => 'Integer',
190
+ :interest_rate => 'String',
191
+ :currency_code => 'String'
192
+
193
+ }
194
+ end
195
+ end
196
+
197
+
198
+ end