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