bandwidth-sdk 14.1.2 → 15.0.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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +18 -16
  3. data/README.md +34 -1
  4. data/bandwidth.yml +675 -101
  5. data/coverage/.last_run.json +1 -1
  6. data/coverage/.resultset.json +210 -6
  7. data/coverage/index.html +14901 -12699
  8. data/docs/Address.md +1 -1
  9. data/docs/CallsApi.md +1 -1
  10. data/docs/CardWidthEnum.md +15 -0
  11. data/docs/ConferencesApi.md +1 -1
  12. data/docs/CreateMultiChannelMessageResponse.md +22 -0
  13. data/docs/ErrorObject.md +20 -0
  14. data/docs/Link.md +20 -0
  15. data/docs/Message.md +1 -1
  16. data/docs/MessageCallback.md +3 -1
  17. data/docs/MessageRequest.md +1 -1
  18. data/docs/MmsMessageContent.md +20 -0
  19. data/docs/MultiChannelAction.md +89 -0
  20. data/docs/MultiChannelActionCalendarEvent.md +30 -0
  21. data/docs/MultiChannelApi.md +80 -0
  22. data/docs/MultiChannelCallbackData.md +26 -0
  23. data/docs/MultiChannelChannelListObject.md +24 -0
  24. data/docs/MultiChannelChannelListObjectContent.md +55 -0
  25. data/docs/MultiChannelMessageCallbackData.md +32 -0
  26. data/docs/MultiChannelMessageChannelEnum.md +15 -0
  27. data/docs/MultiChannelMessageData.md +34 -0
  28. data/docs/MultiChannelMessageDirectionEnum.md +15 -0
  29. data/docs/MultiChannelMessageRequest.md +26 -0
  30. data/docs/MultiChannelStatusEnum.md +15 -0
  31. data/docs/RbmActionBase.md +22 -0
  32. data/docs/RbmActionDial.md +24 -0
  33. data/docs/RbmActionOpenUrl.md +24 -0
  34. data/docs/RbmActionTypeEnum.md +15 -0
  35. data/docs/RbmActionViewLocation.md +28 -0
  36. data/docs/RbmCardContent.md +24 -0
  37. data/docs/RbmCardContentMedia.md +22 -0
  38. data/docs/RbmMediaHeightEnum.md +15 -0
  39. data/docs/RbmMessageCarouselCard.md +22 -0
  40. data/docs/RbmMessageContentFile.md +20 -0
  41. data/docs/RbmMessageContentRichCard.md +49 -0
  42. data/docs/RbmMessageContentText.md +20 -0
  43. data/docs/RbmMessageMedia.md +20 -0
  44. data/docs/RbmStandaloneCard.md +24 -0
  45. data/docs/SmsMessageContent.md +18 -0
  46. data/docs/StandaloneCardOrientationEnum.md +15 -0
  47. data/docs/TfvBasicAuthentication.md +2 -2
  48. data/docs/TfvStatus.md +5 -1
  49. data/docs/TfvSubmissionInfo.md +7 -1
  50. data/docs/ThumbnailAlignmentEnum.md +15 -0
  51. data/docs/TollFreeVerificationApi.md +1 -1
  52. data/docs/VerificationDenialWebhook.md +5 -1
  53. data/docs/VerificationRequest.md +10 -4
  54. data/docs/VerificationUpdateRequest.md +10 -4
  55. data/lib/bandwidth-sdk/api/multi_channel_api.rb +96 -0
  56. data/lib/bandwidth-sdk/configuration.rb +6 -0
  57. data/lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb +1 -0
  58. data/lib/bandwidth-sdk/models/card_width_enum.rb +40 -0
  59. data/lib/bandwidth-sdk/models/create_multi_channel_message_response.rb +234 -0
  60. data/lib/bandwidth-sdk/models/error_object.rb +221 -0
  61. data/lib/bandwidth-sdk/models/link.rb +221 -0
  62. data/lib/bandwidth-sdk/models/message.rb +1 -1
  63. data/lib/bandwidth-sdk/models/message_callback.rb +16 -5
  64. data/lib/bandwidth-sdk/models/message_request.rb +1 -1
  65. data/lib/bandwidth-sdk/models/mms_message_content.rb +244 -0
  66. data/lib/bandwidth-sdk/models/multi_channel_action.rb +61 -0
  67. data/lib/bandwidth-sdk/models/multi_channel_action_calendar_event.rb +419 -0
  68. data/lib/bandwidth-sdk/models/multi_channel_callback_data.rb +272 -0
  69. data/lib/bandwidth-sdk/models/multi_channel_channel_list_object.rb +291 -0
  70. data/lib/bandwidth-sdk/models/multi_channel_channel_list_object_content.rb +108 -0
  71. data/lib/bandwidth-sdk/models/multi_channel_message_callback_data.rb +302 -0
  72. data/lib/bandwidth-sdk/models/multi_channel_message_channel_enum.rb +41 -0
  73. data/lib/bandwidth-sdk/models/multi_channel_message_data.rb +312 -0
  74. data/lib/bandwidth-sdk/models/multi_channel_message_direction_enum.rb +40 -0
  75. data/lib/bandwidth-sdk/models/multi_channel_message_request.rb +310 -0
  76. data/lib/bandwidth-sdk/models/multi_channel_status_enum.rb +42 -0
  77. data/lib/bandwidth-sdk/models/rbm_action_base.rb +313 -0
  78. data/lib/bandwidth-sdk/models/rbm_action_dial.rb +337 -0
  79. data/lib/bandwidth-sdk/models/rbm_action_open_url.rb +356 -0
  80. data/lib/bandwidth-sdk/models/rbm_action_type_enum.rb +44 -0
  81. data/lib/bandwidth-sdk/models/rbm_action_view_location.rb +383 -0
  82. data/lib/bandwidth-sdk/models/rbm_card_content.rb +301 -0
  83. data/lib/bandwidth-sdk/models/rbm_card_content_media.rb +313 -0
  84. data/lib/bandwidth-sdk/models/rbm_media_height_enum.rb +41 -0
  85. data/lib/bandwidth-sdk/models/rbm_message_carousel_card.rb +309 -0
  86. data/lib/bandwidth-sdk/models/rbm_message_content_file.rb +268 -0
  87. data/lib/bandwidth-sdk/models/rbm_message_content_rich_card.rb +104 -0
  88. data/lib/bandwidth-sdk/models/rbm_message_content_text.rb +270 -0
  89. data/lib/bandwidth-sdk/models/rbm_message_media.rb +250 -0
  90. data/lib/bandwidth-sdk/models/rbm_standalone_card.rb +304 -0
  91. data/lib/bandwidth-sdk/models/sms_message_content.rb +239 -0
  92. data/lib/bandwidth-sdk/models/standalone_card_orientation_enum.rb +40 -0
  93. data/lib/bandwidth-sdk/models/tfv_status.rb +24 -4
  94. data/lib/bandwidth-sdk/models/tfv_status_enum.rb +1 -3
  95. data/lib/bandwidth-sdk/models/tfv_submission_info.rb +35 -5
  96. data/lib/bandwidth-sdk/models/thumbnail_alignment_enum.rb +40 -0
  97. data/lib/bandwidth-sdk/models/verification_denial_webhook.rb +24 -4
  98. data/lib/bandwidth-sdk/models/verification_request.rb +45 -15
  99. data/lib/bandwidth-sdk/models/verification_update_request.rb +35 -5
  100. data/lib/bandwidth-sdk/version.rb +1 -1
  101. data/lib/bandwidth-sdk.rb +34 -1
  102. data/spec/smoke/conferences_api_spec.rb +4 -4
  103. data/spec/smoke/multi_channel_api_spec.rb +40 -0
  104. data/spec/smoke/transcriptions_api_spec.rb +1 -1
  105. data/spec/unit/api/multi_channel_api_spec.rb +59 -0
  106. data/spec/unit/models/bxml/verbs/phone_number_spec.rb +6 -4
  107. metadata +117 -45
