bandwidth-sdk 14.0.0 → 14.1.1

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +10 -10
  3. data/README.md +42 -10
  4. data/bandwidth.yml +1113 -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/InitiateCallback.md +3 -1
  15. data/docs/LinksObject.md +24 -0
  16. data/docs/OptInWorkflow.md +20 -0
  17. data/docs/TelephoneNumber.md +18 -0
  18. data/docs/TfvBasicAuthentication.md +20 -0
  19. data/docs/{PublishPermissionsEnum.md → TfvCallbackStatusEnum.md} +2 -2
  20. data/docs/TfvError.md +22 -0
  21. data/docs/TfvStatus.md +32 -0
  22. data/docs/{DeviceApiVersionEnum.md → TfvStatusEnum.md} +2 -2
  23. data/docs/TfvSubmissionInfo.md +34 -0
  24. data/docs/TfvSubmissionWrapper.md +18 -0
  25. data/docs/TollFreeVerificationApi.md +585 -0
  26. data/docs/VerificationDenialWebhook.md +32 -0
  27. data/docs/VerificationRequest.md +36 -0
  28. data/docs/VerificationUpdateRequest.md +34 -0
  29. data/docs/VerificationWebhook.md +24 -0
  30. data/docs/WebhookSubscription.md +30 -0
  31. data/docs/WebhookSubscriptionBasicAuthentication.md +20 -0
  32. data/docs/WebhookSubscriptionRequestSchema.md +22 -0
  33. data/docs/WebhookSubscriptionTypeEnum.md +15 -0
  34. data/docs/WebhookSubscriptionsListBody.md +22 -0
  35. data/lib/bandwidth-sdk/api/toll_free_verification_api.rb +614 -0
  36. data/lib/bandwidth-sdk/configuration.rb +48 -0
  37. data/lib/bandwidth-sdk/models/additional_denial_reason.rb +254 -0
  38. data/lib/bandwidth-sdk/models/address.rb +501 -0
  39. data/lib/bandwidth-sdk/models/contact.rb +393 -0
  40. data/lib/bandwidth-sdk/models/error.rb +232 -0
  41. data/lib/bandwidth-sdk/models/failure_webhook.rb +304 -0
  42. data/lib/bandwidth-sdk/models/initiate_callback.rb +33 -4
  43. data/lib/bandwidth-sdk/models/links_object.rb +243 -0
  44. data/lib/bandwidth-sdk/models/opt_in_workflow.rb +265 -0
  45. data/lib/bandwidth-sdk/models/telephone_number.rb +213 -0
  46. data/lib/bandwidth-sdk/models/tfv_basic_authentication.rb +273 -0
  47. data/lib/bandwidth-sdk/models/tfv_callback_status_enum.rb +40 -0
  48. data/lib/bandwidth-sdk/models/tfv_error.rb +232 -0
  49. data/lib/bandwidth-sdk/models/tfv_status.rb +342 -0
  50. data/lib/bandwidth-sdk/models/tfv_status_enum.rb +43 -0
  51. data/lib/bandwidth-sdk/models/tfv_submission_info.rb +452 -0
  52. data/lib/bandwidth-sdk/models/tfv_submission_wrapper.rb +212 -0
  53. data/lib/bandwidth-sdk/models/verification_denial_webhook.rb +325 -0
  54. data/lib/bandwidth-sdk/models/verification_request.rb +547 -0
  55. data/lib/bandwidth-sdk/models/verification_update_request.rb +501 -0
  56. data/lib/bandwidth-sdk/models/verification_webhook.rb +303 -0
  57. data/lib/bandwidth-sdk/models/webhook_subscription.rb +328 -0
  58. data/lib/bandwidth-sdk/models/webhook_subscription_basic_authentication.rb +274 -0
  59. data/lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb +306 -0
  60. data/lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb +40 -0
  61. data/lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb +242 -0
  62. data/lib/bandwidth-sdk/version.rb +1 -1
  63. data/lib/bandwidth-sdk.rb +25 -0
  64. data/openapi-config.yml +1 -1
  65. data/spec/call_utils.rb +2 -2
  66. data/spec/smoke/toll_free_verification_api_spec.rb +69 -0
  67. data/spec/spec_helper.rb +1 -1
  68. data/spec/unit/api/mfa_api_spec.rb +1 -1
  69. data/spec/unit/api/toll_free_verification_api_spec.rb +278 -0
  70. data/spec/unit/client/api_client_spec.rb +1 -1
  71. metadata +91 -61
  72. data/docs/CreateParticipantRequest.md +0 -24
  73. data/docs/CreateParticipantResponse.md +0 -20
  74. data/docs/DisconenctCallback.md +0 -50
  75. data/docs/ForbiddenRequest.md +0 -18
  76. data/docs/InboundMessageCallback.md +0 -26
  77. data/docs/InboundMessageCallbackMessage.md +0 -40
  78. data/docs/MessageDeliveredCallback.md +0 -26
  79. data/docs/MessageDeliveredCallbackMessage.md +0 -40
  80. data/docs/MessageFailedCallback.md +0 -28
  81. data/docs/MessageFailedCallbackMessage.md +0 -40
  82. data/docs/MessageSendingCallback.md +0 -26
  83. data/docs/MessageSendingCallbackMessage.md +0 -40
  84. data/docs/Participant.md +0 -30
  85. data/docs/ParticipantSubscription.md +0 -20
  86. data/docs/ParticipantsApi.md +0 -227
  87. data/docs/RequestError.md +0 -20
  88. data/docs/Session.md +0 -20
  89. data/docs/SessionsApi.md +0 -605
  90. data/docs/Subscriptions.md +0 -20
  91. data/docs/TranscriptionList.md +0 -18
  92. data/docs/TranscriptionMetadata.md +0 -24
  93. data/docs/UnauthorizedRequest.md +0 -18
