bandwidth-sdk 14.1.3 → 15.1.0

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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +14 -14
  3. data/README.md +35 -1
  4. data/bandwidth.yml +656 -58
  5. data/coverage/.last_run.json +1 -1
  6. data/coverage/.resultset.json +211 -6
  7. data/coverage/index.html +14914 -12700
  8. data/docs/BlockedWebhook.md +28 -0
  9. data/docs/CardWidthEnum.md +15 -0
  10. data/docs/CreateMultiChannelMessageResponse.md +22 -0
  11. data/docs/ErrorObject.md +20 -0
  12. data/docs/Link.md +20 -0
  13. data/docs/Message.md +1 -1
  14. data/docs/MessageCallback.md +3 -1
  15. data/docs/MessageRequest.md +1 -1
  16. data/docs/MmsMessageContent.md +20 -0
  17. data/docs/MultiChannelAction.md +89 -0
  18. data/docs/MultiChannelActionCalendarEvent.md +30 -0
  19. data/docs/MultiChannelApi.md +80 -0
  20. data/docs/MultiChannelCallbackData.md +26 -0
  21. data/docs/MultiChannelChannelListObject.md +24 -0
  22. data/docs/MultiChannelChannelListObjectContent.md +55 -0
  23. data/docs/MultiChannelMessageCallbackData.md +32 -0
  24. data/docs/MultiChannelMessageChannelEnum.md +15 -0
  25. data/docs/MultiChannelMessageData.md +34 -0
  26. data/docs/MultiChannelMessageDirectionEnum.md +15 -0
  27. data/docs/MultiChannelMessageRequest.md +26 -0
  28. data/docs/MultiChannelStatusEnum.md +15 -0
  29. data/docs/RbmActionBase.md +22 -0
  30. data/docs/RbmActionDial.md +24 -0
  31. data/docs/RbmActionOpenUrl.md +24 -0
  32. data/docs/RbmActionTypeEnum.md +15 -0
  33. data/docs/RbmActionViewLocation.md +28 -0
  34. data/docs/RbmCardContent.md +24 -0
  35. data/docs/RbmCardContentMedia.md +22 -0
  36. data/docs/RbmMediaHeightEnum.md +15 -0
  37. data/docs/RbmMessageCarouselCard.md +22 -0
  38. data/docs/RbmMessageContentFile.md +20 -0
  39. data/docs/RbmMessageContentRichCard.md +49 -0
  40. data/docs/RbmMessageContentText.md +20 -0
  41. data/docs/RbmMessageMedia.md +20 -0
  42. data/docs/RbmStandaloneCard.md +24 -0
  43. data/docs/SmsMessageContent.md +18 -0
  44. data/docs/StandaloneCardOrientationEnum.md +15 -0
  45. data/docs/TfvStatus.md +5 -1
  46. data/docs/TfvSubmissionInfo.md +8 -2
  47. data/docs/ThumbnailAlignmentEnum.md +15 -0
  48. data/docs/VerificationDenialWebhook.md +5 -1
  49. data/docs/VerificationRequest.md +7 -1
  50. data/docs/VerificationUpdateRequest.md +8 -2
  51. data/lib/bandwidth-sdk/api/multi_channel_api.rb +96 -0
  52. data/lib/bandwidth-sdk/configuration.rb +6 -0
  53. data/lib/bandwidth-sdk/models/blocked_webhook.rb +323 -0
  54. data/lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb +1 -0
  55. data/lib/bandwidth-sdk/models/card_width_enum.rb +40 -0
  56. data/lib/bandwidth-sdk/models/create_multi_channel_message_response.rb +234 -0
  57. data/lib/bandwidth-sdk/models/error_object.rb +221 -0
  58. data/lib/bandwidth-sdk/models/link.rb +221 -0
  59. data/lib/bandwidth-sdk/models/message.rb +1 -1
  60. data/lib/bandwidth-sdk/models/message_callback.rb +16 -5
  61. data/lib/bandwidth-sdk/models/message_request.rb +1 -1
  62. data/lib/bandwidth-sdk/models/mms_message_content.rb +244 -0
  63. data/lib/bandwidth-sdk/models/multi_channel_action.rb +61 -0
  64. data/lib/bandwidth-sdk/models/multi_channel_action_calendar_event.rb +419 -0
  65. data/lib/bandwidth-sdk/models/multi_channel_callback_data.rb +272 -0
  66. data/lib/bandwidth-sdk/models/multi_channel_channel_list_object.rb +291 -0
  67. data/lib/bandwidth-sdk/models/multi_channel_channel_list_object_content.rb +108 -0
  68. data/lib/bandwidth-sdk/models/multi_channel_message_callback_data.rb +302 -0
  69. data/lib/bandwidth-sdk/models/multi_channel_message_channel_enum.rb +41 -0
  70. data/lib/bandwidth-sdk/models/multi_channel_message_data.rb +312 -0
  71. data/lib/bandwidth-sdk/models/multi_channel_message_direction_enum.rb +40 -0
  72. data/lib/bandwidth-sdk/models/multi_channel_message_request.rb +310 -0
  73. data/lib/bandwidth-sdk/models/multi_channel_status_enum.rb +42 -0
  74. data/lib/bandwidth-sdk/models/rbm_action_base.rb +313 -0
  75. data/lib/bandwidth-sdk/models/rbm_action_dial.rb +337 -0
  76. data/lib/bandwidth-sdk/models/rbm_action_open_url.rb +356 -0
  77. data/lib/bandwidth-sdk/models/rbm_action_type_enum.rb +44 -0
  78. data/lib/bandwidth-sdk/models/rbm_action_view_location.rb +383 -0
  79. data/lib/bandwidth-sdk/models/rbm_card_content.rb +301 -0
  80. data/lib/bandwidth-sdk/models/rbm_card_content_media.rb +313 -0
  81. data/lib/bandwidth-sdk/models/rbm_media_height_enum.rb +41 -0
  82. data/lib/bandwidth-sdk/models/rbm_message_carousel_card.rb +309 -0
  83. data/lib/bandwidth-sdk/models/rbm_message_content_file.rb +268 -0
  84. data/lib/bandwidth-sdk/models/rbm_message_content_rich_card.rb +104 -0
  85. data/lib/bandwidth-sdk/models/rbm_message_content_text.rb +270 -0
  86. data/lib/bandwidth-sdk/models/rbm_message_media.rb +250 -0
  87. data/lib/bandwidth-sdk/models/rbm_standalone_card.rb +304 -0
  88. data/lib/bandwidth-sdk/models/sms_message_content.rb +239 -0
  89. data/lib/bandwidth-sdk/models/standalone_card_orientation_enum.rb +40 -0
  90. data/lib/bandwidth-sdk/models/tfv_status.rb +24 -4
  91. data/lib/bandwidth-sdk/models/tfv_status_enum.rb +1 -3
  92. data/lib/bandwidth-sdk/models/tfv_submission_info.rb +35 -5
  93. data/lib/bandwidth-sdk/models/thumbnail_alignment_enum.rb +40 -0
  94. data/lib/bandwidth-sdk/models/verification_denial_webhook.rb +24 -4
  95. data/lib/bandwidth-sdk/models/verification_request.rb +35 -5
  96. data/lib/bandwidth-sdk/models/verification_update_request.rb +35 -5
  97. data/lib/bandwidth-sdk/version.rb +1 -1
  98. data/lib/bandwidth-sdk.rb +35 -1
  99. data/spec/smoke/conferences_api_spec.rb +4 -4
  100. data/spec/smoke/multi_channel_api_spec.rb +40 -0
  101. data/spec/smoke/transcriptions_api_spec.rb +1 -1
  102. data/spec/unit/api/multi_channel_api_spec.rb +59 -0
  103. data/spec/unit/models/bxml/verbs/phone_number_spec.rb +6 -4
  104. metadata +119 -45
