bandwidth-sdk 14.0.0 → 14.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/README.md +42 -10
- data/bandwidth.yml +1102 -0
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +1204 -231
- data/coverage/index.html +20499 -10053
- data/custom_templates/README.mustache +6 -6
- data/docs/AdditionalDenialReason.md +22 -0
- data/docs/Address.md +30 -0
- data/docs/Contact.md +24 -0
- data/docs/Error.md +22 -0
- data/docs/FailureWebhook.md +28 -0
- data/docs/LinksObject.md +24 -0
- data/docs/OptInWorkflow.md +20 -0
- data/docs/TelephoneNumber.md +18 -0
- data/docs/TfvBasicAuthentication.md +20 -0
- data/docs/TfvCallbackStatusEnum.md +15 -0
- data/docs/TfvError.md +22 -0
- data/docs/TfvStatus.md +32 -0
- data/docs/TfvStatusEnum.md +15 -0
- data/docs/TfvSubmissionInfo.md +34 -0
- data/docs/TfvSubmissionWrapper.md +18 -0
- data/docs/TollFreeVerificationApi.md +585 -0
- data/docs/VerificationDenialWebhook.md +32 -0
- data/docs/VerificationRequest.md +36 -0
- data/docs/VerificationUpdateRequest.md +34 -0
- data/docs/VerificationWebhook.md +24 -0
- data/docs/WebhookSubscription.md +30 -0
- data/docs/WebhookSubscriptionBasicAuthentication.md +20 -0
- data/docs/WebhookSubscriptionRequestSchema.md +22 -0
- data/docs/WebhookSubscriptionTypeEnum.md +15 -0
- data/docs/WebhookSubscriptionsListBody.md +22 -0
- data/lib/bandwidth-sdk/api/toll_free_verification_api.rb +614 -0
- data/lib/bandwidth-sdk/configuration.rb +48 -0
- data/lib/bandwidth-sdk/models/additional_denial_reason.rb +254 -0
- data/lib/bandwidth-sdk/models/address.rb +501 -0
- data/lib/bandwidth-sdk/models/contact.rb +393 -0
- data/lib/bandwidth-sdk/models/error.rb +232 -0
- data/lib/bandwidth-sdk/models/failure_webhook.rb +304 -0
- data/lib/bandwidth-sdk/models/links_object.rb +243 -0
- data/lib/bandwidth-sdk/models/opt_in_workflow.rb +265 -0
- data/lib/bandwidth-sdk/models/telephone_number.rb +213 -0
- data/lib/bandwidth-sdk/models/tfv_basic_authentication.rb +273 -0
- data/lib/bandwidth-sdk/models/tfv_callback_status_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/tfv_error.rb +232 -0
- data/lib/bandwidth-sdk/models/tfv_status.rb +342 -0
- data/lib/bandwidth-sdk/models/tfv_status_enum.rb +43 -0
- data/lib/bandwidth-sdk/models/tfv_submission_info.rb +452 -0
- data/lib/bandwidth-sdk/models/tfv_submission_wrapper.rb +212 -0
- data/lib/bandwidth-sdk/models/verification_denial_webhook.rb +325 -0
- data/lib/bandwidth-sdk/models/verification_request.rb +547 -0
- data/lib/bandwidth-sdk/models/verification_update_request.rb +501 -0
- data/lib/bandwidth-sdk/models/verification_webhook.rb +303 -0
- data/lib/bandwidth-sdk/models/webhook_subscription.rb +328 -0
- data/lib/bandwidth-sdk/models/webhook_subscription_basic_authentication.rb +274 -0
- data/lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb +306 -0
- data/lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb +242 -0
- data/lib/bandwidth-sdk/version.rb +1 -1
- data/lib/bandwidth-sdk.rb +25 -0
- data/openapi-config.yml +1 -1
- data/spec/call_utils.rb +2 -2
- data/spec/smoke/toll_free_verification_api_spec.rb +69 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/api/mfa_api_spec.rb +1 -1
- data/spec/unit/api/toll_free_verification_api_spec.rb +278 -0
- data/spec/unit/client/api_client_spec.rb +1 -1
- metadata +100 -46
@@ -0,0 +1,501 @@
|
|
1
|
+
=begin
|
2
|
+
#Bandwidth
|
3
|
+
|
4
|
+
#Bandwidth's Communication APIs
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: letstalk@bandwidth.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.8.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Bandwidth
|
17
|
+
class VerificationUpdateRequest
|
18
|
+
attr_accessor :business_address
|
19
|
+
|
20
|
+
attr_accessor :business_contact
|
21
|
+
|
22
|
+
# Estimated monthly volume of messages from the toll-free number.
|
23
|
+
attr_accessor :message_volume
|
24
|
+
|
25
|
+
# The category of the use case.
|
26
|
+
attr_accessor :use_case
|
27
|
+
|
28
|
+
# A general idea of the use case and customer.
|
29
|
+
attr_accessor :use_case_summary
|
30
|
+
|
31
|
+
# Example of message content.
|
32
|
+
attr_accessor :production_message_content
|
33
|
+
|
34
|
+
attr_accessor :opt_in_workflow
|
35
|
+
|
36
|
+
# Any additional information.
|
37
|
+
attr_accessor :additional_information
|
38
|
+
|
39
|
+
# ISV name.
|
40
|
+
attr_accessor :isv_reseller
|
41
|
+
|
42
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
43
|
+
def self.attribute_map
|
44
|
+
{
|
45
|
+
:'business_address' => :'businessAddress',
|
46
|
+
:'business_contact' => :'businessContact',
|
47
|
+
:'message_volume' => :'messageVolume',
|
48
|
+
:'use_case' => :'useCase',
|
49
|
+
:'use_case_summary' => :'useCaseSummary',
|
50
|
+
:'production_message_content' => :'productionMessageContent',
|
51
|
+
:'opt_in_workflow' => :'optInWorkflow',
|
52
|
+
:'additional_information' => :'additionalInformation',
|
53
|
+
:'isv_reseller' => :'isvReseller'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns all the JSON keys this model knows about
|
58
|
+
def self.acceptable_attributes
|
59
|
+
attribute_map.values
|
60
|
+
end
|
61
|
+
|
62
|
+
# Attribute type mapping.
|
63
|
+
def self.openapi_types
|
64
|
+
{
|
65
|
+
:'business_address' => :'Address',
|
66
|
+
:'business_contact' => :'Contact',
|
67
|
+
:'message_volume' => :'Integer',
|
68
|
+
:'use_case' => :'String',
|
69
|
+
:'use_case_summary' => :'String',
|
70
|
+
:'production_message_content' => :'String',
|
71
|
+
:'opt_in_workflow' => :'OptInWorkflow',
|
72
|
+
:'additional_information' => :'String',
|
73
|
+
:'isv_reseller' => :'String'
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
# List of attributes with nullable: true
|
78
|
+
def self.openapi_nullable
|
79
|
+
Set.new([
|
80
|
+
:'additional_information',
|
81
|
+
:'isv_reseller'
|
82
|
+
])
|
83
|
+
end
|
84
|
+
|
85
|
+
# Initializes the object
|
86
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
87
|
+
def initialize(attributes = {})
|
88
|
+
if (!attributes.is_a?(Hash))
|
89
|
+
fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerificationUpdateRequest` initialize method'
|
90
|
+
end
|
91
|
+
|
92
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
93
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
94
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
95
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerificationUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
96
|
+
end
|
97
|
+
h[k.to_sym] = v
|
98
|
+
}
|
99
|
+
|
100
|
+
if attributes.key?(:'business_address')
|
101
|
+
self.business_address = attributes[:'business_address']
|
102
|
+
else
|
103
|
+
self.business_address = nil
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'business_contact')
|
107
|
+
self.business_contact = attributes[:'business_contact']
|
108
|
+
else
|
109
|
+
self.business_contact = nil
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:'message_volume')
|
113
|
+
self.message_volume = attributes[:'message_volume']
|
114
|
+
else
|
115
|
+
self.message_volume = nil
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'use_case')
|
119
|
+
self.use_case = attributes[:'use_case']
|
120
|
+
else
|
121
|
+
self.use_case = nil
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'use_case_summary')
|
125
|
+
self.use_case_summary = attributes[:'use_case_summary']
|
126
|
+
else
|
127
|
+
self.use_case_summary = nil
|
128
|
+
end
|
129
|
+
|
130
|
+
if attributes.key?(:'production_message_content')
|
131
|
+
self.production_message_content = attributes[:'production_message_content']
|
132
|
+
else
|
133
|
+
self.production_message_content = nil
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:'opt_in_workflow')
|
137
|
+
self.opt_in_workflow = attributes[:'opt_in_workflow']
|
138
|
+
else
|
139
|
+
self.opt_in_workflow = nil
|
140
|
+
end
|
141
|
+
|
142
|
+
if attributes.key?(:'additional_information')
|
143
|
+
self.additional_information = attributes[:'additional_information']
|
144
|
+
end
|
145
|
+
|
146
|
+
if attributes.key?(:'isv_reseller')
|
147
|
+
self.isv_reseller = attributes[:'isv_reseller']
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
152
|
+
# @return Array for valid properties with the reasons
|
153
|
+
def list_invalid_properties
|
154
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
155
|
+
invalid_properties = Array.new
|
156
|
+
if @business_address.nil?
|
157
|
+
invalid_properties.push('invalid value for "business_address", business_address cannot be nil.')
|
158
|
+
end
|
159
|
+
|
160
|
+
if @business_contact.nil?
|
161
|
+
invalid_properties.push('invalid value for "business_contact", business_contact cannot be nil.')
|
162
|
+
end
|
163
|
+
|
164
|
+
if @message_volume.nil?
|
165
|
+
invalid_properties.push('invalid value for "message_volume", message_volume cannot be nil.')
|
166
|
+
end
|
167
|
+
|
168
|
+
if @message_volume > 10000000
|
169
|
+
invalid_properties.push('invalid value for "message_volume", must be smaller than or equal to 10000000.')
|
170
|
+
end
|
171
|
+
|
172
|
+
if @message_volume < 10
|
173
|
+
invalid_properties.push('invalid value for "message_volume", must be greater than or equal to 10.')
|
174
|
+
end
|
175
|
+
|
176
|
+
if @use_case.nil?
|
177
|
+
invalid_properties.push('invalid value for "use_case", use_case cannot be nil.')
|
178
|
+
end
|
179
|
+
|
180
|
+
if @use_case.to_s.length > 500
|
181
|
+
invalid_properties.push('invalid value for "use_case", the character length must be smaller than or equal to 500.')
|
182
|
+
end
|
183
|
+
|
184
|
+
if @use_case.to_s.length < 0
|
185
|
+
invalid_properties.push('invalid value for "use_case", the character length must be great than or equal to 0.')
|
186
|
+
end
|
187
|
+
|
188
|
+
if @use_case_summary.nil?
|
189
|
+
invalid_properties.push('invalid value for "use_case_summary", use_case_summary cannot be nil.')
|
190
|
+
end
|
191
|
+
|
192
|
+
if @use_case_summary.to_s.length > 500
|
193
|
+
invalid_properties.push('invalid value for "use_case_summary", the character length must be smaller than or equal to 500.')
|
194
|
+
end
|
195
|
+
|
196
|
+
if @use_case_summary.to_s.length < 0
|
197
|
+
invalid_properties.push('invalid value for "use_case_summary", the character length must be great than or equal to 0.')
|
198
|
+
end
|
199
|
+
|
200
|
+
if @production_message_content.nil?
|
201
|
+
invalid_properties.push('invalid value for "production_message_content", production_message_content cannot be nil.')
|
202
|
+
end
|
203
|
+
|
204
|
+
if @production_message_content.to_s.length > 500
|
205
|
+
invalid_properties.push('invalid value for "production_message_content", the character length must be smaller than or equal to 500.')
|
206
|
+
end
|
207
|
+
|
208
|
+
if @production_message_content.to_s.length < 0
|
209
|
+
invalid_properties.push('invalid value for "production_message_content", the character length must be great than or equal to 0.')
|
210
|
+
end
|
211
|
+
|
212
|
+
if @opt_in_workflow.nil?
|
213
|
+
invalid_properties.push('invalid value for "opt_in_workflow", opt_in_workflow cannot be nil.')
|
214
|
+
end
|
215
|
+
|
216
|
+
if !@additional_information.nil? && @additional_information.to_s.length > 500
|
217
|
+
invalid_properties.push('invalid value for "additional_information", the character length must be smaller than or equal to 500.')
|
218
|
+
end
|
219
|
+
|
220
|
+
if !@additional_information.nil? && @additional_information.to_s.length < 0
|
221
|
+
invalid_properties.push('invalid value for "additional_information", the character length must be great than or equal to 0.')
|
222
|
+
end
|
223
|
+
|
224
|
+
if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
|
225
|
+
invalid_properties.push('invalid value for "isv_reseller", the character length must be smaller than or equal to 500.')
|
226
|
+
end
|
227
|
+
|
228
|
+
if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
|
229
|
+
invalid_properties.push('invalid value for "isv_reseller", the character length must be great than or equal to 0.')
|
230
|
+
end
|
231
|
+
|
232
|
+
invalid_properties
|
233
|
+
end
|
234
|
+
|
235
|
+
# Check to see if the all the properties in the model are valid
|
236
|
+
# @return true if the model is valid
|
237
|
+
def valid?
|
238
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
239
|
+
return false if @business_address.nil?
|
240
|
+
return false if @business_contact.nil?
|
241
|
+
return false if @message_volume.nil?
|
242
|
+
return false if @message_volume > 10000000
|
243
|
+
return false if @message_volume < 10
|
244
|
+
return false if @use_case.nil?
|
245
|
+
return false if @use_case.to_s.length > 500
|
246
|
+
return false if @use_case.to_s.length < 0
|
247
|
+
return false if @use_case_summary.nil?
|
248
|
+
return false if @use_case_summary.to_s.length > 500
|
249
|
+
return false if @use_case_summary.to_s.length < 0
|
250
|
+
return false if @production_message_content.nil?
|
251
|
+
return false if @production_message_content.to_s.length > 500
|
252
|
+
return false if @production_message_content.to_s.length < 0
|
253
|
+
return false if @opt_in_workflow.nil?
|
254
|
+
return false if !@additional_information.nil? && @additional_information.to_s.length > 500
|
255
|
+
return false if !@additional_information.nil? && @additional_information.to_s.length < 0
|
256
|
+
return false if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
|
257
|
+
return false if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
|
258
|
+
true
|
259
|
+
end
|
260
|
+
|
261
|
+
# Custom attribute writer method with validation
|
262
|
+
# @param [Object] message_volume Value to be assigned
|
263
|
+
def message_volume=(message_volume)
|
264
|
+
if message_volume.nil?
|
265
|
+
fail ArgumentError, 'message_volume cannot be nil'
|
266
|
+
end
|
267
|
+
|
268
|
+
if message_volume > 10000000
|
269
|
+
fail ArgumentError, 'invalid value for "message_volume", must be smaller than or equal to 10000000.'
|
270
|
+
end
|
271
|
+
|
272
|
+
if message_volume < 10
|
273
|
+
fail ArgumentError, 'invalid value for "message_volume", must be greater than or equal to 10.'
|
274
|
+
end
|
275
|
+
|
276
|
+
@message_volume = message_volume
|
277
|
+
end
|
278
|
+
|
279
|
+
# Custom attribute writer method with validation
|
280
|
+
# @param [Object] use_case Value to be assigned
|
281
|
+
def use_case=(use_case)
|
282
|
+
if use_case.nil?
|
283
|
+
fail ArgumentError, 'use_case cannot be nil'
|
284
|
+
end
|
285
|
+
|
286
|
+
if use_case.to_s.length > 500
|
287
|
+
fail ArgumentError, 'invalid value for "use_case", the character length must be smaller than or equal to 500.'
|
288
|
+
end
|
289
|
+
|
290
|
+
if use_case.to_s.length < 0
|
291
|
+
fail ArgumentError, 'invalid value for "use_case", the character length must be great than or equal to 0.'
|
292
|
+
end
|
293
|
+
|
294
|
+
@use_case = use_case
|
295
|
+
end
|
296
|
+
|
297
|
+
# Custom attribute writer method with validation
|
298
|
+
# @param [Object] use_case_summary Value to be assigned
|
299
|
+
def use_case_summary=(use_case_summary)
|
300
|
+
if use_case_summary.nil?
|
301
|
+
fail ArgumentError, 'use_case_summary cannot be nil'
|
302
|
+
end
|
303
|
+
|
304
|
+
if use_case_summary.to_s.length > 500
|
305
|
+
fail ArgumentError, 'invalid value for "use_case_summary", the character length must be smaller than or equal to 500.'
|
306
|
+
end
|
307
|
+
|
308
|
+
if use_case_summary.to_s.length < 0
|
309
|
+
fail ArgumentError, 'invalid value for "use_case_summary", the character length must be great than or equal to 0.'
|
310
|
+
end
|
311
|
+
|
312
|
+
@use_case_summary = use_case_summary
|
313
|
+
end
|
314
|
+
|
315
|
+
# Custom attribute writer method with validation
|
316
|
+
# @param [Object] production_message_content Value to be assigned
|
317
|
+
def production_message_content=(production_message_content)
|
318
|
+
if production_message_content.nil?
|
319
|
+
fail ArgumentError, 'production_message_content cannot be nil'
|
320
|
+
end
|
321
|
+
|
322
|
+
if production_message_content.to_s.length > 500
|
323
|
+
fail ArgumentError, 'invalid value for "production_message_content", the character length must be smaller than or equal to 500.'
|
324
|
+
end
|
325
|
+
|
326
|
+
if production_message_content.to_s.length < 0
|
327
|
+
fail ArgumentError, 'invalid value for "production_message_content", the character length must be great than or equal to 0.'
|
328
|
+
end
|
329
|
+
|
330
|
+
@production_message_content = production_message_content
|
331
|
+
end
|
332
|
+
|
333
|
+
# Custom attribute writer method with validation
|
334
|
+
# @param [Object] additional_information Value to be assigned
|
335
|
+
def additional_information=(additional_information)
|
336
|
+
if !additional_information.nil? && additional_information.to_s.length > 500
|
337
|
+
fail ArgumentError, 'invalid value for "additional_information", the character length must be smaller than or equal to 500.'
|
338
|
+
end
|
339
|
+
|
340
|
+
if !additional_information.nil? && additional_information.to_s.length < 0
|
341
|
+
fail ArgumentError, 'invalid value for "additional_information", the character length must be great than or equal to 0.'
|
342
|
+
end
|
343
|
+
|
344
|
+
@additional_information = additional_information
|
345
|
+
end
|
346
|
+
|
347
|
+
# Custom attribute writer method with validation
|
348
|
+
# @param [Object] isv_reseller Value to be assigned
|
349
|
+
def isv_reseller=(isv_reseller)
|
350
|
+
if !isv_reseller.nil? && isv_reseller.to_s.length > 500
|
351
|
+
fail ArgumentError, 'invalid value for "isv_reseller", the character length must be smaller than or equal to 500.'
|
352
|
+
end
|
353
|
+
|
354
|
+
if !isv_reseller.nil? && isv_reseller.to_s.length < 0
|
355
|
+
fail ArgumentError, 'invalid value for "isv_reseller", the character length must be great than or equal to 0.'
|
356
|
+
end
|
357
|
+
|
358
|
+
@isv_reseller = isv_reseller
|
359
|
+
end
|
360
|
+
|
361
|
+
# Checks equality by comparing each attribute.
|
362
|
+
# @param [Object] Object to be compared
|
363
|
+
def ==(o)
|
364
|
+
return true if self.equal?(o)
|
365
|
+
self.class == o.class &&
|
366
|
+
business_address == o.business_address &&
|
367
|
+
business_contact == o.business_contact &&
|
368
|
+
message_volume == o.message_volume &&
|
369
|
+
use_case == o.use_case &&
|
370
|
+
use_case_summary == o.use_case_summary &&
|
371
|
+
production_message_content == o.production_message_content &&
|
372
|
+
opt_in_workflow == o.opt_in_workflow &&
|
373
|
+
additional_information == o.additional_information &&
|
374
|
+
isv_reseller == o.isv_reseller
|
375
|
+
end
|
376
|
+
|
377
|
+
# @see the `==` method
|
378
|
+
# @param [Object] Object to be compared
|
379
|
+
def eql?(o)
|
380
|
+
self == o
|
381
|
+
end
|
382
|
+
|
383
|
+
# Calculates hash code according to all attributes.
|
384
|
+
# @return [Integer] Hash code
|
385
|
+
def hash
|
386
|
+
[business_address, business_contact, message_volume, use_case, use_case_summary, production_message_content, opt_in_workflow, additional_information, isv_reseller].hash
|
387
|
+
end
|
388
|
+
|
389
|
+
# Builds the object from hash
|
390
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
391
|
+
# @return [Object] Returns the model itself
|
392
|
+
def self.build_from_hash(attributes)
|
393
|
+
return nil unless attributes.is_a?(Hash)
|
394
|
+
attributes = attributes.transform_keys(&:to_sym)
|
395
|
+
transformed_hash = {}
|
396
|
+
openapi_types.each_pair do |key, type|
|
397
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
398
|
+
transformed_hash["#{key}"] = nil
|
399
|
+
elsif type =~ /\AArray<(.*)>/i
|
400
|
+
# check to ensure the input is an array given that the attribute
|
401
|
+
# is documented as an array but the input is not
|
402
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
403
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
404
|
+
end
|
405
|
+
elsif !attributes[attribute_map[key]].nil?
|
406
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
407
|
+
end
|
408
|
+
end
|
409
|
+
new(transformed_hash)
|
410
|
+
end
|
411
|
+
|
412
|
+
# Deserializes the data based on type
|
413
|
+
# @param string type Data type
|
414
|
+
# @param string value Value to be deserialized
|
415
|
+
# @return [Object] Deserialized data
|
416
|
+
def self._deserialize(type, value)
|
417
|
+
case type.to_sym
|
418
|
+
when :Time
|
419
|
+
Time.parse(value)
|
420
|
+
when :Date
|
421
|
+
Date.parse(value)
|
422
|
+
when :String
|
423
|
+
value.to_s
|
424
|
+
when :Integer
|
425
|
+
value.to_i
|
426
|
+
when :Float
|
427
|
+
value.to_f
|
428
|
+
when :Boolean
|
429
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
430
|
+
true
|
431
|
+
else
|
432
|
+
false
|
433
|
+
end
|
434
|
+
when :Object
|
435
|
+
# generic object (usually a Hash), return directly
|
436
|
+
value
|
437
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
438
|
+
inner_type = Regexp.last_match[:inner_type]
|
439
|
+
value.map { |v| _deserialize(inner_type, v) }
|
440
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
441
|
+
k_type = Regexp.last_match[:k_type]
|
442
|
+
v_type = Regexp.last_match[:v_type]
|
443
|
+
{}.tap do |hash|
|
444
|
+
value.each do |k, v|
|
445
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
else # model
|
449
|
+
# models (e.g. Pet) or oneOf
|
450
|
+
klass = Bandwidth.const_get(type)
|
451
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
# Returns the string representation of the object
|
456
|
+
# @return [String] String presentation of the object
|
457
|
+
def to_s
|
458
|
+
to_hash.to_s
|
459
|
+
end
|
460
|
+
|
461
|
+
# to_body is an alias to to_hash (backward compatibility)
|
462
|
+
# @return [Hash] Returns the object in the form of hash
|
463
|
+
def to_body
|
464
|
+
to_hash
|
465
|
+
end
|
466
|
+
|
467
|
+
# Returns the object in the form of hash
|
468
|
+
# @return [Hash] Returns the object in the form of hash
|
469
|
+
def to_hash
|
470
|
+
hash = {}
|
471
|
+
self.class.attribute_map.each_pair do |attr, param|
|
472
|
+
value = self.send(attr)
|
473
|
+
if value.nil?
|
474
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
475
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
476
|
+
end
|
477
|
+
|
478
|
+
hash[param] = _to_hash(value)
|
479
|
+
end
|
480
|
+
hash
|
481
|
+
end
|
482
|
+
|
483
|
+
# Outputs non-array value in the form of hash
|
484
|
+
# For object, use to_hash. Otherwise, just return the value
|
485
|
+
# @param [Object] value Any valid value
|
486
|
+
# @return [Hash] Returns the value in the form of hash
|
487
|
+
def _to_hash(value)
|
488
|
+
if value.is_a?(Array)
|
489
|
+
value.compact.map { |v| _to_hash(v) }
|
490
|
+
elsif value.is_a?(Hash)
|
491
|
+
{}.tap do |hash|
|
492
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
493
|
+
end
|
494
|
+
elsif value.respond_to? :to_hash
|
495
|
+
value.to_hash
|
496
|
+
else
|
497
|
+
value
|
498
|
+
end
|
499
|
+
end
|
500
|
+
end
|
501
|
+
end
|