@@ -0,0 +1,268 @@
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 RbmMessageContentFile
18
+ # The URL of the media file. 100MB is the maximum file size.
19
+ attr_accessor :file_url
20
+
21
+ # The URL of the thumbnail image. Applies only to video file media.
22
+ attr_accessor :thumbnail_url
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'file_url' => :'fileUrl',
28
+ :'thumbnail_url' => :'thumbnailUrl'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'file_url' => :'String',
41
+ :'thumbnail_url' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmMessageContentFile` initialize method'
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmMessageContentFile`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'file_url')
67
+ self.file_url = attributes[:'file_url']
68
+ else
69
+ self.file_url = nil
70
+ end
71
+
72
+ if attributes.key?(:'thumbnail_url')
73
+ self.thumbnail_url = attributes[:'thumbnail_url']
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
81
+ invalid_properties = Array.new
82
+ if @file_url.nil?
83
+ invalid_properties.push('invalid value for "file_url", file_url cannot be nil.')
84
+ end
85
+
86
+ if @file_url.to_s.length > 1000
87
+ invalid_properties.push('invalid value for "file_url", the character length must be smaller than or equal to 1000.')
88
+ end
89
+
90
+ if !@thumbnail_url.nil? && @thumbnail_url.to_s.length > 1000
91
+ invalid_properties.push('invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.')
92
+ end
93
+
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ warn '[DEPRECATED] the `valid?` method is obsolete'
101
+ return false if @file_url.nil?
102
+ return false if @file_url.to_s.length > 1000
103
+ return false if !@thumbnail_url.nil? && @thumbnail_url.to_s.length > 1000
104
+ true
105
+ end
106
+
107
+ # Custom attribute writer method with validation
108
+ # @param [Object] file_url Value to be assigned
109
+ def file_url=(file_url)
110
+ if file_url.nil?
111
+ fail ArgumentError, 'file_url cannot be nil'
112
+ end
113
+
114
+ if file_url.to_s.length > 1000
115
+ fail ArgumentError, 'invalid value for "file_url", the character length must be smaller than or equal to 1000.'
116
+ end
117
+
118
+ @file_url = file_url
119
+ end
120
+
121
+ # Custom attribute writer method with validation
122
+ # @param [Object] thumbnail_url Value to be assigned
123
+ def thumbnail_url=(thumbnail_url)
124
+ if thumbnail_url.nil?
125
+ fail ArgumentError, 'thumbnail_url cannot be nil'
126
+ end
127
+
128
+ if thumbnail_url.to_s.length > 1000
129
+ fail ArgumentError, 'invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.'
130
+ end
131
+
132
+ @thumbnail_url = thumbnail_url
133
+ end
134
+
135
+ # Checks equality by comparing each attribute.
136
+ # @param [Object] Object to be compared
137
+ def ==(o)
138
+ return true if self.equal?(o)
139
+ self.class == o.class &&
140
+ file_url == o.file_url &&
141
+ thumbnail_url == o.thumbnail_url
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [file_url, thumbnail_url].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ attributes = attributes.transform_keys(&:to_sym)
162
+ transformed_hash = {}
163
+ openapi_types.each_pair do |key, type|
164
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
165
+ transformed_hash["#{key}"] = nil
166
+ elsif type =~ /\AArray<(.*)>/i
167
+ # check to ensure the input is an array given that the attribute
168
+ # is documented as an array but the input is not
169
+ if attributes[attribute_map[key]].is_a?(Array)
170
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
171
+ end
172
+ elsif !attributes[attribute_map[key]].nil?
173
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
174
+ end
175
+ end
176
+ new(transformed_hash)
177
+ end
178
+
179
+ # Deserializes the data based on type
180
+ # @param string type Data type
181
+ # @param string value Value to be deserialized
182
+ # @return [Object] Deserialized data
183
+ def self._deserialize(type, value)
184
+ case type.to_sym
185
+ when :Time
186
+ Time.parse(value)
187
+ when :Date
188
+ Date.parse(value)
189
+ when :String
190
+ value.to_s
191
+ when :Integer
192
+ value.to_i
193
+ when :Float
194
+ value.to_f
195
+ when :Boolean
196
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
+ true
198
+ else
199
+ false
200
+ end
201
+ when :Object
202
+ # generic object (usually a Hash), return directly
203
+ value
204
+ when /\AArray<(?<inner_type>.+)>\z/
205
+ inner_type = Regexp.last_match[:inner_type]
206
+ value.map { |v| _deserialize(inner_type, v) }
207
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
+ k_type = Regexp.last_match[:k_type]
209
+ v_type = Regexp.last_match[:v_type]
210
+ {}.tap do |hash|
211
+ value.each do |k, v|
212
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
+ end
214
+ end
215
+ else # model
216
+ # models (e.g. Pet) or oneOf
217
+ klass = Bandwidth.const_get(type)
218
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
219
+ end
220
+ end
221
+
222
+ # Returns the string representation of the object
223
+ # @return [String] String presentation of the object
224
+ def to_s
225
+ to_hash.to_s
226
+ end
227
+
228
+ # to_body is an alias to to_hash (backward compatibility)
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_body
231
+ to_hash
232
+ end
233
+
234
+ # Returns the object in the form of hash
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_hash
237
+ hash = {}
238
+ self.class.attribute_map.each_pair do |attr, param|
239
+ value = self.send(attr)
240
+ if value.nil?
241
+ is_nullable = self.class.openapi_nullable.include?(attr)
242
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
+ end
244
+
245
+ hash[param] = _to_hash(value)
246
+ end
247
+ hash
248
+ end
249
+
250
+ # Outputs non-array value in the form of hash
251
+ # For object, use to_hash. Otherwise, just return the value
252
+ # @param [Object] value Any valid value
253
+ # @return [Hash] Returns the value in the form of hash
254
+ def _to_hash(value)
255
+ if value.is_a?(Array)
256
+ value.compact.map { |v| _to_hash(v) }
257
+ elsif value.is_a?(Hash)
258
+ {}.tap do |hash|
259
+ value.each { |k, v| hash[k] = _to_hash(v) }
260
+ end
261
+ elsif value.respond_to? :to_hash
262
+ value.to_hash
263
+ else
264
+ value
265
+ end
266
+ end
267
+ end
268
+ end
@@ -0,0 +1,104 @@
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
+ module RbmMessageContentRichCard
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'RbmMessageCarouselCard',
23
+ :'RbmStandaloneCard'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.parse(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = Bandwidth.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,270 @@
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 RbmMessageContentText
18
+ # The text associated with the message. Must be 3270 characters or less
19
+ attr_accessor :text
20
+
21
+ # An array of suggested actions for the recipient.
22
+ attr_accessor :suggestions
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'text' => :'text',
28
+ :'suggestions' => :'suggestions'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'text' => :'String',
41
+ :'suggestions' => :'Array<MultiChannelAction>'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmMessageContentText` initialize method'
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmMessageContentText`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'text')
67
+ self.text = attributes[:'text']
68
+ else
69
+ self.text = nil
70
+ end
71
+
72
+ if attributes.key?(:'suggestions')
73
+ if (value = attributes[:'suggestions']).is_a?(Array)
74
+ self.suggestions = value
75
+ end
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ if @text.nil?
85
+ invalid_properties.push('invalid value for "text", text cannot be nil.')
86
+ end
87
+
88
+ if @text.to_s.length > 3270
89
+ invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 3270.')
90
+ end
91
+
92
+ if !@suggestions.nil? && @suggestions.length > 11
93
+ invalid_properties.push('invalid value for "suggestions", number of items must be less than or equal to 11.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
+ return false if @text.nil?
104
+ return false if @text.to_s.length > 3270
105
+ return false if !@suggestions.nil? && @suggestions.length > 11
106
+ true
107
+ end
108
+
109
+ # Custom attribute writer method with validation
110
+ # @param [Object] text Value to be assigned
111
+ def text=(text)
112
+ if text.nil?
113
+ fail ArgumentError, 'text cannot be nil'
114
+ end
115
+
116
+ if text.to_s.length > 3270
117
+ fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 3270.'
118
+ end
119
+
120
+ @text = text
121
+ end
122
+
123
+ # Custom attribute writer method with validation
124
+ # @param [Object] suggestions Value to be assigned
125
+ def suggestions=(suggestions)
126
+ if suggestions.nil?
127
+ fail ArgumentError, 'suggestions cannot be nil'
128
+ end
129
+
130
+ if suggestions.length > 11
131
+ fail ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.'
132
+ end
133
+
134
+ @suggestions = suggestions
135
+ end
136
+
137
+ # Checks equality by comparing each attribute.
138
+ # @param [Object] Object to be compared
139
+ def ==(o)
140
+ return true if self.equal?(o)
141
+ self.class == o.class &&
142
+ text == o.text &&
143
+ suggestions == o.suggestions
144
+ end
145
+
146
+ # @see the `==` method
147
+ # @param [Object] Object to be compared
148
+ def eql?(o)
149
+ self == o
150
+ end
151
+
152
+ # Calculates hash code according to all attributes.
153
+ # @return [Integer] Hash code
154
+ def hash
155
+ [text, suggestions].hash
156
+ end
157
+
158
+ # Builds the object from hash
159
+ # @param [Hash] attributes Model attributes in the form of hash
160
+ # @return [Object] Returns the model itself
161
+ def self.build_from_hash(attributes)
162
+ return nil unless attributes.is_a?(Hash)
163
+ attributes = attributes.transform_keys(&:to_sym)
164
+ transformed_hash = {}
165
+ openapi_types.each_pair do |key, type|
166
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
167
+ transformed_hash["#{key}"] = nil
168
+ elsif type =~ /\AArray<(.*)>/i
169
+ # check to ensure the input is an array given that the attribute
170
+ # is documented as an array but the input is not
171
+ if attributes[attribute_map[key]].is_a?(Array)
172
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
173
+ end
174
+ elsif !attributes[attribute_map[key]].nil?
175
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
176
+ end
177
+ end
178
+ new(transformed_hash)
179
+ end
180
+
181
+ # Deserializes the data based on type
182
+ # @param string type Data type
183
+ # @param string value Value to be deserialized
184
+ # @return [Object] Deserialized data
185
+ def self._deserialize(type, value)
186
+ case type.to_sym
187
+ when :Time
188
+ Time.parse(value)
189
+ when :Date
190
+ Date.parse(value)
191
+ when :String
192
+ value.to_s
193
+ when :Integer
194
+ value.to_i
195
+ when :Float
196
+ value.to_f
197
+ when :Boolean
198
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
199
+ true
200
+ else
201
+ false
202
+ end
203
+ when :Object
204
+ # generic object (usually a Hash), return directly
205
+ value
206
+ when /\AArray<(?<inner_type>.+)>\z/
207
+ inner_type = Regexp.last_match[:inner_type]
208
+ value.map { |v| _deserialize(inner_type, v) }
209
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
210
+ k_type = Regexp.last_match[:k_type]
211
+ v_type = Regexp.last_match[:v_type]
212
+ {}.tap do |hash|
213
+ value.each do |k, v|
214
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
215
+ end
216
+ end
217
+ else # model
218
+ # models (e.g. Pet) or oneOf
219
+ klass = Bandwidth.const_get(type)
220
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
221
+ end
222
+ end
223
+
224
+ # Returns the string representation of the object
225
+ # @return [String] String presentation of the object
226
+ def to_s
227
+ to_hash.to_s
228
+ end
229
+
230
+ # to_body is an alias to to_hash (backward compatibility)
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_body
233
+ to_hash
234
+ end
235
+
236
+ # Returns the object in the form of hash
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_hash
239
+ hash = {}
240
+ self.class.attribute_map.each_pair do |attr, param|
241
+ value = self.send(attr)
242
+ if value.nil?
243
+ is_nullable = self.class.openapi_nullable.include?(attr)
244
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
+ end
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+ end
270
+ end