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