@@ -0,0 +1,323 @@
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 BlockedWebhook
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
+ attr_accessor :status
25
+
26
+ # Unique identifier (UUID) generated by Bandwidth to assist in tracking the verification status of a toll-free number.
27
+ attr_accessor :internal_ticket_number
28
+
29
+ # Whether a Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked. (Not Available Until 5/28/2025)
30
+ attr_accessor :blocked
31
+
32
+ # The reason why the Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked. (Not Available Until 5/28/2025)
33
+ attr_accessor :blocked_reason
34
+
35
+ class EnumAttributeValidator
36
+ attr_reader :datatype
37
+ attr_reader :allowable_values
38
+
39
+ def initialize(datatype, allowable_values)
40
+ @allowable_values = allowable_values.map do |value|
41
+ case datatype.to_s
42
+ when /Integer/i
43
+ value.to_i
44
+ when /Float/i
45
+ value.to_f
46
+ else
47
+ value
48
+ end
49
+ end
50
+ end
51
+
52
+ def valid?(value)
53
+ !value || allowable_values.include?(value)
54
+ end
55
+ end
56
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'account_id' => :'accountId',
61
+ :'phone_number' => :'phoneNumber',
62
+ :'status' => :'status',
63
+ :'internal_ticket_number' => :'internalTicketNumber',
64
+ :'blocked' => :'blocked',
65
+ :'blocked_reason' => :'blockedReason'
66
+ }
67
+ end
68
+
69
+ # Returns all the JSON keys this model knows about
70
+ def self.acceptable_attributes
71
+ attribute_map.values
72
+ end
73
+
74
+ # Attribute type mapping.
75
+ def self.openapi_types
76
+ {
77
+ :'account_id' => :'String',
78
+ :'phone_number' => :'String',
79
+ :'status' => :'TfvCallbackStatusEnum',
80
+ :'internal_ticket_number' => :'String',
81
+ :'blocked' => :'Boolean',
82
+ :'blocked_reason' => :'String'
83
+ }
84
+ end
85
+
86
+ # List of attributes with nullable: true
87
+ def self.openapi_nullable
88
+ Set.new([
89
+ ])
90
+ end
91
+
92
+ # Initializes the object
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ def initialize(attributes = {})
95
+ if (!attributes.is_a?(Hash))
96
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BlockedWebhook` initialize method'
97
+ end
98
+
99
+ # check to see if the attribute exists and convert string to symbol for hash key
100
+ attributes = attributes.each_with_object({}) { |(k, v), h|
101
+ if (!self.class.attribute_map.key?(k.to_sym))
102
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BlockedWebhook`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
103
+ end
104
+ h[k.to_sym] = v
105
+ }
106
+
107
+ if attributes.key?(:'account_id')
108
+ self.account_id = attributes[:'account_id']
109
+ end
110
+
111
+ if attributes.key?(:'phone_number')
112
+ self.phone_number = attributes[:'phone_number']
113
+ end
114
+
115
+ if attributes.key?(:'status')
116
+ self.status = attributes[:'status']
117
+ end
118
+
119
+ if attributes.key?(:'internal_ticket_number')
120
+ self.internal_ticket_number = attributes[:'internal_ticket_number']
121
+ end
122
+
123
+ if attributes.key?(:'blocked')
124
+ self.blocked = attributes[:'blocked']
125
+ end
126
+
127
+ if attributes.key?(:'blocked_reason')
128
+ self.blocked_reason = attributes[:'blocked_reason']
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
136
+ invalid_properties = Array.new
137
+ if !@phone_number.nil? && @phone_number.to_s.length > 12
138
+ invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 12.')
139
+ end
140
+
141
+ if !@phone_number.nil? && @phone_number.to_s.length < 12
142
+ invalid_properties.push('invalid value for "phone_number", the character length must be great than or equal to 12.')
143
+ end
144
+
145
+ pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
146
+ if !@phone_number.nil? && @phone_number !~ pattern
147
+ invalid_properties.push("invalid value for \"phone_number\", must conform to the pattern #{pattern}.")
148
+ end
149
+
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
+ warn '[DEPRECATED] the `valid?` method is obsolete'
157
+ return false if !@phone_number.nil? && @phone_number.to_s.length > 12
158
+ return false if !@phone_number.nil? && @phone_number.to_s.length < 12
159
+ return false if !@phone_number.nil? && @phone_number !~ Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
160
+ true
161
+ end
162
+
163
+ # Custom attribute writer method with validation
164
+ # @param [Object] phone_number Value to be assigned
165
+ def phone_number=(phone_number)
166
+ if phone_number.nil?
167
+ fail ArgumentError, 'phone_number cannot be nil'
168
+ end
169
+
170
+ if phone_number.to_s.length > 12
171
+ fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.'
172
+ end
173
+
174
+ if phone_number.to_s.length < 12
175
+ fail ArgumentError, 'invalid value for "phone_number", the character length must be great than or equal to 12.'
176
+ end
177
+
178
+ pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
179
+ if phone_number !~ pattern
180
+ fail ArgumentError, "invalid value for \"phone_number\", must conform to the pattern #{pattern}."
181
+ end
182
+
183
+ @phone_number = phone_number
184
+ end
185
+
186
+ # Checks equality by comparing each attribute.
187
+ # @param [Object] Object to be compared
188
+ def ==(o)
189
+ return true if self.equal?(o)
190
+ self.class == o.class &&
191
+ account_id == o.account_id &&
192
+ phone_number == o.phone_number &&
193
+ status == o.status &&
194
+ internal_ticket_number == o.internal_ticket_number &&
195
+ blocked == o.blocked &&
196
+ blocked_reason == o.blocked_reason
197
+ end
198
+
199
+ # @see the `==` method
200
+ # @param [Object] Object to be compared
201
+ def eql?(o)
202
+ self == o
203
+ end
204
+
205
+ # Calculates hash code according to all attributes.
206
+ # @return [Integer] Hash code
207
+ def hash
208
+ [account_id, phone_number, status, internal_ticket_number, blocked, blocked_reason].hash
209
+ end
210
+
211
+ # Builds the object from hash
212
+ # @param [Hash] attributes Model attributes in the form of hash
213
+ # @return [Object] Returns the model itself
214
+ def self.build_from_hash(attributes)
215
+ return nil unless attributes.is_a?(Hash)
216
+ attributes = attributes.transform_keys(&:to_sym)
217
+ transformed_hash = {}
218
+ openapi_types.each_pair do |key, type|
219
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
220
+ transformed_hash["#{key}"] = nil
221
+ elsif type =~ /\AArray<(.*)>/i
222
+ # check to ensure the input is an array given that the attribute
223
+ # is documented as an array but the input is not
224
+ if attributes[attribute_map[key]].is_a?(Array)
225
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
226
+ end
227
+ elsif !attributes[attribute_map[key]].nil?
228
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
229
+ end
230
+ end
231
+ new(transformed_hash)
232
+ end
233
+
234
+ # Deserializes the data based on type
235
+ # @param string type Data type
236
+ # @param string value Value to be deserialized
237
+ # @return [Object] Deserialized data
238
+ def self._deserialize(type, value)
239
+ case type.to_sym
240
+ when :Time
241
+ Time.parse(value)
242
+ when :Date
243
+ Date.parse(value)
244
+ when :String
245
+ value.to_s
246
+ when :Integer
247
+ value.to_i
248
+ when :Float
249
+ value.to_f
250
+ when :Boolean
251
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
252
+ true
253
+ else
254
+ false
255
+ end
256
+ when :Object
257
+ # generic object (usually a Hash), return directly
258
+ value
259
+ when /\AArray<(?<inner_type>.+)>\z/
260
+ inner_type = Regexp.last_match[:inner_type]
261
+ value.map { |v| _deserialize(inner_type, v) }
262
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
263
+ k_type = Regexp.last_match[:k_type]
264
+ v_type = Regexp.last_match[:v_type]
265
+ {}.tap do |hash|
266
+ value.each do |k, v|
267
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
268
+ end
269
+ end
270
+ else # model
271
+ # models (e.g. Pet) or oneOf
272
+ klass = Bandwidth.const_get(type)
273
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
274
+ end
275
+ end
276
+
277
+ # Returns the string representation of the object
278
+ # @return [String] String presentation of the object
279
+ def to_s
280
+ to_hash.to_s
281
+ end
282
+
283
+ # to_body is an alias to to_hash (backward compatibility)
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_body
286
+ to_hash
287
+ end
288
+
289
+ # Returns the object in the form of hash
290
+ # @return [Hash] Returns the object in the form of hash
291
+ def to_hash
292
+ hash = {}
293
+ self.class.attribute_map.each_pair do |attr, param|
294
+ value = self.send(attr)
295
+ if value.nil?
296
+ is_nullable = self.class.openapi_nullable.include?(attr)
297
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
298
+ end
299
+
300
+ hash[param] = _to_hash(value)
301
+ end
302
+ hash
303
+ end
304
+
305
+ # Outputs non-array value in the form of hash
306
+ # For object, use to_hash. Otherwise, just return the value
307
+ # @param [Object] value Any valid value
308
+ # @return [Hash] Returns the value in the form of hash
309
+ def _to_hash(value)
310
+ if value.is_a?(Array)
311
+ value.compact.map { |v| _to_hash(v) }
312
+ elsif value.is_a?(Hash)
313
+ {}.tap do |hash|
314
+ value.each { |k, v| hash[k] = _to_hash(v) }
315
+ end
316
+ elsif value.respond_to? :to_hash
317
+ value.to_hash
318
+ else
319
+ value
320
+ end
321
+ end
322
+ end
323
+ end
@@ -19,6 +19,7 @@ module Bandwidth
19
19
  fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None.