@@ -0,0 +1,304 @@
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 FailureWebhook
18
+ # User's account ID.
19
+ attr_accessor :account_id
20
+
21
+ # Toll-free telephone number in E.164 format.
22
+ attr_accessor :phone_number
23
+
24
+ # An error code indicating what error was encountered. This code can be interpreted as an HTTP status code in regards to the error that was encountered.
25
+ attr_accessor :error_code
26
+
27
+ # A description of the error that was encountered.
28
+ attr_accessor :error_description
29
+
30
+ # Details of the errors that were encountered when processing the request.
31
+ attr_accessor :errors
32
+
33
+ # Unique identifier (UUID) generated by Bandwidth to assist in tracking the verification status of a toll-free number.
34
+ attr_accessor :internal_ticket_number
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'account_id' => :'accountId',
40
+ :'phone_number' => :'phoneNumber',
41
+ :'error_code' => :'errorCode',
42
+ :'error_description' => :'errorDescription',
43
+ :'errors' => :'errors',
44
+ :'internal_ticket_number' => :'internalTicketNumber'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'account_id' => :'String',
57
+ :'phone_number' => :'String',
58
+ :'error_code' => :'String',
59
+ :'error_description' => :'String',
60
+ :'errors' => :'Array<String>',
61
+ :'internal_ticket_number' => :'String'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::FailureWebhook` initialize method'
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::FailureWebhook`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'account_id')
87
+ self.account_id = attributes[:'account_id']
88
+ end
89
+
90
+ if attributes.key?(:'phone_number')
91
+ self.phone_number = attributes[:'phone_number']
92
+ end
93
+
94
+ if attributes.key?(:'error_code')
95
+ self.error_code = attributes[:'error_code']
96
+ end
97
+
98
+ if attributes.key?(:'error_description')
99
+ self.error_description = attributes[:'error_description']
100
+ end
101
+
102
+ if attributes.key?(:'errors')
103
+ if (value = attributes[:'errors']).is_a?(Array)
104
+ self.errors = value
105
+ end
106
+ end
107
+
108
+ if attributes.key?(:'internal_ticket_number')
109
+ self.internal_ticket_number = attributes[:'internal_ticket_number']
110
+ end
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properties with the reasons
115
+ def list_invalid_properties
116
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
117
+ invalid_properties = Array.new
118
+ if !@phone_number.nil? && @phone_number.to_s.length > 12
119
+ invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 12.')
120
+ end
121
+
122
+ if !@phone_number.nil? && @phone_number.to_s.length < 12
123
+ invalid_properties.push('invalid value for "phone_number", the character length must be great than or equal to 12.')
124
+ end
125
+
126
+ pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
127
+ if !@phone_number.nil? && @phone_number !~ pattern
128
+ invalid_properties.push("invalid value for \"phone_number\", must conform to the pattern #{pattern}.")
129
+ end
130
+
131
+ invalid_properties
132
+ end
133
+
134
+ # Check to see if the all the properties in the model are valid
135
+ # @return true if the model is valid
136
+ def valid?
137
+ warn '[DEPRECATED] the `valid?` method is obsolete'
138
+ return false if !@phone_number.nil? && @phone_number.to_s.length > 12
139
+ return false if !@phone_number.nil? && @phone_number.to_s.length < 12
140
+ return false if !@phone_number.nil? && @phone_number !~ Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
141
+ true
142
+ end
143
+
144
+ # Custom attribute writer method with validation
145
+ # @param [Object] phone_number Value to be assigned
146
+ def phone_number=(phone_number)
147
+ if phone_number.nil?
148
+ fail ArgumentError, 'phone_number cannot be nil'
149
+ end
150
+
151
+ if phone_number.to_s.length > 12
152
+ fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.'
153
+ end
154
+
155
+ if phone_number.to_s.length < 12
156
+ fail ArgumentError, 'invalid value for "phone_number", the character length must be great than or equal to 12.'
157
+ end
158
+
159
+ pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
160
+ if phone_number !~ pattern
161
+ fail ArgumentError, "invalid value for \"phone_number\", must conform to the pattern #{pattern}."
162
+ end
163
+
164
+ @phone_number = phone_number
165
+ end
166
+
167
+ # Checks equality by comparing each attribute.
168
+ # @param [Object] Object to be compared
169
+ def ==(o)
170
+ return true if self.equal?(o)
171
+ self.class == o.class &&
172
+ account_id == o.account_id &&
173
+ phone_number == o.phone_number &&
174
+ error_code == o.error_code &&
175
+ error_description == o.error_description &&
176
+ errors == o.errors &&
177
+ internal_ticket_number == o.internal_ticket_number
178
+ end
179
+
180
+ # @see the `==` method
181
+ # @param [Object] Object to be compared
182
+ def eql?(o)
183
+ self == o
184
+ end
185
+
186
+ # Calculates hash code according to all attributes.
187
+ # @return [Integer] Hash code
188
+ def hash
189
+ [account_id, phone_number, error_code, error_description, errors, internal_ticket_number].hash
190
+ end
191
+
192
+ # Builds the object from hash
193
+ # @param [Hash] attributes Model attributes in the form of hash
194
+ # @return [Object] Returns the model itself
195
+ def self.build_from_hash(attributes)
196
+ return nil unless attributes.is_a?(Hash)
197
+ attributes = attributes.transform_keys(&:to_sym)
198
+ transformed_hash = {}
199
+ openapi_types.each_pair do |key, type|
200
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
201
+ transformed_hash["#{key}"] = nil
202
+ elsif type =~ /\AArray<(.*)>/i
203
+ # check to ensure the input is an array given that the attribute
204
+ # is documented as an array but the input is not
205
+ if attributes[attribute_map[key]].is_a?(Array)
206
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
207
+ end
208
+ elsif !attributes[attribute_map[key]].nil?
209
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
210
+ end
211
+ end
212
+ new(transformed_hash)
213
+ end
214
+
215
+ # Deserializes the data based on type
216
+ # @param string type Data type
217
+ # @param string value Value to be deserialized
218
+ # @return [Object] Deserialized data
219
+ def self._deserialize(type, value)
220
+ case type.to_sym
221
+ when :Time
222
+ Time.parse(value)
223
+ when :Date
224
+ Date.parse(value)
225
+ when :String
226
+ value.to_s
227
+ when :Integer
228
+ value.to_i
229
+ when :Float
230
+ value.to_f
231
+ when :Boolean
232
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
233
+ true
234
+ else
235
+ false
236
+ end
237
+ when :Object
238
+ # generic object (usually a Hash), return directly
239
+ value
240
+ when /\AArray<(?<inner_type>.+)>\z/
241
+ inner_type = Regexp.last_match[:inner_type]
242
+ value.map { |v| _deserialize(inner_type, v) }
243
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
244
+ k_type = Regexp.last_match[:k_type]
245
+ v_type = Regexp.last_match[:v_type]
246
+ {}.tap do |hash|
247
+ value.each do |k, v|
248
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
249
+ end
250
+ end
251
+ else # model
252
+ # models (e.g. Pet) or oneOf
253
+ klass = Bandwidth.const_get(type)
254
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
255
+ end
256
+ end
257
+
258
+ # Returns the string representation of the object
259
+ # @return [String] String presentation of the object
260
+ def to_s
261
+ to_hash.to_s
262
+ end
263
+
264
+ # to_body is an alias to to_hash (backward compatibility)
265
+ # @return [Hash] Returns the object in the form of hash
266
+ def to_body
267
+ to_hash
268
+ end
269
+
270
+ # Returns the object in the form of hash
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_hash
273
+ hash = {}
274
+ self.class.attribute_map.each_pair do |attr, param|
275
+ value = self.send(attr)
276
+ if value.nil?
277
+ is_nullable = self.class.openapi_nullable.include?(attr)
278
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
279
+ end
280
+
281
+ hash[param] = _to_hash(value)
282
+ end
283
+ hash
284
+ end
285
+
286
+ # Outputs non-array value in the form of hash
287
+ # For object, use to_hash. Otherwise, just return the value
288
+ # @param [Object] value Any valid value
289
+ # @return [Hash] Returns the value in the form of hash
290
+ def _to_hash(value)
291
+ if value.is_a?(Array)
292
+ value.compact.map { |v| _to_hash(v) }
293
+ elsif value.is_a?(Hash)
294
+ {}.tap do |hash|
295
+ value.each { |k, v| hash[k] = _to_hash(v) }
296
+ end
297
+ elsif value.respond_to? :to_hash
298
+ value.to_hash
299
+ else
300
+ value
301
+ end
302
+ end
303
+ end
304
+ end
@@ -49,6 +49,9 @@ module Bandwidth
49
49
 
