cybersource_rest_client 0.0.46 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cybersource_rest_client/api/emv_tag_details_api.rb +152 -0
  3. data/lib/cybersource_rest_client/api/transient_token_data_api.rb +92 -0
  4. data/lib/cybersource_rest_client/api/unified_checkout_capture_context_api.rb +88 -0
  5. data/lib/cybersource_rest_client/models/body.rb +216 -0
  6. data/lib/cybersource_rest_client/models/generate_unified_checkout_capture_context_request.rb +276 -0
  7. data/lib/cybersource_rest_client/models/inline_response_400_3.rb +265 -0
  8. data/lib/cybersource_rest_client/models/inline_response_400_3_details.rb +192 -0
  9. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_consumer_authentication_information_issuer_information.rb +52 -4
  10. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_issuer_information.rb +4 -20
  11. data/lib/cybersource_rest_client/models/pts_v2_payouts_post201_response.rb +13 -4
  12. data/lib/cybersource_rest_client/models/pts_v2_payouts_post201_response_issuer_information.rb +190 -0
  13. data/lib/cybersource_rest_client/models/ptsv2payments_point_of_sale_information.rb +1 -1
  14. data/lib/cybersource_rest_client/models/ptsv2payments_processing_information_authorization_options.rb +1 -1
  15. data/lib/cybersource_rest_client/models/ptsv2payments_recurring_payment_information.rb +100 -4
  16. data/lib/cybersource_rest_client/models/tss_v2_get_emv_tags200_response.rb +186 -0
  17. data/lib/cybersource_rest_client/models/tss_v2_get_emv_tags200_response_emv_tag_breakdown_list.rb +215 -0
  18. data/lib/cybersource_rest_client/models/tss_v2_post_emv_tags200_response.rb +186 -0
  19. data/lib/cybersource_rest_client/models/tss_v2_post_emv_tags200_response_emv_tag_breakdown_list.rb +266 -0
  20. data/lib/cybersource_rest_client/models/tss_v2_post_emv_tags200_response_parsed_emv_tags_list.rb +212 -0
  21. data/lib/cybersource_rest_client/models/tssv2transactionsemv_tag_details_emv_details_list.rb +224 -0
  22. data/lib/cybersource_rest_client/models/upv1capturecontexts_capture_mandate.rb +242 -0
  23. data/lib/cybersource_rest_client/models/upv1capturecontexts_checkout_api_initialization.rb +264 -0
  24. data/lib/cybersource_rest_client/models/upv1capturecontexts_order_information.rb +201 -0
  25. data/lib/cybersource_rest_client/models/upv1capturecontexts_order_information_amount_details.rb +192 -0
  26. data/lib/cybersource_rest_client/models/upv1capturecontexts_order_information_bill_to.rb +459 -0
  27. data/lib/cybersource_rest_client/models/upv1capturecontexts_order_information_bill_to_company.rb +350 -0
  28. data/lib/cybersource_rest_client/models/upv1capturecontexts_order_information_ship_to.rb +354 -0
  29. data/lib/cybersource_rest_client.rb +21 -0
  30. metadata +45 -24
