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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +9 -9
  3. data/README.md +42 -10
  4. data/bandwidth.yml +1102 -0
  5. data/coverage/.last_run.json +1 -1
  6. data/coverage/.resultset.json +1204 -231
  7. data/coverage/index.html +20499 -10053
  8. data/custom_templates/README.mustache +6 -6
  9. data/docs/AdditionalDenialReason.md +22 -0
  10. data/docs/Address.md +30 -0
  11. data/docs/Contact.md +24 -0
  12. data/docs/Error.md +22 -0
  13. data/docs/FailureWebhook.md +28 -0
  14. data/docs/LinksObject.md +24 -0
  15. data/docs/OptInWorkflow.md +20 -0
  16. data/docs/TelephoneNumber.md +18 -0
  17. data/docs/TfvBasicAuthentication.md +20 -0
  18. data/docs/TfvCallbackStatusEnum.md +15 -0
  19. data/docs/TfvError.md +22 -0
  20. data/docs/TfvStatus.md +32 -0
  21. data/docs/TfvStatusEnum.md +15 -0
  22. data/docs/TfvSubmissionInfo.md +34 -0
  23. data/docs/TfvSubmissionWrapper.md +18 -0
  24. data/docs/TollFreeVerificationApi.md +585 -0
  25. data/docs/VerificationDenialWebhook.md +32 -0
  26. data/docs/VerificationRequest.md +36 -0
  27. data/docs/VerificationUpdateRequest.md +34 -0
  28. data/docs/VerificationWebhook.md +24 -0
  29. data/docs/WebhookSubscription.md +30 -0
  30. data/docs/WebhookSubscriptionBasicAuthentication.md +20 -0
  31. data/docs/WebhookSubscriptionRequestSchema.md +22 -0
  32. data/docs/WebhookSubscriptionTypeEnum.md +15 -0
  33. data/docs/WebhookSubscriptionsListBody.md +22 -0
  34. data/lib/bandwidth-sdk/api/toll_free_verification_api.rb +614 -0
  35. data/lib/bandwidth-sdk/configuration.rb +48 -0
  36. data/lib/bandwidth-sdk/models/additional_denial_reason.rb +254 -0
  37. data/lib/bandwidth-sdk/models/address.rb +501 -0
  38. data/lib/bandwidth-sdk/models/contact.rb +393 -0
  39. data/lib/bandwidth-sdk/models/error.rb +232 -0
  40. data/lib/bandwidth-sdk/models/failure_webhook.rb +304 -0
  41. data/lib/bandwidth-sdk/models/links_object.rb +243 -0
  42. data/lib/bandwidth-sdk/models/opt_in_workflow.rb +265 -0
  43. data/lib/bandwidth-sdk/models/telephone_number.rb +213 -0
  44. data/lib/bandwidth-sdk/models/tfv_basic_authentication.rb +273 -0
  45. data/lib/bandwidth-sdk/models/tfv_callback_status_enum.rb +40 -0
  46. data/lib/bandwidth-sdk/models/tfv_error.rb +232 -0
  47. data/lib/bandwidth-sdk/models/tfv_status.rb +342 -0
  48. data/lib/bandwidth-sdk/models/tfv_status_enum.rb +43 -0
  49. data/lib/bandwidth-sdk/models/tfv_submission_info.rb +452 -0
  50. data/lib/bandwidth-sdk/models/tfv_submission_wrapper.rb +212 -0
  51. data/lib/bandwidth-sdk/models/verification_denial_webhook.rb +325 -0
  52. data/lib/bandwidth-sdk/models/verification_request.rb +547 -0
  53. data/lib/bandwidth-sdk/models/verification_update_request.rb +501 -0
  54. data/lib/bandwidth-sdk/models/verification_webhook.rb +303 -0
  55. data/lib/bandwidth-sdk/models/webhook_subscription.rb +328 -0
  56. data/lib/bandwidth-sdk/models/webhook_subscription_basic_authentication.rb +274 -0
  57. data/lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb +306 -0
  58. data/lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb +40 -0
  59. data/lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb +242 -0
  60. data/lib/bandwidth-sdk/version.rb +1 -1
  61. data/lib/bandwidth-sdk.rb +25 -0
  62. data/openapi-config.yml +1 -1
  63. data/spec/call_utils.rb +2 -2
  64. data/spec/smoke/toll_free_verification_api_spec.rb +69 -0
  65. data/spec/spec_helper.rb +1 -1
  66. data/spec/unit/api/mfa_api_spec.rb +1 -1
  67. data/spec/unit/api/toll_free_verification_api_spec.rb +278 -0
  68. data/spec/unit/client/api_client_spec.rb +1 -1
  69. metadata +100 -46