50
50
  attr_accessor :stir_shaken
51
51
 
52
+ # The value of the `User-To-User` header to send within the initial `INVITE`. Must include the encoding parameter as specified in RFC 7433. Only `base64`, `jwt` and `hex` encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters.
53
+ attr_accessor :uui
54
+
52
55
  class EnumAttributeValidator
53
56
  attr_reader :datatype
54
57
  attr_reader :allowable_values
@@ -85,7 +88,8 @@ module Bandwidth
85
88
  :'call_url' => :'callUrl',
86
89
  :'start_time' => :'startTime',
87
90
  :'diversion' => :'diversion',
88
- :'stir_shaken' => :'stirShaken'
91
+ :'stir_shaken' => :'stirShaken',
92
+ :'uui' => :'uui'
89
93
  }
90
94
  end
91
95
 
@@ -108,7 +112,8 @@ module Bandwidth
108
112
  :'call_url' => :'String',
109
113
  :'start_time' => :'Time',
110
114
  :'diversion' => :'Diversion',
111
- :'stir_shaken' => :'StirShaken'
115
+ :'stir_shaken' => :'StirShaken',
116
+ :'uui' => :'String'
112
117
  }
113
118
  end
114
119
 
@@ -180,6 +185,10 @@ module Bandwidth
180
185
  if attributes.key?(:'stir_shaken')
