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,42 @@
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 MultiChannelStatusEnum
18
+ QUEUED = 'QUEUED'.freeze
19
+ SENDING = 'SENDING'.freeze
20
+ DELIVERED = 'DELIVERED'.freeze
21
+ FAILED = 'FAILED'.freeze
22
+
23
+ def self.all_vars
24
+ @all_vars ||= [QUEUED, SENDING, DELIVERED, FAILED].freeze
25
+ end
26
+
27
+ # Builds the enum from string
28
+ # @param [String] The enum value in the form of the string
29
+ # @return [String] The enum value
30
+ def self.build_from_hash(value)
31
+ new.build_from_hash(value)
32
+ end
33
+
34
+ # Builds the enum from string
35
+ # @param [String] The enum value in the form of the string
36
+ # @return [String] The enum value
37
+ def build_from_hash(value)
38
+ return value if MultiChannelStatusEnum.all_vars.include?(value)
39
+ raise "Invalid ENUM value #{value} for class #MultiChannelStatusEnum"
40
+ end
41
+ end
42
+ end
@@ -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 RbmActionBase
18
+ attr_accessor :type
19
+
20
+ # Displayed text for user to click
21
+ attr_accessor :text
22
+
23
+ # Base64 payload the customer receives when the reply is clicked.
24
+ attr_accessor :post_back_data
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
+ :'type' => :'type',
52
+ :'text' => :'text',
53
+ :'post_back_data' => :'postBackData'
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
+ :'type' => :'RbmActionTypeEnum',
66
+ :'text' => :'String',
67
+ :'post_back_data' => :'String'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmActionBase` initialize method'
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!self.class.attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmActionBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'type')
93
+ self.type = attributes[:'type']
94
+ else
95
+ self.type = nil
96
+ end
97
+
98
+ if attributes.key?(:'text')
99
+ self.text = attributes[:'text']
100
+ else
101
+ self.text = nil
102
+ end
103
+
104
+ if attributes.key?(:'post_back_data')
105
+ self.post_back_data = attributes[:'post_back_data']
106
+ else
107
+ self.post_back_data = nil
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
115
+ invalid_properties = Array.new
116
+ if @type.nil?
117
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
118
+ end
119
+
120
+ if @text.nil?
121
+ invalid_properties.push('invalid value for "text", text cannot be nil.')
122
+ end
123
+
124
+ if @text.to_s.length > 25
125
+ invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 25.')
126
+ end
127
+
128
+ if @post_back_data.nil?
129
+ invalid_properties.push('invalid value for "post_back_data", post_back_data cannot be nil.')
130
+ end
131
+
132
+ if @post_back_data.to_s.length > 2048
133
+ invalid_properties.push('invalid value for "post_back_data", the character length must be smaller than or equal to 2048.')
134
+ end
135
+
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ warn '[DEPRECATED] the `valid?` method is obsolete'
143
+ return false if @type.nil?
144
+ return false if @text.nil?
145
+ return false if @text.to_s.length > 25
146
+ return false if @post_back_data.nil?
147
+ return false if @post_back_data.to_s.length > 2048
148
+ true
149
+ end
150
+
151
+ # Custom attribute writer method with validation
152
+ # @param [Object] text Value to be assigned
153
+ def text=(text)
154
+ if text.nil?
155
+ fail ArgumentError, 'text cannot be nil'
156
+ end
157
+
158
+ if text.to_s.length > 25
159
+ fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.'
160
+ end
161
+
162
+ @text = text
163
+ end
164
+
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] post_back_data Value to be assigned
167
+ def post_back_data=(post_back_data)
168
+ if post_back_data.nil?
169
+ fail ArgumentError, 'post_back_data cannot be nil'
170
+ end
171
+
172
+ if post_back_data.to_s.length > 2048
173
+ fail ArgumentError, 'invalid value for "post_back_data", the character length must be smaller than or equal to 2048.'
174
+ end
175
+
176
+ @post_back_data = post_back_data
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
+ type == o.type &&
185
+ text == o.text &&
186
+ post_back_data == o.post_back_data
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
+ [type, text, post_back_data].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,337 @@
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 RbmActionDial
18
+ attr_accessor :type
19
+
20
+ # Displayed text for user to click
21
+ attr_accessor :text
22
+
23
+ # Base64 payload the customer receives when the reply is clicked.
24
+ attr_accessor :post_back_data
25
+
26
+ # The phone number to dial. Must be E164 format.
27
+ attr_accessor :phone_number
28
+
29
+ class EnumAttributeValidator
30
+ attr_reader :datatype
31
+ attr_reader :allowable_values
32
+
33
+ def initialize(datatype, allowable_values)
34
+ @allowable_values = allowable_values.map do |value|
35
+ case datatype.to_s
36
+ when /Integer/i
37
+ value.to_i
38
+ when /Float/i
39
+ value.to_f
40
+ else
41
+ value
42
+ end
43
+ end
44
+ end
45
+
46
+ def valid?(value)
47
+ !value || allowable_values.include?(value)
48
+ end
49
+ end
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ :'type' => :'type',
55
+ :'text' => :'text',
56
+ :'post_back_data' => :'postBackData',
57
+ :'phone_number' => :'phoneNumber'
58
+ }
59
+ end
60
+
61
+ # Returns all the JSON keys this model knows about
62
+ def self.acceptable_attributes
63
+ attribute_map.values
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'type' => :'RbmActionTypeEnum',
70
+ :'text' => :'String',
71
+ :'post_back_data' => :'String',
72
+ :'phone_number' => :'String'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ ])
80
+ end
81
+
82
+ # List of class defined in allOf (OpenAPI v3)
83
+ def self.openapi_all_of
84
+ [
85
+ :'RbmActionBase'
86
+ ]
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ if (!attributes.is_a?(Hash))
93
+ fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmActionDial` initialize method'
94
+ end
95
+
96
+ # check to see if the attribute exists and convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!self.class.attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmActionDial`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'type')
105
+ self.type = attributes[:'type']
106
+ else
107
+ self.type = nil
108
+ end
109
+
110
+ if attributes.key?(:'text')
111
+ self.text = attributes[:'text']
112
+ else
113
+ self.text = nil
114
+ end
115
+
116
+ if attributes.key?(:'post_back_data')
117
+ self.post_back_data = attributes[:'post_back_data']
118
+ else
119
+ self.post_back_data = nil
120
+ end
121
+
122
+ if attributes.key?(:'phone_number')
123
+ self.phone_number = attributes[:'phone_number']
124
+ else
125
+ self.phone_number = nil
126
+ end
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properties with the reasons
131
+ def list_invalid_properties
132
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
133
+ invalid_properties = Array.new
134
+ if @type.nil?
135
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
136
+ end
137
+
138
+ if @text.nil?
139
+ invalid_properties.push('invalid value for "text", text cannot be nil.')
140
+ end
141
+
142
+ if @text.to_s.length > 25
143
+ invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 25.')
144
+ end
145
+
146
+ if @post_back_data.nil?
147
+ invalid_properties.push('invalid value for "post_back_data", post_back_data cannot be nil.')
148
+ end
149
+
150
+ if @post_back_data.to_s.length > 2048
151
+ invalid_properties.push('invalid value for "post_back_data", the character length must be smaller than or equal to 2048.')
152
+ end
153
+
154
+ if @phone_number.nil?
155
+ invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
156
+ end
157
+
158
+ invalid_properties
159
+ end
160
+
161
+ # Check to see if the all the properties in the model are valid
162
+ # @return true if the model is valid
163
+ def valid?
164
+ warn '[DEPRECATED] the `valid?` method is obsolete'
165
+ return false if @type.nil?
166
+ return false if @text.nil?
167
+ return false if @text.to_s.length > 25
168
+ return false if @post_back_data.nil?
169
+ return false if @post_back_data.to_s.length > 2048
170
+ return false if @phone_number.nil?
171
+ true
172
+ end
173
+
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] text Value to be assigned
176
+ def text=(text)
177
+ if text.nil?
178
+ fail ArgumentError, 'text cannot be nil'
179
+ end
180
+
181
+ if text.to_s.length > 25
182
+ fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.'
183
+ end
184
+
185
+ @text = text
186
+ end
187
+
188
+ # Custom attribute writer method with validation
189
+ # @param [Object] post_back_data Value to be assigned
190
+ def post_back_data=(post_back_data)
191
+ if post_back_data.nil?
192
+ fail ArgumentError, 'post_back_data cannot be nil'
193
+ end
194
+
195
+ if post_back_data.to_s.length > 2048
196
+ fail ArgumentError, 'invalid value for "post_back_data", the character length must be smaller than or equal to 2048.'
197
+ end
198
+
199
+ @post_back_data = post_back_data
200
+ end
201
+
202
+ # Checks equality by comparing each attribute.
203
+ # @param [Object] Object to be compared
204
+ def ==(o)
205
+ return true if self.equal?(o)
206
+ self.class == o.class &&
207
+ type == o.type &&
208
+ text == o.text &&
209
+ post_back_data == o.post_back_data &&
210
+ phone_number == o.phone_number
211
+ end
212
+
213
+ # @see the `==` method
214
+ # @param [Object] Object to be compared
215
+ def eql?(o)
216
+ self == o
217
+ end
218
+
219
+ # Calculates hash code according to all attributes.
220
+ # @return [Integer] Hash code
221
+ def hash
222
+ [type, text, post_back_data, phone_number].hash
223
+ end
224
+
225
+ # Builds the object from hash
226
+ # @param [Hash] attributes Model attributes in the form of hash
227
+ # @return [Object] Returns the model itself
228
+ def self.build_from_hash(attributes)
229
+ return nil unless attributes.is_a?(Hash)
230
+ attributes = attributes.transform_keys(&:to_sym)
231
+ transformed_hash = {}
232
+ openapi_types.each_pair do |key, type|
233
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
234
+ transformed_hash["#{key}"] = nil
235
+ elsif type =~ /\AArray<(.*)>/i
236
+ # check to ensure the input is an array given that the attribute
237
+ # is documented as an array but the input is not
238
+ if attributes[attribute_map[key]].is_a?(Array)
239
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
240
+ end
241
+ elsif !attributes[attribute_map[key]].nil?
242
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
243
+ end
244
+ end
245
+ new(transformed_hash)
246
+ end
247
+
248
+ # Deserializes the data based on type
249
+ # @param string type Data type
250
+ # @param string value Value to be deserialized
251
+ # @return [Object] Deserialized data
252
+ def self._deserialize(type, value)
253
+ case type.to_sym
254
+ when :Time
255
+ Time.parse(value)
256
+ when :Date
257
+ Date.parse(value)
258
+ when :String
259
+ value.to_s
260
+ when :Integer
261
+ value.to_i
262
+ when :Float
263
+ value.to_f
264
+ when :Boolean
265
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
266
+ true
267
+ else
268
+ false
269
+ end
270
+ when :Object
271
+ # generic object (usually a Hash), return directly
272
+ value
273
+ when /\AArray<(?<inner_type>.+)>\z/
274
+ inner_type = Regexp.last_match[:inner_type]
275
+ value.map { |v| _deserialize(inner_type, v) }
276
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
277
+ k_type = Regexp.last_match[:k_type]
278
+ v_type = Regexp.last_match[:v_type]
279
+ {}.tap do |hash|
280
+ value.each do |k, v|
281
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
282
+ end
283
+ end
284
+ else # model
285
+ # models (e.g. Pet) or oneOf
286
+ klass = Bandwidth.const_get(type)
287
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
288
+ end
289
+ end
290
+
291
+ # Returns the string representation of the object
292
+ # @return [String] String presentation of the object
293
+ def to_s
294
+ to_hash.to_s
295
+ end
296
+
297
+ # to_body is an alias to to_hash (backward compatibility)
298
+ # @return [Hash] Returns the object in the form of hash
299
+ def to_body
300
+ to_hash
301
+ end
302
+
303
+ # Returns the object in the form of hash
304
+ # @return [Hash] Returns the object in the form of hash
305
+ def to_hash
306
+ hash = {}
307
+ self.class.attribute_map.each_pair do |attr, param|
308
+ value = self.send(attr)
309
+ if value.nil?
310
+ is_nullable = self.class.openapi_nullable.include?(attr)
311
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
312
+ end
313
+
314
+ hash[param] = _to_hash(value)
315
+ end
316
+ hash
317
+ end
318
+
319
+ # Outputs non-array value in the form of hash
320
+ # For object, use to_hash. Otherwise, just return the value
321
+ # @param [Object] value Any valid value
322
+ # @return [Hash] Returns the value in the form of hash
323
+ def _to_hash(value)
324
+ if value.is_a?(Array)
325
+ value.compact.map { |v| _to_hash(v) }
326
+ elsif value.is_a?(Hash)
327
+ {}.tap do |hash|
328
+ value.each { |k, v| hash[k] = _to_hash(v) }
329
+ end
330
+ elsif value.respond_to? :to_hash
331
+ value.to_hash
332
+ else
333
+ value
334
+ end
335
+ end
336
+ end
337
+ end