@@ -0,0 +1,350 @@
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 Upv1capturecontextsOrderInformationBillToCompany
17
+ # Name of the customer’s company.
18
+ attr_accessor :name
19
+
20
+ # Payment card billing street address as it appears on the credit card issuer’s records.
21
+ attr_accessor :address1
22
+
23
+ # Used for additional address information. For example: _Attention: Accounts Payable_ Optional field.
24
+ attr_accessor :address2
25
+
26
+ # Additional address information (third line of the billing address)
27
+ attr_accessor :address3
28
+
29
+ # Additional address information (fourth line of the billing address)
30
+ attr_accessor :address4
31
+
32
+ # State or province of the billing address. Use the [State, Province, and Territory Codes for the United States and Canada](https://developer.cybersource.com/library/documentation/sbc/quickref/states_and_provinces.pdf).
33
+ attr_accessor :administrative_area
34
+
35
+ # Building number in the street address.
36
+ attr_accessor :building_number
37
+
38
+ # Payment card billing country. Use the two-character [ISO Standard Country Codes](http://apps.cybersource.com/library/documentation/sbc/quickref/countries_alpha_list.pdf).
39
+ attr_accessor :country
40
+
41
+ # Customer’s neighborhood, community, or region (a barrio in Brazil) within the city or municipality
42
+ attr_accessor :district
43
+
44
+ # Payment card billing city.
45
+ attr_accessor :locality
46
+
47
+ # Postal code for the billing address. The postal code must consist of 5 to 9 digits.
48
+ attr_accessor :postal_code
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'name' => :'name',
54
+ :'address1' => :'address1',
55
+ :'address2' => :'address2',
56
+ :'address3' => :'address3',
57
+ :'address4' => :'address4',
58
+ :'administrative_area' => :'administrativeArea',
59
+ :'building_number' => :'buildingNumber',
60
+ :'country' => :'country',
61
+ :'district' => :'district',
62
+ :'locality' => :'locality',
63
+ :'postal_code' => :'postalCode'
64
+ }
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.swagger_types
69
+ {
70
+ :'name' => :'String',
71
+ :'address1' => :'String',
72
+ :'address2' => :'String',
73
+ :'address3' => :'String',
74
+ :'address4' => :'String',
75
+ :'administrative_area' => :'String',
76
+ :'building_number' => :'String',
77
+ :'country' => :'String',
78
+ :'district' => :'String',
79
+ :'locality' => :'String',
80
+ :'postal_code' => :'String'
81
+ }
82
+ end
83
+
84
+ # Initializes the object
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ def initialize(attributes = {})
87
+ return unless attributes.is_a?(Hash)
88
+
89
+ # convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
91
+
92
+ if attributes.has_key?(:'name')
93
+ self.name = attributes[:'name']
94
+ end
95
+
96
+ if attributes.has_key?(:'address1')
97
+ self.address1 = attributes[:'address1']
98
+ end
99
+
100
+ if attributes.has_key?(:'address2')
101
+ self.address2 = attributes[:'address2']
102
+ end
103
+
104
+ if attributes.has_key?(:'address3')
105
+ self.address3 = attributes[:'address3']
106
+ end
107
+
108
+ if attributes.has_key?(:'address4')
109
+ self.address4 = attributes[:'address4']
110
+ end
111
+
112
+ if attributes.has_key?(:'administrativeArea')
113
+ self.administrative_area = attributes[:'administrativeArea']
114
+ end
115
+
116
+ if attributes.has_key?(:'buildingNumber')
117
+ self.building_number = attributes[:'buildingNumber']
118
+ end
119
+
120
+ if attributes.has_key?(:'country')
121
+ self.country = attributes[:'country']
122
+ end
123
+
124
+ if attributes.has_key?(:'district')
125
+ self.district = attributes[:'district']
126
+ end
127
+
128
+ if attributes.has_key?(:'locality')
129
+ self.locality = attributes[:'locality']
130
+ end
131
+
132
+ if attributes.has_key?(:'postalCode')
133
+ self.postal_code = attributes[:'postalCode']
134
+ end
135
+ end
136
+
137
+ # Show invalid properties with the reasons. Usually used together with valid?
138
+ # @return Array for valid properties with the reasons
139
+ def list_invalid_properties
140
+ invalid_properties = Array.new
141
+ invalid_properties
142
+ end
143
+
144
+ # Check to see if the all the properties in the model are valid
145
+ # @return true if the model is valid
146
+ def valid?
147
+ true
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] name Value to be assigned
152
+ def name=(name)
153
+ @name = name
154
+ end
155
+
156
+ # Custom attribute writer method with validation
157
+ # @param [Object] address1 Value to be assigned
158
+ def address1=(address1)
159
+ @address1 = address1
160
+ end
161
+
162
+ # Custom attribute writer method with validation
163
+ # @param [Object] address2 Value to be assigned
164
+ def address2=(address2)
165
+ @address2 = address2
166
+ end
167
+
168
+ # Custom attribute writer method with validation
169
+ # @param [Object] address3 Value to be assigned
170
+ def address3=(address3)
171
+ @address3 = address3
172
+ end
173
+
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] address4 Value to be assigned
176
+ def address4=(address4)
177
+ @address4 = address4
178
+ end
179
+
180
+ # Custom attribute writer method with validation
181
+ # @param [Object] administrative_area Value to be assigned
182
+ def administrative_area=(administrative_area)
183
+ @administrative_area = administrative_area
184
+ end
185
+
186
+ # Custom attribute writer method with validation
187
+ # @param [Object] building_number Value to be assigned
188
+ def building_number=(building_number)
189
+ @building_number = building_number
190
+ end
191
+
192
+ # Custom attribute writer method with validation
193
+ # @param [Object] country Value to be assigned
194
+ def country=(country)
195
+ @country = country
196
+ end
197
+
198
+ # Custom attribute writer method with validation
199
+ # @param [Object] district Value to be assigned
200
+ def district=(district)
201
+ @district = district
202
+ end
203
+
204
+ # Custom attribute writer method with validation
205
+ # @param [Object] locality Value to be assigned
206
+ def locality=(locality)
207
+ @locality = locality
208
+ end
209
+
210
+ # Custom attribute writer method with validation
211
+ # @param [Object] postal_code Value to be assigned
212
+ def postal_code=(postal_code)
213
+ @postal_code = postal_code
214
+ end
215
+
216
+ # Checks equality by comparing each attribute.
217
+ # @param [Object] Object to be compared
218
+ def ==(o)
219
+ return true if self.equal?(o)
220
+ self.class == o.class &&
221
+ name == o.name &&
222
+ address1 == o.address1 &&
223
+ address2 == o.address2 &&
224
+ address3 == o.address3 &&
225
+ address4 == o.address4 &&
226
+ administrative_area == o.administrative_area &&
227
+ building_number == o.building_number &&
228
+ country == o.country &&
229
+ district == o.district &&
230
+ locality == o.locality &&
231
+ postal_code == o.postal_code
232
+ end
233
+
234
+ # @see the `==` method
235
+ # @param [Object] Object to be compared
236
+ def eql?(o)
237
+ self == o
238
+ end
239
+
240
+ # Calculates hash code according to all attributes.
241
+ # @return [Fixnum] Hash code
242
+ def hash
243
+ [name, address1, address2, address3, address4, administrative_area, building_number, country, district, locality, postal_code].hash
244
+ end
245
+
246
+ # Builds the object from hash
247
+ # @param [Hash] attributes Model attributes in the form of hash
248
+ # @return [Object] Returns the model itself
249
+ def build_from_hash(attributes)
250
+ return nil unless attributes.is_a?(Hash)
251
+ self.class.swagger_types.each_pair do |key, type|
252
+ if type =~ /\AArray<(.*)>/i
253
+ # check to ensure the input is an array given that the the attribute
254
+ # is documented as an array but the input is not
255
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
256
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
257
+ end
258
+ elsif !attributes[self.class.attribute_map[key]].nil?
259
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
260
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
261
+ end
262
+
263
+ self
264
+ end
265
+
266
+ # Deserializes the data based on type
267
+ # @param string type Data type
268
+ # @param string value Value to be deserialized
269
+ # @return [Object] Deserialized data
270
+ def _deserialize(type, value)
271
+ case type.to_sym
272
+ when :DateTime
273
+ DateTime.parse(value)
274
+ when :Date
275
+ Date.parse(value)
276
+ when :String
277
+ value.to_s
278
+ when :Integer
279
+ value.to_i
280
+ when :Float
281
+ value.to_f
282
+ when :BOOLEAN
283
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
284
+ true
285
+ else
286
+ false
287
+ end
288
+ when :Object
289
+ # generic object (usually a Hash), return directly
290
+ value
291
+ when /\AArray<(?<inner_type>.+)>\z/
292
+ inner_type = Regexp.last_match[:inner_type]
293
+ value.map { |v| _deserialize(inner_type, v) }
294
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
295
+ k_type = Regexp.last_match[:k_type]
296
+ v_type = Regexp.last_match[:v_type]
297
+ {}.tap do |hash|
298
+ value.each do |k, v|
299
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
300
+ end
301
+ end
302
+ else # model
303
+ temp_model = CyberSource.const_get(type).new
304
+ temp_model.build_from_hash(value)
305
+ end
306
+ end
307
+
308
+ # Returns the string representation of the object
309
+ # @return [String] String presentation of the object
310
+ def to_s
311
+ to_hash.to_s
312
+ end
313
+
314
+ # to_body is an alias to to_hash (backward compatibility)
315
+ # @return [Hash] Returns the object in the form of hash
316
+ def to_body
317
+ to_hash
318
+ end
319
+
320
+ # Returns the object in the form of hash
321
+ # @return [Hash] Returns the object in the form of hash
322
+ def to_hash
323
+ hash = {}
324
+ self.class.attribute_map.each_pair do |attr, param|
325
+ value = self.send(attr)
326
+ next if value.nil?
327
+ hash[param] = _to_hash(value)
328
+ end
329
+ hash
330
+ end
331
+
332
+ # Outputs non-array value in the form of hash
333
+ # For object, use to_hash. Otherwise, just return the value
334
+ # @param [Object] value Any valid value
335
+ # @return [Hash] Returns the value in the form of hash
336
+ def _to_hash(value)
337
+ if value.is_a?(Array)
338
+ value.compact.map { |v| _to_hash(v) }
339
+ elsif value.is_a?(Hash)
340
+ {}.tap do |hash|
341
+ value.each { |k, v| hash[k] = _to_hash(v) }
342
+ end
343
+ elsif value.respond_to? :to_hash
344
+ value.to_hash
345
+ else
346
+ value
347
+ end
348
+ end
349
+ end
350
+ end
@@ -0,0 +1,354 @@
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 Upv1capturecontextsOrderInformationShipTo
17
+ # First line of the shipping address.
18
+ attr_accessor :address1
19
+
20
+ # Second line of the shipping address.
21
+ attr_accessor :address2
22
+
23
+ # Third line of the shipping address.
24
+ attr_accessor :address3
25
+
26
+ # Fourth line of the shipping address.
27
+ attr_accessor :address4
28
+
29
+ # State or province of the shipping address. Use the [State, Province, and Territory Codes for the United States and Canada](https://developer.cybersource.com/library/documentation/sbc/quickref/states_and_provinces.pdf)
30
+ attr_accessor :administrative_area
31
+
32
+ # Building number in the street address.
33
+ attr_accessor :building_number
34
+
35
+ # Country of the shipping address. Use the two-character [ISO Standard Country Codes.](http://apps.cybersource.com/library/documentation/sbc/quickref/countries_alpha_list.pdf)
36
+ attr_accessor :country
37
+
38
+ # Neighborhood, community, or region within a city or municipality.
39
+ attr_accessor :district
40
+
41
+ # City of the shipping address.
42
+ attr_accessor :locality
43
+
44
+ # Postal code for the shipping address. The postal code must consist of 5 to 9 digits.
45
+ attr_accessor :postal_code
46
+
47
+ # First name of the recipient
48
+ attr_accessor :first_name
49
+
50
+ # Last name of the recipient.
51
+ attr_accessor :last_name
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'address1' => :'address1',
57
+ :'address2' => :'address2',
58
+ :'address3' => :'address3',
59
+ :'address4' => :'address4',
60
+ :'administrative_area' => :'administrativeArea',
61
+ :'building_number' => :'buildingNumber',
62
+ :'country' => :'country',
63
+ :'district' => :'district',
64
+ :'locality' => :'locality',
65
+ :'postal_code' => :'postalCode',
66
+ :'first_name' => :'firstName',
67
+ :'last_name' => :'lastName'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.swagger_types
73
+ {
74
+ :'address1' => :'String',
75
+ :'address2' => :'String',
76
+ :'address3' => :'String',
77
+ :'address4' => :'String',
78
+ :'administrative_area' => :'String',
79
+ :'building_number' => :'String',
80
+ :'country' => :'String',
81
+ :'district' => :'String',
82
+ :'locality' => :'String',
83
+ :'postal_code' => :'String',
84
+ :'first_name' => :'String',
85
+ :'last_name' => :'String'
86
+ }
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ return unless attributes.is_a?(Hash)
93
+
94
+ # convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
96
+
97
+ if attributes.has_key?(:'address1')
98
+ self.address1 = attributes[:'address1']
99
+ end
100
+
101
+ if attributes.has_key?(:'address2')
102
+ self.address2 = attributes[:'address2']
103
+ end
104
+
105
+ if attributes.has_key?(:'address3')
106
+ self.address3 = attributes[:'address3']
107
+ end
108
+
109
+ if attributes.has_key?(:'address4')
110
+ self.address4 = attributes[:'address4']
111
+ end
112
+
113
+ if attributes.has_key?(:'administrativeArea')
114
+ self.administrative_area = attributes[:'administrativeArea']
115
+ end
116
+
117
+ if attributes.has_key?(:'buildingNumber')
118
+ self.building_number = attributes[:'buildingNumber']
119
+ end
120
+
121
+ if attributes.has_key?(:'country')
122
+ self.country = attributes[:'country']
123
+ end
124
+
125
+ if attributes.has_key?(:'district')
126
+ self.district = attributes[:'district']
127
+ end
128
+
129
+ if attributes.has_key?(:'locality')
130
+ self.locality = attributes[:'locality']
131
+ end
132
+
133
+ if attributes.has_key?(:'postalCode')
134
+ self.postal_code = attributes[:'postalCode']
135
+ end
136
+
137
+ if attributes.has_key?(:'firstName')
138
+ self.first_name = attributes[:'firstName']
139
+ end
140
+
141
+ if attributes.has_key?(:'lastName')
142
+ self.last_name = attributes[:'lastName']
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ invalid_properties = Array.new
150
+ invalid_properties
151
+ end
152
+
153
+ # Check to see if the all the properties in the model are valid
154
+ # @return true if the model is valid
155
+ def valid?
156
+ true
157
+ end
158
+
159
+ # Custom attribute writer method with validation
160
+ # @param [Object] address1 Value to be assigned
161
+ def address1=(address1)
162
+ @address1 = address1
163
+ end
164
+
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] address2 Value to be assigned
167
+ def address2=(address2)
168
+ @address2 = address2
169
+ end
170
+
171
+ # Custom attribute writer method with validation
172
+ # @param [Object] address4 Value to be assigned
173
+ def address4=(address4)
174
+ @address4 = address4
175
+ end
176
+
177
+ # Custom attribute writer method with validation
178
+ # @param [Object] administrative_area Value to be assigned
179
+ def administrative_area=(administrative_area)
180
+ @administrative_area = administrative_area
181
+ end
182
+
183
+ # Custom attribute writer method with validation
184
+ # @param [Object] building_number Value to be assigned
185
+ def building_number=(building_number)
186
+ @building_number = building_number
187
+ end
188
+
189
+ # Custom attribute writer method with validation
190
+ # @param [Object] district Value to be assigned
191
+ def district=(district)
192
+ @district = district
193
+ end
194
+
195
+ # Custom attribute writer method with validation
196
+ # @param [Object] locality Value to be assigned
197
+ def locality=(locality)
198
+ @locality = locality
199
+ end
200
+
201
+ # Custom attribute writer method with validation
202
+ # @param [Object] postal_code Value to be assigned
203
+ def postal_code=(postal_code)
204
+ @postal_code = postal_code
205
+ end
206
+
207
+ # Custom attribute writer method with validation
208
+ # @param [Object] first_name Value to be assigned
209
+ def first_name=(first_name)
210
+ @first_name = first_name
211
+ end
212
+
213
+ # Custom attribute writer method with validation
214
+ # @param [Object] last_name Value to be assigned
215
+ def last_name=(last_name)
216
+ @last_name = last_name
217
+ end
218
+
219
+ # Checks equality by comparing each attribute.
220
+ # @param [Object] Object to be compared
221
+ def ==(o)
222
+ return true if self.equal?(o)
223
+ self.class == o.class &&
224
+ address1 == o.address1 &&
225
+ address2 == o.address2 &&
226
+ address3 == o.address3 &&
227
+ address4 == o.address4 &&
228
+ administrative_area == o.administrative_area &&
229
+ building_number == o.building_number &&
230
+ country == o.country &&
231
+ district == o.district &&
232
+ locality == o.locality &&
233
+ postal_code == o.postal_code &&
234
+ first_name == o.first_name &&
235
+ last_name == o.last_name
236
+ end
237
+
238
+ # @see the `==` method
239
+ # @param [Object] Object to be compared
240
+ def eql?(o)
241
+ self == o
242
+ end
243
+
244
+ # Calculates hash code according to all attributes.
245
+ # @return [Fixnum] Hash code
246
+ def hash
247
+ [address1, address2, address3, address4, administrative_area, building_number, country, district, locality, postal_code, first_name, last_name].hash
248
+ end
249
+
250
+ # Builds the object from hash
251
+ # @param [Hash] attributes Model attributes in the form of hash
252
+ # @return [Object] Returns the model itself
253
+ def build_from_hash(attributes)
254
+ return nil unless attributes.is_a?(Hash)
255
+ self.class.swagger_types.each_pair do |key, type|
256
+ if type =~ /\AArray<(.*)>/i
257
+ # check to ensure the input is an array given that the the attribute
258
+ # is documented as an array but the input is not
259
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
260
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
261
+ end
262
+ elsif !attributes[self.class.attribute_map[key]].nil?
263
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
264
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
265
+ end
266
+
267
+ self
268
+ end
269
+
270
+ # Deserializes the data based on type
271
+ # @param string type Data type
272
+ # @param string value Value to be deserialized
273
+ # @return [Object] Deserialized data
274
+ def _deserialize(type, value)
275
+ case type.to_sym
276
+ when :DateTime
277
+ DateTime.parse(value)
278
+ when :Date
279
+ Date.parse(value)
280
+ when :String
281
+ value.to_s
282
+ when :Integer
283
+ value.to_i
284
+ when :Float
285
+ value.to_f
286
+ when :BOOLEAN
287
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
288
+ true
289
+ else
290
+ false
291
+ end
292
+ when :Object
293
+ # generic object (usually a Hash), return directly
294
+ value
295
+ when /\AArray<(?<inner_type>.+)>\z/
296
+ inner_type = Regexp.last_match[:inner_type]
297
+ value.map { |v| _deserialize(inner_type, v) }
298
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
299
+ k_type = Regexp.last_match[:k_type]
300
+ v_type = Regexp.last_match[:v_type]
301
+ {}.tap do |hash|
302
+ value.each do |k, v|
303
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
304
+ end
305
+ end
306
+ else # model
307
+ temp_model = CyberSource.const_get(type).new
308
+ temp_model.build_from_hash(value)
309
+ end
310
+ end
311
+
312
+ # Returns the string representation of the object
313
+ # @return [String] String presentation of the object
314
+ def to_s
315
+ to_hash.to_s
316
+ end
317
+
318
+ # to_body is an alias to to_hash (backward compatibility)
319
+ # @return [Hash] Returns the object in the form of hash
320
+ def to_body
321
+ to_hash
322
+ end
323
+
324
+ # Returns the object in the form of hash
325
+ # @return [Hash] Returns the object in the form of hash
326
+ def to_hash
327
+ hash = {}
328
+ self.class.attribute_map.each_pair do |attr, param|
329
+ value = self.send(attr)
330
+ next if value.nil?
331
+ hash[param] = _to_hash(value)
332
+ end
333
+ hash
334
+ end
335
+
336
+ # Outputs non-array value in the form of hash
337
+ # For object, use to_hash. Otherwise, just return the value
338
+ # @param [Object] value Any valid value
339
+ # @return [Hash] Returns the value in the form of hash
340
+ def _to_hash(value)
341
+ if value.is_a?(Array)
342
+ value.compact.map { |v| _to_hash(v) }
343
+ elsif value.is_a?(Hash)
344
+ {}.tap do |hash|
345
+ value.each { |k, v| hash[k] = _to_hash(v) }
346
+ end
347
+ elsif value.respond_to? :to_hash
348
+ value.to_hash
349
+ else
350
+ value
351
+ end
352
+ end
353
+ end
354
+ end