181
186
  self.stir_shaken = attributes[:'stir_shaken']
182
187
  end
188
+
189
+ if attributes.key?(:'uui')
190
+ self.uui = attributes[:'uui']
191
+ end
183
192
  end
184
193
 
185
194
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -187,6 +196,10 @@ module Bandwidth
187
196
  def list_invalid_properties
188
197
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
189
198
  invalid_properties = Array.new
199
+ if !@uui.nil? && @uui.to_s.length > 256
200
+ invalid_properties.push('invalid value for "uui", the character length must be smaller than or equal to 256.')
201
+ end
202
+
190
203
  invalid_properties
191
204
  end
192
205
 
@@ -194,9 +207,24 @@ module Bandwidth
194
207
  # @return true if the model is valid
195
208
  def valid?
196
209
  warn '[DEPRECATED] the `valid?` method is obsolete'
210
+ return false if !@uui.nil? && @uui.to_s.length > 256
197
211
  true
198
212
  end
199
213
 
214
+ # Custom attribute writer method with validation
215
+ # @param [Object] uui Value to be assigned
216
+ def uui=(uui)
217
+ if uui.nil?
218
+ fail ArgumentError, 'uui cannot be nil'
219
+ end
220
+
221
+ if uui.to_s.length > 256
222
+ fail ArgumentError, 'invalid value for "uui", the character length must be smaller than or equal to 256.'
223
+ end
224
+
225
+ @uui = uui
226
+ end
227
+
200
228
  # Checks equality by comparing each attribute.