20
20
  fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None.
21
21
  tag: 'tag', # Optional [String]: A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None.
22
+ uui: 'uui', # Optional [String]: 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.
22
23
  }
23
24
  end
24
25
  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 CardWidthEnum
18
+ SMALL = 'SMALL'.freeze
19
+ MEDIUM = 'MEDIUM'.freeze
20
+
21
+ def self.all_vars
22
+ @all_vars ||= [SMALL, MEDIUM].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 CardWidthEnum.all_vars.include?(value)
37
+ raise "Invalid ENUM value #{value} for class #CardWidthEnum"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,234 @@
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 CreateMultiChannelMessageResponse
18
+ attr_accessor :links
19
+
20
+ attr_accessor :data
21
+
22
+ attr_accessor :errors
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'links' => :'links',
28
+ :'data' => :'data',
29
+ :'errors' => :'errors'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'links' => :'Array<Link>',
42
+ :'data' => :'MultiChannelMessageData',
43
+ :'errors' => :'Array<ErrorObject>'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateMultiChannelMessageResponse` initialize method'
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateMultiChannelMessageResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'links')
69
+ if (value = attributes[:'links']).is_a?(Array)
70
+ self.links = value
71
+ end
72
+ end
73
+
74
+ if attributes.key?(:'data')
75
+ self.data = attributes[:'data']
76
+ end
77
+
78
+ if attributes.key?(:'errors')
79
+ if (value = attributes[:'errors']).is_a?(Array)
80
+ self.errors = value
81
+ end
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ warn '[DEPRECATED] the `valid?` method is obsolete'
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ links == o.links &&
106
+ data == o.data &&
107
+ errors == o.errors
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Integer] Hash code
118
+ def hash
119
+ [links, data, errors].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ attributes = attributes.transform_keys(&:to_sym)
128
+ transformed_hash = {}
129
+ openapi_types.each_pair do |key, type|
130
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
131
+ transformed_hash["#{key}"] = nil
132
+ elsif type =~ /\AArray<(.*)>/i
133
+ # check to ensure the input is an array given that the attribute
134
+ # is documented as an array but the input is not
135
+ if attributes[attribute_map[key]].is_a?(Array)
136
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
137
+ end
138
+ elsif !attributes[attribute_map[key]].nil?
139
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
140
+ end
141
+ end
142
+ new(transformed_hash)
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def self._deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ # models (e.g. Pet) or oneOf
183
+ klass = Bandwidth.const_get(type)
184
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = self.send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+ end
234
+ end