cybersource_rest_client 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cybersource_rest_client.rb +12 -5
- data/lib/cybersource_rest_client/api/credit_api.rb +1 -1
- data/lib/cybersource_rest_client/api/download_dtd_api.rb +4 -4
- data/lib/cybersource_rest_client/api/download_xsd_api.rb +4 -4
- data/lib/cybersource_rest_client/api/payments_api.rb +1 -1
- data/lib/cybersource_rest_client/api/report_subscriptions_api.rb +9 -9
- data/lib/cybersource_rest_client/api/reports_api.rb +9 -9
- data/lib/cybersource_rest_client/api/search_transactions_api.rb +1 -1
- data/lib/cybersource_rest_client/api/transaction_batches_api.rb +2 -8
- data/lib/cybersource_rest_client/models/{request_body.rb → create_adhoc_report_request.rb} +1 -1
- data/lib/cybersource_rest_client/models/{request_body_1.rb → create_report_subscription_request.rb} +1 -1
- data/lib/cybersource_rest_client/models/error.rb +23 -13
- data/lib/cybersource_rest_client/models/error_bean.rb +1 -1
- data/lib/cybersource_rest_client/models/error_links.rb +15 -15
- data/lib/cybersource_rest_client/models/error_response.rb +2 -20
- data/lib/cybersource_rest_client/models/inline_response_400.rb +59 -14
- data/lib/cybersource_rest_client/models/inline_response_400_1.rb +14 -59
- data/lib/cybersource_rest_client/models/{inline_response_400_1_fields.rb → inline_response_400_fields.rb} +1 -1
- data/lib/cybersource_rest_client/models/link.rb +4 -25
- data/lib/cybersource_rest_client/models/links.rb +14 -18
- data/lib/cybersource_rest_client/models/ptsv2credits_processing_information.rb +22 -4
- data/lib/cybersource_rest_client/models/ptsv2credits_processing_information_electronic_benefits_transfer.rb +199 -0
- data/lib/cybersource_rest_client/models/ptsv2credits_processing_information_purchase_options.rb +184 -0
- data/lib/cybersource_rest_client/models/ptsv2payments_order_information_amount_details.rb +29 -4
- data/lib/cybersource_rest_client/models/ptsv2payments_order_information_line_items.rb +6 -6
- data/lib/cybersource_rest_client/models/ptsv2payments_payment_information.rb +13 -4
- data/lib/cybersource_rest_client/models/ptsv2payments_payment_information_payment_type.rb +203 -0
- data/lib/cybersource_rest_client/models/ptsv2payments_payment_information_payment_type_method.rb +184 -0
- data/lib/cybersource_rest_client/models/ptsv2payments_processing_information.rb +22 -4
- data/lib/cybersource_rest_client/models/ptsv2payments_processing_information_electronic_benefits_transfer.rb +224 -0
- data/lib/cybersource_rest_client/models/ptsv2payments_processing_information_purchase_options.rb +209 -0
- data/lib/cybersource_rest_client/models/ptsv2paymentsidcaptures_order_information_amount_details.rb +29 -4
- data/lib/cybersource_rest_client/models/ptsv2paymentsidrefunds_order_information_line_items.rb +6 -6
- data/lib/cybersource_rest_client/models/ptsv2paymentsidrefunds_payment_information.rb +13 -4
- data/lib/cybersource_rest_client/models/ptsv2paymentsidreversals_order_information_line_items.rb +6 -6
- data/lib/cybersource_rest_client/models/ptsv2paymentsidvoids_payment_information.rb +183 -0
- data/lib/cybersource_rest_client/models/riskv1decisions_order_information_line_items.rb +6 -6
- data/lib/cybersource_rest_client/models/tss_v2_transactions_get200_response_payment_information_payment_type.rb +2 -2
- data/lib/cybersource_rest_client/models/tss_v2_transactions_post201_response__embedded_payment_information_payment_type.rb +1 -1
- data/lib/cybersource_rest_client/models/void_capture_request.rb +13 -4
- data/lib/cybersource_rest_client/models/void_credit_request.rb +13 -4
- data/lib/cybersource_rest_client/models/void_payment_request.rb +13 -4
- data/lib/cybersource_rest_client/models/void_refund_request.rb +13 -4
- metadata +12 -5
@@ -55,6 +55,10 @@ module CyberSource
|
|
55
55
|
|
56
56
|
attr_accessor :bank_transfer_options
|
57
57
|
|
58
|
+
attr_accessor :purchase_options
|
59
|
+
|
60
|
+
attr_accessor :electronic_benefits_transfer
|
61
|
+
|
58
62
|
# Attribute mapping from ruby-style variable name to JSON key.
|
59
63
|
def self.attribute_map
|
60
64
|
{
|
@@ -72,7 +76,9 @@ module CyberSource
|
|
72
76
|
:'authorization_options' => :'authorizationOptions',
|
73
77
|
:'capture_options' => :'captureOptions',
|
74
78
|
:'recurring_options' => :'recurringOptions',
|
75
|
-
:'bank_transfer_options' => :'bankTransferOptions'
|
79
|
+
:'bank_transfer_options' => :'bankTransferOptions',
|
80
|
+
:'purchase_options' => :'purchaseOptions',
|
81
|
+
:'electronic_benefits_transfer' => :'electronicBenefitsTransfer'
|
76
82
|
}
|
77
83
|
end
|
78
84
|
|
@@ -93,7 +99,9 @@ module CyberSource
|
|
93
99
|
:'authorization_options' => :'Ptsv2paymentsProcessingInformationAuthorizationOptions',
|
94
100
|
:'capture_options' => :'Ptsv2paymentsProcessingInformationCaptureOptions',
|
95
101
|
:'recurring_options' => :'Ptsv2paymentsProcessingInformationRecurringOptions',
|
96
|
-
:'bank_transfer_options' => :'Ptsv2paymentsProcessingInformationBankTransferOptions'
|
102
|
+
:'bank_transfer_options' => :'Ptsv2paymentsProcessingInformationBankTransferOptions',
|
103
|
+
:'purchase_options' => :'Ptsv2paymentsProcessingInformationPurchaseOptions',
|
104
|
+
:'electronic_benefits_transfer' => :'Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer'
|
97
105
|
}
|
98
106
|
end
|
99
107
|
|
@@ -166,6 +174,14 @@ module CyberSource
|
|
166
174
|
if attributes.has_key?(:'bankTransferOptions')
|
167
175
|
self.bank_transfer_options = attributes[:'bankTransferOptions']
|
168
176
|
end
|
177
|
+
|
178
|
+
if attributes.has_key?(:'purchaseOptions')
|
179
|
+
self.purchase_options = attributes[:'purchaseOptions']
|
180
|
+
end
|
181
|
+
|
182
|
+
if attributes.has_key?(:'electronicBenefitsTransfer')
|
183
|
+
self.electronic_benefits_transfer = attributes[:'electronicBenefitsTransfer']
|
184
|
+
end
|
169
185
|
end
|
170
186
|
|
171
187
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -335,7 +351,9 @@ module CyberSource
|
|
335
351
|
authorization_options == o.authorization_options &&
|
336
352
|
capture_options == o.capture_options &&
|
337
353
|
recurring_options == o.recurring_options &&
|
338
|
-
bank_transfer_options == o.bank_transfer_options
|
354
|
+
bank_transfer_options == o.bank_transfer_options &&
|
355
|
+
purchase_options == o.purchase_options &&
|
356
|
+
electronic_benefits_transfer == o.electronic_benefits_transfer
|
339
357
|
end
|
340
358
|
|
341
359
|
# @see the `==` method
|
@@ -347,7 +365,7 @@ module CyberSource
|
|
347
365
|
# Calculates hash code according to all attributes.
|
348
366
|
# @return [Fixnum] Hash code
|
349
367
|
def hash
|
350
|
-
[capture, processor_id, business_application_id, commerce_indicator, payment_solution, reconciliation_id, link_id, purchase_level, report_group, visa_checkout_id, industry_data_type, authorization_options, capture_options, recurring_options, bank_transfer_options].hash
|
368
|
+
[capture, processor_id, business_application_id, commerce_indicator, payment_solution, reconciliation_id, link_id, purchase_level, report_group, visa_checkout_id, industry_data_type, authorization_options, capture_options, recurring_options, bank_transfer_options, purchase_options, electronic_benefits_transfer].hash
|
351
369
|
end
|
352
370
|
|
353
371
|
# Builds the object from hash
|
@@ -0,0 +1,224 @@
|
|
1
|
+
=begin
|
2
|
+
#CyberSource Merged Spec
|
3
|
+
|
4
|
+
#All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.0.1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CyberSource
|
16
|
+
class Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer
|
17
|
+
# Flag that specifies the category for the EBT transaction. Possible values: - `CASH`: Cash benefits, which can be used to purchase any item at a participating retailer, as well as to obtain cash-back or make a cash withdrawal from a participating ATM. - `FOOD`: Food stamp benefits, which can be used only to purchase food items authorized by the USDA SNAP program.
|
18
|
+
attr_accessor :category
|
19
|
+
|
20
|
+
# The serial number printed on the EBT voucher.
|
21
|
+
attr_accessor :voucher_serial_number
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:'category' => :'category',
|
27
|
+
:'voucher_serial_number' => :'voucherSerialNumber'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.swagger_types
|
33
|
+
{
|
34
|
+
:'category' => :'String',
|
35
|
+
:'voucher_serial_number' => :'String'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Initializes the object
|
40
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
41
|
+
def initialize(attributes = {})
|
42
|
+
return unless attributes.is_a?(Hash)
|
43
|
+
|
44
|
+
# convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
46
|
+
|
47
|
+
if attributes.has_key?(:'category')
|
48
|
+
self.category = attributes[:'category']
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:'voucherSerialNumber')
|
52
|
+
self.voucher_serial_number = attributes[:'voucherSerialNumber']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
57
|
+
# @return Array for valid properties with the reasons
|
58
|
+
def list_invalid_properties
|
59
|
+
invalid_properties = Array.new
|
60
|
+
if !@category.nil? && @category.to_s.length > 4
|
61
|
+
invalid_properties.push('invalid value for "category", the character length must be smaller than or equal to 4.')
|
62
|
+
end
|
63
|
+
|
64
|
+
if !@voucher_serial_number.nil? && @voucher_serial_number.to_s.length > 15
|
65
|
+
invalid_properties.push('invalid value for "voucher_serial_number", the character length must be smaller than or equal to 15.')
|
66
|
+
end
|
67
|
+
|
68
|
+
invalid_properties
|
69
|
+
end
|
70
|
+
|
71
|
+
# Check to see if the all the properties in the model are valid
|
72
|
+
# @return true if the model is valid
|
73
|
+
def valid?
|
74
|
+
return false if !@category.nil? && @category.to_s.length > 4
|
75
|
+
return false if !@voucher_serial_number.nil? && @voucher_serial_number.to_s.length > 15
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
# Custom attribute writer method with validation
|
80
|
+
# @param [Object] category Value to be assigned
|
81
|
+
def category=(category)
|
82
|
+
if !category.nil? && category.to_s.length > 4
|
83
|
+
fail ArgumentError, 'invalid value for "category", the character length must be smaller than or equal to 4.'
|
84
|
+
end
|
85
|
+
|
86
|
+
@category = category
|
87
|
+
end
|
88
|
+
|
89
|
+
# Custom attribute writer method with validation
|
90
|
+
# @param [Object] voucher_serial_number Value to be assigned
|
91
|
+
def voucher_serial_number=(voucher_serial_number)
|
92
|
+
if !voucher_serial_number.nil? && voucher_serial_number.to_s.length > 15
|
93
|
+
fail ArgumentError, 'invalid value for "voucher_serial_number", the character length must be smaller than or equal to 15.'
|
94
|
+
end
|
95
|
+
|
96
|
+
@voucher_serial_number = voucher_serial_number
|
97
|
+
end
|
98
|
+
|
99
|
+
# Checks equality by comparing each attribute.
|
100
|
+
# @param [Object] Object to be compared
|
101
|
+
def ==(o)
|
102
|
+
return true if self.equal?(o)
|
103
|
+
self.class == o.class &&
|
104
|
+
category == o.category &&
|
105
|
+
voucher_serial_number == o.voucher_serial_number
|
106
|
+
end
|
107
|
+
|
108
|
+
# @see the `==` method
|
109
|
+
# @param [Object] Object to be compared
|
110
|
+
def eql?(o)
|
111
|
+
self == o
|
112
|
+
end
|
113
|
+
|
114
|
+
# Calculates hash code according to all attributes.
|
115
|
+
# @return [Fixnum] Hash code
|
116
|
+
def hash
|
117
|
+
[category, voucher_serial_number].hash
|
118
|
+
end
|
119
|
+
|
120
|
+
# Builds the object from hash
|
121
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
122
|
+
# @return [Object] Returns the model itself
|
123
|
+
def build_from_hash(attributes)
|
124
|
+
return nil unless attributes.is_a?(Hash)
|
125
|
+
self.class.swagger_types.each_pair do |key, type|
|
126
|
+
if type =~ /\AArray<(.*)>/i
|
127
|
+
# check to ensure the input is an array given that the the attribute
|
128
|
+
# is documented as an array but the input is not
|
129
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
130
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
131
|
+
end
|
132
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
133
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
134
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
135
|
+
end
|
136
|
+
|
137
|
+
self
|
138
|
+
end
|
139
|
+
|
140
|
+
# Deserializes the data based on type
|
141
|
+
# @param string type Data type
|
142
|
+
# @param string value Value to be deserialized
|
143
|
+
# @return [Object] Deserialized data
|
144
|
+
def _deserialize(type, value)
|
145
|
+
case type.to_sym
|
146
|
+
when :DateTime
|
147
|
+
DateTime.parse(value)
|
148
|
+
when :Date
|
149
|
+
Date.parse(value)
|
150
|
+
when :String
|
151
|
+
value.to_s
|
152
|
+
when :Integer
|
153
|
+
value.to_i
|
154
|
+
when :Float
|
155
|
+
value.to_f
|
156
|
+
when :BOOLEAN
|
157
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
158
|
+
true
|
159
|
+
else
|
160
|
+
false
|
161
|
+
end
|
162
|
+
when :Object
|
163
|
+
# generic object (usually a Hash), return directly
|
164
|
+
value
|
165
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
166
|
+
inner_type = Regexp.last_match[:inner_type]
|
167
|
+
value.map { |v| _deserialize(inner_type, v) }
|
168
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
169
|
+
k_type = Regexp.last_match[:k_type]
|
170
|
+
v_type = Regexp.last_match[:v_type]
|
171
|
+
{}.tap do |hash|
|
172
|
+
value.each do |k, v|
|
173
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
else # model
|
177
|
+
temp_model = CyberSource.const_get(type).new
|
178
|
+
temp_model.build_from_hash(value)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Returns the string representation of the object
|
183
|
+
# @return [String] String presentation of the object
|
184
|
+
def to_s
|
185
|
+
to_hash.to_s
|
186
|
+
end
|
187
|
+
|
188
|
+
# to_body is an alias to to_hash (backward compatibility)
|
189
|
+
# @return [Hash] Returns the object in the form of hash
|
190
|
+
def to_body
|
191
|
+
to_hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the object in the form of hash
|
195
|
+
# @return [Hash] Returns the object in the form of hash
|
196
|
+
def to_hash
|
197
|
+
hash = {}
|
198
|
+
self.class.attribute_map.each_pair do |attr, param|
|
199
|
+
value = self.send(attr)
|
200
|
+
next if value.nil?
|
201
|
+
hash[param] = _to_hash(value)
|
202
|
+
end
|
203
|
+
hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Outputs non-array value in the form of hash
|
207
|
+
# For object, use to_hash. Otherwise, just return the value
|
208
|
+
# @param [Object] value Any valid value
|
209
|
+
# @return [Hash] Returns the value in the form of hash
|
210
|
+
def _to_hash(value)
|
211
|
+
if value.is_a?(Array)
|
212
|
+
value.compact.map { |v| _to_hash(v) }
|
213
|
+
elsif value.is_a?(Hash)
|
214
|
+
{}.tap do |hash|
|
215
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
216
|
+
end
|
217
|
+
elsif value.respond_to? :to_hash
|
218
|
+
value.to_hash
|
219
|
+
else
|
220
|
+
value
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
data/lib/cybersource_rest_client/models/ptsv2payments_processing_information_purchase_options.rb
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
=begin
|
2
|
+
#CyberSource Merged Spec
|
3
|
+
|
4
|
+
#All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.0.1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CyberSource
|
16
|
+
class Ptsv2paymentsProcessingInformationPurchaseOptions
|
17
|
+
# Flag that indicates that this transaction is an EBT transaction.Possible values: - **true** - **false**
|
18
|
+
attr_accessor :is_electronic_benefits_transfer
|
19
|
+
|
20
|
+
# This field is used in PIN Debit EBT transaction as a flag to identify EBT vouchers.Possible values: - `EBT_VOUCHER`: Indicates EBT voucher
|
21
|
+
attr_accessor :type
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:'is_electronic_benefits_transfer' => :'isElectronicBenefitsTransfer',
|
27
|
+
:'type' => :'type'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.swagger_types
|
33
|
+
{
|
34
|
+
:'is_electronic_benefits_transfer' => :'BOOLEAN',
|
35
|
+
:'type' => :'String'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Initializes the object
|
40
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
41
|
+
def initialize(attributes = {})
|
42
|
+
return unless attributes.is_a?(Hash)
|
43
|
+
|
44
|
+
# convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
46
|
+
|
47
|
+
if attributes.has_key?(:'isElectronicBenefitsTransfer')
|
48
|
+
self.is_electronic_benefits_transfer = attributes[:'isElectronicBenefitsTransfer']
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:'type')
|
52
|
+
self.type = attributes[:'type']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
57
|
+
# @return Array for valid properties with the reasons
|
58
|
+
def list_invalid_properties
|
59
|
+
invalid_properties = Array.new
|
60
|
+
if !@type.nil? && @type.to_s.length > 6
|
61
|
+
invalid_properties.push('invalid value for "type", the character length must be smaller than or equal to 6.')
|
62
|
+
end
|
63
|
+
|
64
|
+
invalid_properties
|
65
|
+
end
|
66
|
+
|
67
|
+
# Check to see if the all the properties in the model are valid
|
68
|
+
# @return true if the model is valid
|
69
|
+
def valid?
|
70
|
+
return false if !@type.nil? && @type.to_s.length > 6
|
71
|
+
true
|
72
|
+
end
|
73
|
+
|
74
|
+
# Custom attribute writer method with validation
|
75
|
+
# @param [Object] type Value to be assigned
|
76
|
+
def type=(type)
|
77
|
+
if !type.nil? && type.to_s.length > 6
|
78
|
+
fail ArgumentError, 'invalid value for "type", the character length must be smaller than or equal to 6.'
|
79
|
+
end
|
80
|
+
|
81
|
+
@type = type
|
82
|
+
end
|
83
|
+
|
84
|
+
# Checks equality by comparing each attribute.
|
85
|
+
# @param [Object] Object to be compared
|
86
|
+
def ==(o)
|
87
|
+
return true if self.equal?(o)
|
88
|
+
self.class == o.class &&
|
89
|
+
is_electronic_benefits_transfer == o.is_electronic_benefits_transfer &&
|
90
|
+
type == o.type
|
91
|
+
end
|
92
|
+
|
93
|
+
# @see the `==` method
|
94
|
+
# @param [Object] Object to be compared
|
95
|
+
def eql?(o)
|
96
|
+
self == o
|
97
|
+
end
|
98
|
+
|
99
|
+
# Calculates hash code according to all attributes.
|
100
|
+
# @return [Fixnum] Hash code
|
101
|
+
def hash
|
102
|
+
[is_electronic_benefits_transfer, type].hash
|
103
|
+
end
|
104
|
+
|
105
|
+
# Builds the object from hash
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
# @return [Object] Returns the model itself
|
108
|
+
def build_from_hash(attributes)
|
109
|
+
return nil unless attributes.is_a?(Hash)
|
110
|
+
self.class.swagger_types.each_pair do |key, type|
|
111
|
+
if type =~ /\AArray<(.*)>/i
|
112
|
+
# check to ensure the input is an array given that the the attribute
|
113
|
+
# is documented as an array but the input is not
|
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
|
+
end
|
117
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
118
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
119
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
120
|
+
end
|
121
|
+
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
# Deserializes the data based on type
|
126
|
+
# @param string type Data type
|
127
|
+
# @param string value Value to be deserialized
|
128
|
+
# @return [Object] Deserialized data
|
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.to_s =~ /\A(true|t|yes|y|1)\z/i
|
143
|
+
true
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
when :Object
|
148
|
+
# generic object (usually a Hash), return directly
|
149
|
+
value
|
150
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
151
|
+
inner_type = Regexp.last_match[:inner_type]
|
152
|
+
value.map { |v| _deserialize(inner_type, v) }
|
153
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
154
|
+
k_type = Regexp.last_match[:k_type]
|
155
|
+
v_type = Regexp.last_match[:v_type]
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each do |k, v|
|
158
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else # model
|
162
|
+
temp_model = CyberSource.const_get(type).new
|
163
|
+
temp_model.build_from_hash(value)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns the string representation of the object
|
168
|
+
# @return [String] String presentation of the object
|
169
|
+
def to_s
|
170
|
+
to_hash.to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
# to_body is an alias to to_hash (backward compatibility)
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
175
|
+
def to_body
|
176
|
+
to_hash
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the object in the form of hash
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
181
|
+
def to_hash
|
182
|
+
hash = {}
|
183
|
+
self.class.attribute_map.each_pair do |attr, param|
|
184
|
+
value = self.send(attr)
|
185
|
+
next if value.nil?
|
186
|
+
hash[param] = _to_hash(value)
|
187
|
+
end
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to? :to_hash
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|