mastercard_masterpass_merchant 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +24 -0
- data/README.md +74 -0
- data/lib/mastercard_masterpass_merchant.rb +182 -0
- data/lib/mastercard_masterpass_merchant/api/checkout_api.rb +41 -0
- data/lib/mastercard_masterpass_merchant/api/decryption_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/api/express_checkout_api.rb +42 -0
- data/lib/mastercard_masterpass_merchant/api/merchant_initialization_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/api/postback_api.rb +39 -0
- data/lib/mastercard_masterpass_merchant/api/precheckout_data_api.rb +42 -0
- data/lib/mastercard_masterpass_merchant/api/session_key_signing_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/api/shopping_cart_api.rb +40 -0
- data/lib/mastercard_masterpass_merchant/models/acceptance_option.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/address.rb +243 -0
- data/lib/mastercard_masterpass_merchant/models/address_extension_point.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/authentication_options.rb +265 -0
- data/lib/mastercard_masterpass_merchant/models/base_card.rb +221 -0
- data/lib/mastercard_masterpass_merchant/models/brands.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/card.rb +244 -0
- data/lib/mastercard_masterpass_merchant/models/card_extension.rb +189 -0
- data/lib/mastercard_masterpass_merchant/models/card_type.rb +174 -0
- data/lib/mastercard_masterpass_merchant/models/card_types.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/checkout.rb +259 -0
- data/lib/mastercard_masterpass_merchant/models/checkout_dsrp.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/checkout_extension.rb +259 -0
- data/lib/mastercard_masterpass_merchant/models/contact.rb +275 -0
- data/lib/mastercard_masterpass_merchant/models/date_of_birth.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/decryption_request.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/decryption_response.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/detail.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/details.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/dsrp.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/dsrp_extension.rb +189 -0
- data/lib/mastercard_masterpass_merchant/models/dsrp_options.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/error.rb +222 -0
- data/lib/mastercard_masterpass_merchant/models/errors.rb +174 -0
- data/lib/mastercard_masterpass_merchant/models/express_checkout_request.rb +276 -0
- data/lib/mastercard_masterpass_merchant/models/express_checkout_response.rb +201 -0
- data/lib/mastercard_masterpass_merchant/models/extension_point.rb +163 -0
- data/lib/mastercard_masterpass_merchant/models/installment.rb +221 -0
- data/lib/mastercard_masterpass_merchant/models/installment_option.rb +198 -0
- data/lib/mastercard_masterpass_merchant/models/installment_options.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/installments.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/issuers.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_extension.rb +201 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_request.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_response.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_initialization_response_extension.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_transaction.rb +274 -0
- data/lib/mastercard_masterpass_merchant/models/merchant_transactions.rb +176 -0
- data/lib/mastercard_masterpass_merchant/models/option.rb +197 -0
- data/lib/mastercard_masterpass_merchant/models/pairing_data_type.rb +186 -0
- data/lib/mastercard_masterpass_merchant/models/pairing_data_types.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/payment_acceptance.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/payment_acceptance_types_extension.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/payment_options_extensions.rb +178 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_card.rb +288 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_cards.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_data.rb +259 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_data_request.rb +178 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_data_response.rb +211 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_reward_program.rb +243 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_shipping_address.rb +298 -0
- data/lib/mastercard_masterpass_merchant/models/precheckout_shipping_addresses.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/private_data.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/private_datas.rb +166 -0
- data/lib/mastercard_masterpass_merchant/models/reward_program.rb +221 -0
- data/lib/mastercard_masterpass_merchant/models/reward_programs.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/risk_decisioning.rb +178 -0
- data/lib/mastercard_masterpass_merchant/models/session_key_signing_request.rb +199 -0
- data/lib/mastercard_masterpass_merchant/models/session_key_signing_response.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/shipping_address.rb +265 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_item.rb +210 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_request.rb +189 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_request_extension_point.rb +165 -0
- data/lib/mastercard_masterpass_merchant/models/shopping_cart_response.rb +177 -0
- data/lib/mastercard_masterpass_merchant/models/tokenization.rb +188 -0
- data/lib/mastercard_masterpass_merchant/models/types.rb +174 -0
- data/lib/mastercard_masterpass_merchant/models/wallet.rb +177 -0
- data/lib/mastercard_masterpass_merchant/tracker/sdk_api_tracker.rb +57 -0
- data/lib/mastercard_masterpass_merchant/version.rb +3 -0
- metadata +240 -0
@@ -0,0 +1,221 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
|
5
|
+
|
6
|
+
module MastercardMasterpassMerchant
|
7
|
+
# This class contains methods to get consumer reward program details.
|
8
|
+
class RewardProgram
|
9
|
+
include ROXML
|
10
|
+
|
11
|
+
xml_name "RewardProgram"
|
12
|
+
|
13
|
+
# @!attribute reward_number
|
14
|
+
# @return [String] the reward number.
|
15
|
+
xml_accessor :reward_number, :from =>"RewardNumber"
|
16
|
+
|
17
|
+
# @!attribute reward_id
|
18
|
+
# @return [String] the reward Id.
|
19
|
+
xml_accessor :reward_id, :from =>"RewardId"
|
20
|
+
|
21
|
+
# @!attribute reward_name
|
22
|
+
# @return [String] the reward name.
|
23
|
+
xml_accessor :reward_name, :from =>"RewardName"
|
24
|
+
|
25
|
+
# @!attribute expiry_month
|
26
|
+
# @return [Integer] the expiry month.
|
27
|
+
xml_accessor :expiry_month, :from =>"ExpiryMonth"
|
28
|
+
|
29
|
+
# @!attribute expiry_year
|
30
|
+
# @return [Integer] the expiry year.
|
31
|
+
xml_accessor :expiry_year, :from =>"ExpiryYear"
|
32
|
+
|
33
|
+
# @!attribute extension_point
|
34
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
35
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
36
|
+
|
37
|
+
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
39
|
+
def self.attribute_map
|
40
|
+
{
|
41
|
+
:reward_number => :RewardNumber ,
|
42
|
+
:reward_id => :RewardId ,
|
43
|
+
:reward_name => :RewardName ,
|
44
|
+
:expiry_month => :ExpiryMonth ,
|
45
|
+
:expiry_year => :ExpiryYear ,
|
46
|
+
:extension_point => :ExtensionPoint
|
47
|
+
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize(attributes = {})
|
52
|
+
return unless attributes.is_a?(Hash)
|
53
|
+
|
54
|
+
# convert string to symbol for hash key
|
55
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
56
|
+
|
57
|
+
|
58
|
+
if attributes.has_key?(:RewardNumber) || attributes.has_key?(:reward_number)
|
59
|
+
self.reward_number = attributes[:RewardNumber] || attributes[:reward_number]
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:RewardId) || attributes.has_key?(:reward_id)
|
63
|
+
self.reward_id = attributes[:RewardId] || attributes[:reward_id]
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:RewardName) || attributes.has_key?(:reward_name)
|
67
|
+
self.reward_name = attributes[:RewardName] || attributes[:reward_name]
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:ExpiryMonth) || attributes.has_key?(:expiry_month)
|
71
|
+
self.expiry_month = attributes[:ExpiryMonth] || attributes[:expiry_month]
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.has_key?(:ExpiryYear) || attributes.has_key?(:expiry_year)
|
75
|
+
self.expiry_year = attributes[:ExpiryYear] || attributes[:expiry_year]
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
79
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
# Check equality by comparing each attribute.
|
88
|
+
def ==(o)
|
89
|
+
return true if self.equal?(o)
|
90
|
+
self.class == o.class &&
|
91
|
+
reward_number == o.reward_number &&
|
92
|
+
reward_id == o.reward_id &&
|
93
|
+
reward_name == o.reward_name &&
|
94
|
+
expiry_month == o.expiry_month &&
|
95
|
+
expiry_year == o.expiry_year &&
|
96
|
+
extension_point == o.extension_point
|
97
|
+
end
|
98
|
+
|
99
|
+
# @see the `==` method
|
100
|
+
def eql?(o)
|
101
|
+
self == o
|
102
|
+
end
|
103
|
+
|
104
|
+
# Calculate hash code according to all attributes.
|
105
|
+
def hash
|
106
|
+
[reward_number, reward_id, reward_name, expiry_month, expiry_year, extension_point].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# build the object from hash
|
110
|
+
def build_from_hash(attributes)
|
111
|
+
return nil unless attributes.is_a?(Hash)
|
112
|
+
self.class.datatype_map.each_pair do |key, type|
|
113
|
+
if type =~ /^Array<(.*)>/i
|
114
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
115
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
116
|
+
else
|
117
|
+
#TODO show warning in debug mode
|
118
|
+
end
|
119
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
120
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
121
|
+
else
|
122
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
def _deserialize(type, value)
|
130
|
+
case type.to_sym
|
131
|
+
when :DateTime
|
132
|
+
DateTime.parse(value)
|
133
|
+
when :Date
|
134
|
+
Date.parse(value)
|
135
|
+
when :String
|
136
|
+
value.to_s
|
137
|
+
when :Integer
|
138
|
+
value.to_i
|
139
|
+
when :Float
|
140
|
+
value.to_f
|
141
|
+
when :BOOLEAN
|
142
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
143
|
+
true
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
148
|
+
inner_type = Regexp.last_match[:inner_type]
|
149
|
+
value.map { |v| _deserialize(inner_type, v) }
|
150
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
151
|
+
k_type = Regexp.last_match[:k_type]
|
152
|
+
v_type = Regexp.last_match[:v_type]
|
153
|
+
{}.tap do |hash|
|
154
|
+
value.each do |k, v|
|
155
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
else # model
|
159
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
160
|
+
_model.build_from_hash(value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def to_s
|
165
|
+
to_hash.to_s
|
166
|
+
end
|
167
|
+
|
168
|
+
# to_body is an alias to to_body (backward compatibility))
|
169
|
+
def to_body
|
170
|
+
to_hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# return the object in the form of hash
|
174
|
+
def to_hash
|
175
|
+
hash = {}
|
176
|
+
self.class.attribute_map.each_pair do |attr, param|
|
177
|
+
value = self.send(attr)
|
178
|
+
next if value.nil?
|
179
|
+
hash[param] = _to_hash(value)
|
180
|
+
end
|
181
|
+
hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Method to output non-array value in the form of hash
|
185
|
+
# For object, use to_hash. Otherwise, just return the value
|
186
|
+
def _to_hash(value)
|
187
|
+
if value.is_a?(Array)
|
188
|
+
value.compact.map{ |v| _to_hash(v) }
|
189
|
+
elsif value.is_a?(Hash)
|
190
|
+
{}.tap do |hash|
|
191
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
192
|
+
end
|
193
|
+
elsif value.respond_to? :to_hash
|
194
|
+
value.to_hash
|
195
|
+
else
|
196
|
+
value
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
private
|
202
|
+
def after_parse
|
203
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
204
|
+
end
|
205
|
+
|
206
|
+
# Attribute datatype mapping.
|
207
|
+
def self.datatype_map
|
208
|
+
{
|
209
|
+
:reward_number => 'String',
|
210
|
+
:reward_id => 'String',
|
211
|
+
:reward_name => 'String',
|
212
|
+
:expiry_month => 'Integer',
|
213
|
+
:expiry_year => 'Integer',
|
214
|
+
:extension_point => 'ExtensionPoint'
|
215
|
+
|
216
|
+
}
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
|
221
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/precheckout_reward_program'
|
5
|
+
|
6
|
+
|
7
|
+
module MastercardMasterpassMerchant
|
8
|
+
# This class contains consumer reward program information.
|
9
|
+
class RewardPrograms
|
10
|
+
include ROXML
|
11
|
+
|
12
|
+
xml_name "RewardPrograms"
|
13
|
+
|
14
|
+
# @!attribute reward_program
|
15
|
+
# @return [Array<PrecheckoutRewardProgram>] the reward program details.
|
16
|
+
xml_accessor :reward_program, :from =>"RewardProgram", :as =>[PrecheckoutRewardProgram]
|
17
|
+
|
18
|
+
# @!attribute extension_point
|
19
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
20
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
21
|
+
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:reward_program => :RewardProgram ,
|
27
|
+
:extension_point => :ExtensionPoint
|
28
|
+
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(attributes = {})
|
33
|
+
return unless attributes.is_a?(Hash)
|
34
|
+
|
35
|
+
# convert string to symbol for hash key
|
36
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
37
|
+
|
38
|
+
|
39
|
+
if attributes.has_key?(:RewardProgram) || attributes.has_key?(:reward_program)
|
40
|
+
self.reward_program = attributes[:RewardProgram] || attributes[:reward_program]
|
41
|
+
end
|
42
|
+
|
43
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
44
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
# Overriding setter method reward_program
|
51
|
+
# @param value
|
52
|
+
def reward_program=(value)
|
53
|
+
if (value.is_a?(Array))
|
54
|
+
@reward_program = value
|
55
|
+
else
|
56
|
+
@reward_program = [] if !@reward_program
|
57
|
+
@reward_program.push value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Check equality by comparing each attribute.
|
63
|
+
def ==(o)
|
64
|
+
return true if self.equal?(o)
|
65
|
+
self.class == o.class &&
|
66
|
+
reward_program == o.reward_program &&
|
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
|
+
[reward_program, 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
|
+
:reward_program => 'Array<PrecheckoutRewardProgram>',
|
181
|
+
:extension_point => 'ExtensionPoint'
|
182
|
+
|
183
|
+
}
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'roxml'
|
3
|
+
require_relative '../../mastercard_masterpass_merchant/models/extension_point'
|
4
|
+
require_relative '../../mastercard_masterpass_merchant/models/wallet'
|
5
|
+
|
6
|
+
|
7
|
+
module MastercardMasterpassMerchant
|
8
|
+
# This class contains methods require to set checkout details during DSRP.
|
9
|
+
class RiskDecisioning
|
10
|
+
include ROXML
|
11
|
+
|
12
|
+
xml_name "RiskDecisioning"
|
13
|
+
|
14
|
+
# @!attribute wallet
|
15
|
+
# @return [Wallet] the Wallet information.
|
16
|
+
xml_accessor :wallet, :from =>"Wallet",:as => Wallet
|
17
|
+
|
18
|
+
# @!attribute extension_point
|
19
|
+
# @return [ExtensionPoint] the ExtensionPoint for future enhancement.
|
20
|
+
xml_accessor :extension_point, :from =>"ExtensionPoint",:as => ExtensionPoint
|
21
|
+
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:wallet => :Wallet ,
|
27
|
+
:extension_point => :ExtensionPoint
|
28
|
+
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(attributes = {})
|
33
|
+
return unless attributes.is_a?(Hash)
|
34
|
+
|
35
|
+
# convert string to symbol for hash key
|
36
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
37
|
+
|
38
|
+
|
39
|
+
if attributes.has_key?(:Wallet) || attributes.has_key?(:wallet)
|
40
|
+
self.wallet = attributes[:Wallet] || attributes[:wallet]
|
41
|
+
end
|
42
|
+
|
43
|
+
if attributes.has_key?(:ExtensionPoint) || attributes.has_key?(:extension_point)
|
44
|
+
self.extension_point = attributes[:ExtensionPoint] || attributes[:extension_point]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
# Check equality by comparing each attribute.
|
53
|
+
def ==(o)
|
54
|
+
return true if self.equal?(o)
|
55
|
+
self.class == o.class &&
|
56
|
+
wallet == o.wallet &&
|
57
|
+
extension_point == o.extension_point
|
58
|
+
end
|
59
|
+
|
60
|
+
# @see the `==` method
|
61
|
+
def eql?(o)
|
62
|
+
self == o
|
63
|
+
end
|
64
|
+
|
65
|
+
# Calculate hash code according to all attributes.
|
66
|
+
def hash
|
67
|
+
[wallet, extension_point].hash
|
68
|
+
end
|
69
|
+
|
70
|
+
# build the object from hash
|
71
|
+
def build_from_hash(attributes)
|
72
|
+
return nil unless attributes.is_a?(Hash)
|
73
|
+
self.class.datatype_map.each_pair do |key, type|
|
74
|
+
if type =~ /^Array<(.*)>/i
|
75
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
76
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
77
|
+
else
|
78
|
+
#TODO show warning in debug mode
|
79
|
+
end
|
80
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
81
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
82
|
+
else
|
83
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
def _deserialize(type, value)
|
91
|
+
case type.to_sym
|
92
|
+
when :DateTime
|
93
|
+
DateTime.parse(value)
|
94
|
+
when :Date
|
95
|
+
Date.parse(value)
|
96
|
+
when :String
|
97
|
+
value.to_s
|
98
|
+
when :Integer
|
99
|
+
value.to_i
|
100
|
+
when :Float
|
101
|
+
value.to_f
|
102
|
+
when :BOOLEAN
|
103
|
+
if value =~ /^(true|t|yes|y|1)$/i
|
104
|
+
true
|
105
|
+
else
|
106
|
+
false
|
107
|
+
end
|
108
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
109
|
+
inner_type = Regexp.last_match[:inner_type]
|
110
|
+
value.map { |v| _deserialize(inner_type, v) }
|
111
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
112
|
+
k_type = Regexp.last_match[:k_type]
|
113
|
+
v_type = Regexp.last_match[:v_type]
|
114
|
+
{}.tap do |hash|
|
115
|
+
value.each do |k, v|
|
116
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
else # model
|
120
|
+
_model = MastercardMasterpassMerchant.const_get(type).new
|
121
|
+
_model.build_from_hash(value)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def to_s
|
126
|
+
to_hash.to_s
|
127
|
+
end
|
128
|
+
|
129
|
+
# to_body is an alias to to_body (backward compatibility))
|
130
|
+
def to_body
|
131
|
+
to_hash
|
132
|
+
end
|
133
|
+
|
134
|
+
# return the object in the form of hash
|
135
|
+
def to_hash
|
136
|
+
hash = {}
|
137
|
+
self.class.attribute_map.each_pair do |attr, param|
|
138
|
+
value = self.send(attr)
|
139
|
+
next if value.nil?
|
140
|
+
hash[param] = _to_hash(value)
|
141
|
+
end
|
142
|
+
hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Method to output non-array value in the form of hash
|
146
|
+
# For object, use to_hash. Otherwise, just return the value
|
147
|
+
def _to_hash(value)
|
148
|
+
if value.is_a?(Array)
|
149
|
+
value.compact.map{ |v| _to_hash(v) }
|
150
|
+
elsif value.is_a?(Hash)
|
151
|
+
{}.tap do |hash|
|
152
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
153
|
+
end
|
154
|
+
elsif value.respond_to? :to_hash
|
155
|
+
value.to_hash
|
156
|
+
else
|
157
|
+
value
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
private
|
163
|
+
def after_parse
|
164
|
+
self.send(:remove_instance_variable, :@roxml_references) if defined? self.roxml_references
|
165
|
+
end
|
166
|
+
|
167
|
+
# Attribute datatype mapping.
|
168
|
+
def self.datatype_map
|
169
|
+
{
|
170
|
+
:wallet => 'Wallet',
|
171
|
+
:extension_point => 'ExtensionPoint'
|
172
|
+
|
173
|
+
}
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
end
|