@@ -0,0 +1,274 @@
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
+ # Basic authentication credentials are not required, but if present, both username and password must be provided.
18
+ class WebhookSubscriptionBasicAuthentication
19
+ attr_accessor :username
20
+
21
+ attr_accessor :password
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'username' => :'username',
27
+ :'password' => :'password'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'username' => :'String',
40
+ :'password' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscriptionBasicAuthentication` initialize method'
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscriptionBasicAuthentication`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'username')
66
+ self.username = attributes[:'username']
67
+ else
68
+ self.username = nil
69
+ end
70
+
71
+ if attributes.key?(:'password')
72
+ self.password = attributes[:'password']
73
+ else
74
+ self.password = nil
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
+ invalid_properties = Array.new
83
+ if @username.nil?
84
+ invalid_properties.push('invalid value for "username", username cannot be nil.')
85
+ end
86
+
87
+ if @username.to_s.length > 100
88
+ invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 100.')
89
+ end
90
+
91
+ if @password.nil?
92
+ invalid_properties.push('invalid value for "password", password cannot be nil.')
93
+ end
94
+
95
+ if @password.to_s.length > 200
96
+ invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 200.')
97
+ end
98
+
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ warn '[DEPRECATED] the `valid?` method is obsolete'
106
+ return false if @username.nil?
107
+ return false if @username.to_s.length > 100
108
+ return false if @password.nil?
109
+ return false if @password.to_s.length > 200
110
+ true
111
+ end
112
+
113
+ # Custom attribute writer method with validation
114
+ # @param [Object] username Value to be assigned
115
+ def username=(username)
116
+ if username.nil?
117
+ fail ArgumentError, 'username cannot be nil'
118
+ end
119
+
120
+ if username.to_s.length > 100
121
+ fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 100.'
122
+ end
123
+
124
+ @username = username
125
+ end
126
+
127
+ # Custom attribute writer method with validation
128
+ # @param [Object] password Value to be assigned
129
+ def password=(password)
130
+ if password.nil?
131
+ fail ArgumentError, 'password cannot be nil'
132
+ end
133
+
134
+ if password.to_s.length > 200
135
+ fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 200.'
136
+ end
137
+
138
+ @password = password
139
+ end
140
+
141
+ # Checks equality by comparing each attribute.
142
+ # @param [Object] Object to be compared
143
+ def ==(o)
144
+ return true if self.equal?(o)
145
+ self.class == o.class &&
146
+ username == o.username &&
147
+ password == o.password
148
+ end
149
+
150
+ # @see the `==` method
151
+ # @param [Object] Object to be compared
152
+ def eql?(o)
153
+ self == o
154
+ end
155
+
156
+ # Calculates hash code according to all attributes.
157
+ # @return [Integer] Hash code
158
+ def hash
159
+ [username, password].hash
160
+ end
161
+
162
+ # Builds the object from hash
163
+ # @param [Hash] attributes Model attributes in the form of hash
164
+ # @return [Object] Returns the model itself
165
+ def self.build_from_hash(attributes)
166
+ return nil unless attributes.is_a?(Hash)
167
+ attributes = attributes.transform_keys(&:to_sym)
168
+ transformed_hash = {}
169
+ openapi_types.each_pair do |key, type|
170
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
171
+ transformed_hash["#{key}"] = nil
172
+ elsif type =~ /\AArray<(.*)>/i
173
+ # check to ensure the input is an array given that the attribute
174
+ # is documented as an array but the input is not
175
+ if attributes[attribute_map[key]].is_a?(Array)
176
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
177
+ end
178
+ elsif !attributes[attribute_map[key]].nil?
179
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
180
+ end
181
+ end
182
+ new(transformed_hash)
183
+ end
184
+
185
+ # Deserializes the data based on type
186
+ # @param string type Data type
187
+ # @param string value Value to be deserialized
188
+ # @return [Object] Deserialized data
189
+ def self._deserialize(type, value)
190
+ case type.to_sym
191
+ when :Time
192
+ Time.parse(value)
193
+ when :Date
194
+ Date.parse(value)
195
+ when :String
196
+ value.to_s
197
+ when :Integer
198
+ value.to_i
199
+ when :Float
200
+ value.to_f
201
+ when :Boolean
202
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
203
+ true
204
+ else
205
+ false
206
+ end
207
+ when :Object
208
+ # generic object (usually a Hash), return directly
209
+ value
210
+ when /\AArray<(?<inner_type>.+)>\z/
211
+ inner_type = Regexp.last_match[:inner_type]
212
+ value.map { |v| _deserialize(inner_type, v) }
213
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
214
+ k_type = Regexp.last_match[:k_type]
215
+ v_type = Regexp.last_match[:v_type]
216
+ {}.tap do |hash|
217
+ value.each do |k, v|
218
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
219
+ end
220
+ end
221
+ else # model
222
+ # models (e.g. Pet) or oneOf
223
+ klass = Bandwidth.const_get(type)
224
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
225
+ end
226
+ end
227
+
228
+ # Returns the string representation of the object
229
+ # @return [String] String presentation of the object
230
+ def to_s
231
+ to_hash.to_s
232
+ end
233
+
234
+ # to_body is an alias to to_hash (backward compatibility)
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_body
237
+ to_hash
238
+ end
239
+
240
+ # Returns the object in the form of hash
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_hash
243
+ hash = {}
244
+ self.class.attribute_map.each_pair do |attr, param|
245
+ value = self.send(attr)
246
+ if value.nil?
247
+ is_nullable = self.class.openapi_nullable.include?(attr)
248
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
+ end
250
+
251
+ hash[param] = _to_hash(value)
252
+ end
253
+ hash
254
+ end
255
+
256
+ # Outputs non-array value in the form of hash
257
+ # For object, use to_hash. Otherwise, just return the value
258
+ # @param [Object] value Any valid value
259
+ # @return [Hash] Returns the value in the form of hash
260
+ def _to_hash(value)
261
+ if value.is_a?(Array)
262
+ value.compact.map { |v| _to_hash(v) }
263
+ elsif value.is_a?(Hash)
264
+ {}.tap do |hash|
265
+ value.each { |k, v| hash[k] = _to_hash(v) }
266
+ end
267
+ elsif value.respond_to? :to_hash
268
+ value.to_hash
269
+ else
270
+ value
271
+ end
272
+ end
273
+ end
274
+ end
@@ -0,0 +1,306 @@
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 WebhookSubscriptionRequestSchema
18
+ attr_accessor :basic_authentication
19
+
20
+ # Callback URL to receive status updates from Bandwidth. When a webhook subscription is registered with Bandwidth under a given account ID, it will be used to send status updates for all requests submitted under that account ID.
21
+ attr_accessor :callback_url
22
+
23
+ # An ASCII string submitted by the user as a shared secret key for generating an HMAC header for callbacks.
24
+ attr_accessor :shared_secret_key
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'basic_authentication' => :'basicAuthentication',
30
+ :'callback_url' => :'callbackUrl',
31
+ :'shared_secret_key' => :'sharedSecretKey'
32
+ }
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'basic_authentication' => :'TfvBasicAuthentication',
44
+ :'callback_url' => :'String',
45
+ :'shared_secret_key' => :'String'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ :'callback_url',
53
+ :'shared_secret_key'
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscriptionRequestSchema` initialize method'
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscriptionRequestSchema`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'basic_authentication')
73
+ self.basic_authentication = attributes[:'basic_authentication']
74
+ end
75
+
76
+ if attributes.key?(:'callback_url')
77
+ self.callback_url = attributes[:'callback_url']
78
+ else
79
+ self.callback_url = nil
80
+ end
81
+
82
+ if attributes.key?(:'shared_secret_key')
83
+ self.shared_secret_key = attributes[:'shared_secret_key']
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
91
+ invalid_properties = Array.new
92
+ if @callback_url.to_s.length > 2000
93
+ invalid_properties.push('invalid value for "callback_url", the character length must be smaller than or equal to 2000.')
94
+ end
95
+
96
+ if @callback_url.to_s.length < 0
97
+ invalid_properties.push('invalid value for "callback_url", the character length must be great than or equal to 0.')
98
+ end
99
+
100
+ pattern = Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
101
+ if @callback_url !~ pattern
102
+ invalid_properties.push("invalid value for \"callback_url\", must conform to the pattern #{pattern}.")
103
+ end
104
+
105
+ if !@shared_secret_key.nil? && @shared_secret_key.to_s.length > 64
106
+ invalid_properties.push('invalid value for "shared_secret_key", the character length must be smaller than or equal to 64.')
107
+ end
108
+
109
+ if !@shared_secret_key.nil? && @shared_secret_key.to_s.length < 16
110
+ invalid_properties.push('invalid value for "shared_secret_key", the character length must be great than or equal to 16.')
111
+ end
112
+
113
+ pattern = Regexp.new(/^[ -~]{16,64}$/)
114
+ if !@shared_secret_key.nil? && @shared_secret_key !~ pattern
115
+ invalid_properties.push("invalid value for \"shared_secret_key\", must conform to the pattern #{pattern}.")
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ warn '[DEPRECATED] the `valid?` method is obsolete'
125
+ return false if @callback_url.to_s.length > 2000
126
+ return false if @callback_url.to_s.length < 0
127
+ return false if @callback_url !~ Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
128
+ return false if !@shared_secret_key.nil? && @shared_secret_key.to_s.length > 64
129
+ return false if !@shared_secret_key.nil? && @shared_secret_key.to_s.length < 16
130
+ return false if !@shared_secret_key.nil? && @shared_secret_key !~ Regexp.new(/^[ -~]{16,64}$/)
131
+ true
132
+ end
133
+
134
+ # Custom attribute writer method with validation
135
+ # @param [Object] callback_url Value to be assigned
136
+ def callback_url=(callback_url)
137
+ if !callback_url.nil? && callback_url.to_s.length > 2000
138
+ fail ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2000.'
139
+ end
140
+
141
+ if !callback_url.nil? && callback_url.to_s.length < 0
142
+ fail ArgumentError, 'invalid value for "callback_url", the character length must be great than or equal to 0.'
143
+ end
144
+
145
+ pattern = Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
146
+ if !callback_url.nil? && callback_url !~ pattern
147
+ fail ArgumentError, "invalid value for \"callback_url\", must conform to the pattern #{pattern}."
148
+ end
149
+
150
+ @callback_url = callback_url
151
+ end
152
+
153
+ # Custom attribute writer method with validation
154
+ # @param [Object] shared_secret_key Value to be assigned
155
+ def shared_secret_key=(shared_secret_key)
156
+ if !shared_secret_key.nil? && shared_secret_key.to_s.length > 64
157
+ fail ArgumentError, 'invalid value for "shared_secret_key", the character length must be smaller than or equal to 64.'
158
+ end
159
+
160
+ if !shared_secret_key.nil? && shared_secret_key.to_s.length < 16
161
+ fail ArgumentError, 'invalid value for "shared_secret_key", the character length must be great than or equal to 16.'
162
+ end
163
+
164
+ pattern = Regexp.new(/^[ -~]{16,64}$/)
165
+ if !shared_secret_key.nil? && shared_secret_key !~ pattern
166
+ fail ArgumentError, "invalid value for \"shared_secret_key\", must conform to the pattern #{pattern}."
167
+ end
168
+
169
+ @shared_secret_key = shared_secret_key
170
+ end
171
+
172
+ # Checks equality by comparing each attribute.
173
+ # @param [Object] Object to be compared
174
+ def ==(o)
175
+ return true if self.equal?(o)
176
+ self.class == o.class &&
177
+ basic_authentication == o.basic_authentication &&
178
+ callback_url == o.callback_url &&
179
+ shared_secret_key == o.shared_secret_key
180
+ end
181
+
182
+ # @see the `==` method
183
+ # @param [Object] Object to be compared
184
+ def eql?(o)
185
+ self == o
186
+ end
187
+
188
+ # Calculates hash code according to all attributes.
189
+ # @return [Integer] Hash code
190
+ def hash
191
+ [basic_authentication, callback_url, shared_secret_key].hash
192
+ end
193
+
194
+ # Builds the object from hash
195
+ # @param [Hash] attributes Model attributes in the form of hash
196
+ # @return [Object] Returns the model itself
197
+ def self.build_from_hash(attributes)
198
+ return nil unless attributes.is_a?(Hash)
199
+ attributes = attributes.transform_keys(&:to_sym)
200
+ transformed_hash = {}
201
+ openapi_types.each_pair do |key, type|
202
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
203
+ transformed_hash["#{key}"] = nil
204
+ elsif type =~ /\AArray<(.*)>/i
205
+ # check to ensure the input is an array given that the attribute
206
+ # is documented as an array but the input is not
207
+ if attributes[attribute_map[key]].is_a?(Array)
208
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
209
+ end
210
+ elsif !attributes[attribute_map[key]].nil?
211
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
212
+ end
213
+ end
214
+ new(transformed_hash)
215
+ end
216
+
217
+ # Deserializes the data based on type
218
+ # @param string type Data type
219
+ # @param string value Value to be deserialized
220
+ # @return [Object] Deserialized data
221
+ def self._deserialize(type, value)
222
+ case type.to_sym
223
+ when :Time
224
+ Time.parse(value)
225
+ when :Date
226
+ Date.parse(value)
227
+ when :String
228
+ value.to_s
229
+ when :Integer
230
+ value.to_i
231
+ when :Float
232
+ value.to_f
233
+ when :Boolean
234
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
235
+ true
236
+ else
237
+ false
238
+ end
239
+ when :Object
240
+ # generic object (usually a Hash), return directly
241
+ value
242
+ when /\AArray<(?<inner_type>.+)>\z/
243
+ inner_type = Regexp.last_match[:inner_type]
244
+ value.map { |v| _deserialize(inner_type, v) }
245
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
246
+ k_type = Regexp.last_match[:k_type]
247
+ v_type = Regexp.last_match[:v_type]
248
+ {}.tap do |hash|
249
+ value.each do |k, v|
250
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
251
+ end
252
+ end
253
+ else # model
254
+ # models (e.g. Pet) or oneOf
255
+ klass = Bandwidth.const_get(type)
256
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
257
+ end
258
+ end
259
+
260
+ # Returns the string representation of the object
261
+ # @return [String] String presentation of the object
262
+ def to_s
263
+ to_hash.to_s
264
+ end
265
+
266
+ # to_body is an alias to to_hash (backward compatibility)
267
+ # @return [Hash] Returns the object in the form of hash
268
+ def to_body
269
+ to_hash
270
+ end
271
+
272
+ # Returns the object in the form of hash
273
+ # @return [Hash] Returns the object in the form of hash
274
+ def to_hash
275
+ hash = {}
276
+ self.class.attribute_map.each_pair do |attr, param|
277
+ value = self.send(attr)
278
+ if value.nil?
279
+ is_nullable = self.class.openapi_nullable.include?(attr)
280
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
281
+ end
282
+
283
+ hash[param] = _to_hash(value)
284
+ end
285
+ hash
286
+ end
287
+
288
+ # Outputs non-array value in the form of hash
289
+ # For object, use to_hash. Otherwise, just return the value
290
+ # @param [Object] value Any valid value
291
+ # @return [Hash] Returns the value in the form of hash
292
+ def _to_hash(value)
293
+ if value.is_a?(Array)
294
+ value.compact.map { |v| _to_hash(v) }
295
+ elsif value.is_a?(Hash)
296
+ {}.tap do |hash|
297
+ value.each { |k, v| hash[k] = _to_hash(v) }
298
+ end
299
+ elsif value.respond_to? :to_hash
300
+ value.to_hash
301
+ else
302
+ value
303
+ end
304
+ end
305
+ end
306
+ end
@@ -0,0 +1,40 @@
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 WebhookSubscriptionTypeEnum
18
+ TOLLFREE_VERIFICATION_STATUS = 'TOLLFREE_VERIFICATION_STATUS'.freeze
19
+ MESSAGING_PORTOUT_APPROVAL_STATUS = 'MESSAGING_PORTOUT_APPROVAL_STATUS'.freeze
20
+
21
+ def self.all_vars
22
+ @all_vars ||= [TOLLFREE_VERIFICATION_STATUS, MESSAGING_PORTOUT_APPROVAL_STATUS].freeze
23
+ end
24
+
25
+ # Builds the enum from string
26
+ # @param [String] The enum value in the form of the string
27
+ # @return [String] The enum value
28
+ def self.build_from_hash(value)
29
+ new.build_from_hash(value)
30
+ end
31
+
32
+ # Builds the enum from string
33
+ # @param [String] The enum value in the form of the string
34
+ # @return [String] The enum value
35
+ def build_from_hash(value)
36
+ return value if WebhookSubscriptionTypeEnum.all_vars.include?(value)
37
+ raise "Invalid ENUM value #{value} for class #WebhookSubscriptionTypeEnum"
38
+ end
39
+ end
40
+ end