201
229
  # @param [Object] Object to be compared
202
230
  def ==(o)
@@ -213,7 +241,8 @@ module Bandwidth
213
241
  call_url == o.call_url &&
214
242
  start_time == o.start_time &&
215
243
  diversion == o.diversion &&
216
- stir_shaken == o.stir_shaken
244
+ stir_shaken == o.stir_shaken &&
245
+ uui == o.uui
217
246
  end
218
247
 
219
248
  # @see the `==` method
@@ -225,7 +254,7 @@ module Bandwidth
225
254
  # Calculates hash code according to all attributes.
226
255
  # @return [Integer] Hash code
227
256
  def hash
228
- [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, start_time, diversion, stir_shaken].hash
257
+ [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, start_time, diversion, stir_shaken, uui].hash
229
258
  end
230
259
 
231
260
  # Builds the object from hash
@@ -0,0 +1,243 @@
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 LinksObject
18
+ # The first (or only) page of results matching the query.
19
+ attr_accessor :first
20
+
21
+ # If more results exist than specified by 'size', this link returns the next page of 'size' results.
22
+ attr_accessor :_next
23
+
24
+ # If the results are more than one page, this link returns the previous page of 'size' results.
25
+ attr_accessor :previous
26
+
27
+ # If more results exist than specified by 'size', this link return the last page of result.
28
+ attr_accessor :last
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'first' => :'first',
34
+ :'_next' => :'next',
35
+ :'previous' => :'previous',
36
+ :'last' => :'last'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'first' => :'String',
49
+ :'_next' => :'String',
50
+ :'previous' => :'String',
51
+ :'last' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LinksObject` initialize method'
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LinksObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'first')
77
+ self.first = attributes[:'first']
78
+ end
79
+
80
+ if attributes.key?(:'_next')
81
+ self._next = attributes[:'_next']
82
+ end
83
+
84
+ if attributes.key?(:'previous')
85
+ self.previous = attributes[:'previous']
86
+ end
87
+
88
+ if attributes.key?(:'last')
89
+ self.last = attributes[:'last']
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
97
+ invalid_properties = Array.new
98
+ invalid_properties
99
+ end
100
+
101
+ # Check to see if the all the properties in the model are valid
102
+ # @return true if the model is valid
103
+ def valid?
104
+ warn '[DEPRECATED] the `valid?` method is obsolete'
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ first == o.first &&
114
+ _next == o._next &&
115
+ previous == o.previous &&
116
+ last == o.last
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(o)
122
+ self == o
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Integer] Hash code
127
+ def hash
128
+ [first, _next, previous, last].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def self.build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ attributes = attributes.transform_keys(&:to_sym)
137
+ transformed_hash = {}
138
+ openapi_types.each_pair do |key, type|
139
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = nil
141
+ elsif type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[attribute_map[key]].is_a?(Array)
145
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
146
+ end
147
+ elsif !attributes[attribute_map[key]].nil?
148
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
149
+ end
150
+ end
151
+ new(transformed_hash)
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def self._deserialize(type, value)
159
+ case type.to_sym
160
+ when :Time
161
+ Time.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ # models (e.g. Pet) or oneOf
192
+ klass = Bandwidth.const_get(type)
193
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ if value.nil?
216
+ is_nullable = self.class.openapi_nullable.include?(attr)
217
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
218
+ end
219
+
220
+ hash[param] = _to_hash(value)
221
+ end
222
+ hash
223
+ end
224
+
225
+ # Outputs non-array value in the form of hash
226
+ # For object, use to_hash. Otherwise, just return the value
227
+ # @param [Object] value Any valid value
228
+ # @return [Hash] Returns the value in the form of hash
229
+ def _to_hash(value)
230
+ if value.is_a?(Array)
231
+ value.compact.map { |v| _to_hash(v) }
232
+ elsif value.is_a?(Hash)
233
+ {}.tap do |hash|
234
+ value.each { |k, v| hash[k] = _to_hash(v) }
235
+ end
236
+ elsif value.respond_to? :to_hash
237
+ value.to_hash
238
+ else
239
+ value
240
+ end
241
+ end
242
+ end
243
+ end