daily-ruby 0.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 (59) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +119 -0
  5. data/Rakefile +10 -0
  6. data/daily-ruby.gemspec +40 -0
  7. data/daily.yaml +422 -0
  8. data/docs/CreateMeetingToken200Response.md +18 -0
  9. data/docs/MeetingTokenRequest.md +18 -0
  10. data/docs/MeetingTokenRequestProperties.md +56 -0
  11. data/docs/MeetingTokenRequestPropertiesPermissions.md +22 -0
  12. data/docs/MeetingTokenRequestPropertiesPermissionsCanAdmin.md +49 -0
  13. data/docs/MeetingTokenRequestPropertiesPermissionsCanSend.md +49 -0
  14. data/docs/MeetingTokensApi.md +79 -0
  15. data/docs/RoomApi.md +227 -0
  16. data/docs/RoomDeletedResponse.md +20 -0
  17. data/docs/RoomNotFoundResponse.md +20 -0
  18. data/docs/RoomRequest.md +22 -0
  19. data/docs/RoomRequestProperties.md +76 -0
  20. data/docs/RoomResponse.md +28 -0
  21. data/docs/ServerErrorResponse.md +18 -0
  22. data/git_push.sh +57 -0
  23. data/lib/daily-ruby/api/meeting_tokens_api.rb +86 -0
  24. data/lib/daily-ruby/api/room_api.rb +218 -0
  25. data/lib/daily-ruby/api_client.rb +431 -0
  26. data/lib/daily-ruby/api_error.rb +58 -0
  27. data/lib/daily-ruby/configuration.rb +382 -0
  28. data/lib/daily-ruby/models/create_meeting_token200_response.rb +214 -0
  29. data/lib/daily-ruby/models/meeting_token_request.rb +215 -0
  30. data/lib/daily-ruby/models/meeting_token_request_properties.rb +438 -0
  31. data/lib/daily-ruby/models/meeting_token_request_properties_permissions.rb +232 -0
  32. data/lib/daily-ruby/models/meeting_token_request_properties_permissions_can_admin.rb +105 -0
  33. data/lib/daily-ruby/models/meeting_token_request_properties_permissions_can_send.rb +105 -0
  34. data/lib/daily-ruby/models/room_deleted_response.rb +224 -0
  35. data/lib/daily-ruby/models/room_not_found_response.rb +224 -0
  36. data/lib/daily-ruby/models/room_request.rb +267 -0
  37. data/lib/daily-ruby/models/room_request_properties.rb +521 -0
  38. data/lib/daily-ruby/models/room_response.rb +260 -0
  39. data/lib/daily-ruby/models/server_error_response.rb +215 -0
  40. data/lib/daily-ruby/version.rb +15 -0
  41. data/lib/daily-ruby.rb +53 -0
  42. data/run.sh +16 -0
  43. data/script.rb +35 -0
  44. data/spec/api/meeting_tokens_api_spec.rb +47 -0
  45. data/spec/api/room_api_spec.rb +74 -0
  46. data/spec/models/create_meeting_token200_response_spec.rb +36 -0
  47. data/spec/models/meeting_token_request_properties_permissions_can_admin_spec.rb +32 -0
  48. data/spec/models/meeting_token_request_properties_permissions_can_send_spec.rb +32 -0
  49. data/spec/models/meeting_token_request_properties_permissions_spec.rb +48 -0
  50. data/spec/models/meeting_token_request_properties_spec.rb +158 -0
  51. data/spec/models/meeting_token_request_spec.rb +36 -0
  52. data/spec/models/room_deleted_response_spec.rb +42 -0
  53. data/spec/models/room_not_found_response_spec.rb +42 -0
  54. data/spec/models/room_request_properties_spec.rb +218 -0
  55. data/spec/models/room_request_spec.rb +52 -0
  56. data/spec/models/room_response_spec.rb +66 -0
  57. data/spec/models/server_error_response_spec.rb +36 -0
  58. data/spec/spec_helper.rb +111 -0
  59. metadata +169 -0
@@ -0,0 +1,215 @@
1
+ =begin
2
+ #Daily
3
+
4
+ #The official library for communicating with the Daily REST API.
5
+
6
+ The version of the OpenAPI document: 0.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Daily
17
+ # Meeting token request
18
+ class MeetingTokenRequest
19
+ attr_accessor :properties
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'properties' => :'properties'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'properties' => :'MeetingTokenRequestProperties'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Daily::MeetingTokenRequest` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Daily::MeetingTokenRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'properties')
62
+ self.properties = attributes[:'properties']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
70
+ invalid_properties = Array.new
71
+ invalid_properties
72
+ end
73
+
74
+ # Check to see if the all the properties in the model are valid
75
+ # @return true if the model is valid
76
+ def valid?
77
+ warn '[DEPRECATED] the `valid?` method is obsolete'
78
+ true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ properties == o.properties
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Integer] Hash code
97
+ def hash
98
+ [properties].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def self.build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ attributes = attributes.transform_keys(&:to_sym)
107
+ transformed_hash = {}
108
+ openapi_types.each_pair do |key, type|
109
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
110
+ transformed_hash["#{key}"] = nil
111
+ elsif type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[attribute_map[key]].is_a?(Array)
115
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
116
+ end
117
+ elsif !attributes[attribute_map[key]].nil?
118
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
119
+ end
120
+ end
121
+ new(transformed_hash)
122
+ end
123
+
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
128
+ def self._deserialize(type, value)
129
+ case type.to_sym
130
+ when :Time
131
+ Time.parse(value)
132
+ when :Date
133
+ Date.parse(value)
134
+ when :String
135
+ value.to_s
136
+ when :Integer
137
+ value.to_i
138
+ when :Float
139
+ value.to_f
140
+ when :Boolean
141
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
+ true
143
+ else
144
+ false
145
+ end
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
149
+ when /\AArray<(?<inner_type>.+)>\z/
150
+ inner_type = Regexp.last_match[:inner_type]
151
+ value.map { |v| _deserialize(inner_type, v) }
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
153
+ k_type = Regexp.last_match[:k_type]
154
+ v_type = Regexp.last_match[:v_type]
155
+ {}.tap do |hash|
156
+ value.each do |k, v|
157
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
158
+ end
159
+ end
160
+ else # model
161
+ # models (e.g. Pet) or oneOf
162
+ klass = Daily.const_get(type)
163
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ if value.nil?
186
+ is_nullable = self.class.openapi_nullable.include?(attr)
187
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
+ end
189
+
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+
213
+ end
214
+
215
+ end
@@ -0,0 +1,438 @@
1
+ =begin
2
+ #Daily
3
+
4
+ #The official library for communicating with the Daily REST API.
5
+
6
+ The version of the OpenAPI document: 0.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Daily
17
+ class MeetingTokenRequestProperties
18
+ attr_accessor :room_name
19
+
20
+ attr_accessor :eject_at_token_exp
21
+
22
+ attr_accessor :nbf
23
+
24
+ attr_accessor :exp
25
+
26
+ attr_accessor :is_owner
27
+
28
+ attr_accessor :user_name
29
+
30
+ attr_accessor :user_id
31
+
32
+ attr_accessor :enable_screenshare
33
+
34
+ attr_accessor :start_video_off
35
+
36
+ attr_accessor :start_audio_off
37
+
38
+ attr_accessor :enable_recording
39
+
40
+ attr_accessor :enable_prejoin_ui
41
+
42
+ attr_accessor :enable_live_captions_ui
43
+
44
+ attr_accessor :enable_recording_ui
45
+
46
+ attr_accessor :enable_terse_logging
47
+
48
+ attr_accessor :auto_start_transcription
49
+
50
+ attr_accessor :close_tab_on_exit
51
+
52
+ attr_accessor :redirect_on_meeting_exit
53
+
54
+ attr_accessor :lang
55
+
56
+ attr_accessor :permissions
57
+
58
+ class EnumAttributeValidator
59
+ attr_reader :datatype
60
+ attr_reader :allowable_values
61
+
62
+ def initialize(datatype, allowable_values)
63
+ @allowable_values = allowable_values.map do |value|
64
+ case datatype.to_s
65
+ when /Integer/i
66
+ value.to_i
67
+ when /Float/i
68
+ value.to_f
69
+ else
70
+ value
71
+ end
72
+ end
73
+ end
74
+
75
+ def valid?(value)
76
+ !value || allowable_values.include?(value)
77
+ end
78
+ end
79
+
80
+ # Attribute mapping from ruby-style variable name to JSON key.
81
+ def self.attribute_map
82
+ {
83
+ :'room_name' => :'room_name',
84
+ :'eject_at_token_exp' => :'eject_at_token_exp',
85
+ :'nbf' => :'nbf',
86
+ :'exp' => :'exp',
87
+ :'is_owner' => :'is_owner',
88
+ :'user_name' => :'user_name',
89
+ :'user_id' => :'user_id',
90
+ :'enable_screenshare' => :'enable_screenshare',
91
+ :'start_video_off' => :'start_video_off',
92
+ :'start_audio_off' => :'start_audio_off',
93
+ :'enable_recording' => :'enable_recording',
94
+ :'enable_prejoin_ui' => :'enable_prejoin_ui',
95
+ :'enable_live_captions_ui' => :'enable_live_captions_ui',
96
+ :'enable_recording_ui' => :'enable_recording_ui',
97
+ :'enable_terse_logging' => :'enable_terse_logging',
98
+ :'auto_start_transcription' => :'auto_start_transcription',
99
+ :'close_tab_on_exit' => :'close_tab_on_exit',
100
+ :'redirect_on_meeting_exit' => :'redirect_on_meeting_exit',
101
+ :'lang' => :'lang',
102
+ :'permissions' => :'permissions'
103
+ }
104
+ end
105
+
106
+ # Returns all the JSON keys this model knows about
107
+ def self.acceptable_attributes
108
+ attribute_map.values
109
+ end
110
+
111
+ # Attribute type mapping.
112
+ def self.openapi_types
113
+ {
114
+ :'room_name' => :'String',
115
+ :'eject_at_token_exp' => :'Boolean',
116
+ :'nbf' => :'Integer',
117
+ :'exp' => :'Integer',
118
+ :'is_owner' => :'Boolean',
119
+ :'user_name' => :'String',
120
+ :'user_id' => :'String',
121
+ :'enable_screenshare' => :'Boolean',
122
+ :'start_video_off' => :'Boolean',
123
+ :'start_audio_off' => :'Boolean',
124
+ :'enable_recording' => :'String',
125
+ :'enable_prejoin_ui' => :'Boolean',
126
+ :'enable_live_captions_ui' => :'Boolean',
127
+ :'enable_recording_ui' => :'Boolean',
128
+ :'enable_terse_logging' => :'Boolean',
129
+ :'auto_start_transcription' => :'Boolean',
130
+ :'close_tab_on_exit' => :'Boolean',
131
+ :'redirect_on_meeting_exit' => :'String',
132
+ :'lang' => :'String',
133
+ :'permissions' => :'MeetingTokenRequestPropertiesPermissions'
134
+ }
135
+ end
136
+
137
+ # List of attributes with nullable: true
138
+ def self.openapi_nullable
139
+ Set.new([
140
+ ])
141
+ end
142
+
143
+ # Initializes the object
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ def initialize(attributes = {})
146
+ if (!attributes.is_a?(Hash))
147
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Daily::MeetingTokenRequestProperties` initialize method"
148
+ end
149
+
150
+ # check to see if the attribute exists and convert string to symbol for hash key
151
+ attributes = attributes.each_with_object({}) { |(k, v), h|
152
+ if (!self.class.attribute_map.key?(k.to_sym))
153
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Daily::MeetingTokenRequestProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
154
+ end
155
+ h[k.to_sym] = v
156
+ }
157
+
158
+ if attributes.key?(:'room_name')
159
+ self.room_name = attributes[:'room_name']
160
+ else
161
+ self.room_name = nil
162
+ end
163
+
164
+ if attributes.key?(:'eject_at_token_exp')
165
+ self.eject_at_token_exp = attributes[:'eject_at_token_exp']
166
+ end
167
+
168
+ if attributes.key?(:'nbf')
169
+ self.nbf = attributes[:'nbf']
170
+ end
171
+
172
+ if attributes.key?(:'exp')
173
+ self.exp = attributes[:'exp']
174
+ end
175
+
176
+ if attributes.key?(:'is_owner')
177
+ self.is_owner = attributes[:'is_owner']
178
+ end
179
+
180
+ if attributes.key?(:'user_name')
181
+ self.user_name = attributes[:'user_name']
182
+ end
183
+
184
+ if attributes.key?(:'user_id')
185
+ self.user_id = attributes[:'user_id']
186
+ end
187
+
188
+ if attributes.key?(:'enable_screenshare')
189
+ self.enable_screenshare = attributes[:'enable_screenshare']
190
+ end
191
+
192
+ if attributes.key?(:'start_video_off')
193
+ self.start_video_off = attributes[:'start_video_off']
194
+ end
195
+
196
+ if attributes.key?(:'start_audio_off')
197
+ self.start_audio_off = attributes[:'start_audio_off']
198
+ end
199
+
200
+ if attributes.key?(:'enable_recording')
201
+ self.enable_recording = attributes[:'enable_recording']
202
+ end
203
+
204
+ if attributes.key?(:'enable_prejoin_ui')
205
+ self.enable_prejoin_ui = attributes[:'enable_prejoin_ui']
206
+ end
207
+
208
+ if attributes.key?(:'enable_live_captions_ui')
209
+ self.enable_live_captions_ui = attributes[:'enable_live_captions_ui']
210
+ end
211
+
212
+ if attributes.key?(:'enable_recording_ui')
213
+ self.enable_recording_ui = attributes[:'enable_recording_ui']
214
+ end
215
+
216
+ if attributes.key?(:'enable_terse_logging')
217
+ self.enable_terse_logging = attributes[:'enable_terse_logging']
218
+ end
219
+
220
+ if attributes.key?(:'auto_start_transcription')
221
+ self.auto_start_transcription = attributes[:'auto_start_transcription']
222
+ end
223
+
224
+ if attributes.key?(:'close_tab_on_exit')
225
+ self.close_tab_on_exit = attributes[:'close_tab_on_exit']
226
+ end
227
+
228
+ if attributes.key?(:'redirect_on_meeting_exit')
229
+ self.redirect_on_meeting_exit = attributes[:'redirect_on_meeting_exit']
230
+ end
231
+
232
+ if attributes.key?(:'lang')
233
+ self.lang = attributes[:'lang']
234
+ end
235
+
236
+ if attributes.key?(:'permissions')
237
+ self.permissions = attributes[:'permissions']
238
+ end
239
+ end
240
+
241
+ # Show invalid properties with the reasons. Usually used together with valid?
242
+ # @return Array for valid properties with the reasons
243
+ def list_invalid_properties
244
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
245
+ invalid_properties = Array.new
246
+ if @room_name.nil?
247
+ invalid_properties.push('invalid value for "room_name", room_name cannot be nil.')
248
+ end
249
+
250
+ invalid_properties
251
+ end
252
+
253
+ # Check to see if the all the properties in the model are valid
254
+ # @return true if the model is valid
255
+ def valid?
256
+ warn '[DEPRECATED] the `valid?` method is obsolete'
257
+ return false if @room_name.nil?
258
+ enable_recording_validator = EnumAttributeValidator.new('String', ["local", "cloud", "raw-tracks", "unknown_default_open_api"])
259
+ return false unless enable_recording_validator.valid?(@enable_recording)
260
+ lang_validator = EnumAttributeValidator.new('String', ["de", "en", "es", "fi", "fr", "it", "jp", "ka", "nl", "no", "pt", "pt-BR", "pl", "ru", "sv", "tr", "user", "unknown_default_open_api"])
261
+ return false unless lang_validator.valid?(@lang)
262
+ true
263
+ end
264
+
265
+ # Custom attribute writer method checking allowed values (enum).
266
+ # @param [Object] enable_recording Object to be assigned
267
+ def enable_recording=(enable_recording)
268
+ validator = EnumAttributeValidator.new('String', ["local", "cloud", "raw-tracks", "unknown_default_open_api"])
269
+ unless validator.valid?(enable_recording)
270
+ fail ArgumentError, "invalid value for \"enable_recording\", must be one of #{validator.allowable_values}."
271
+ end
272
+ @enable_recording = enable_recording
273
+ end
274
+
275
+ # Custom attribute writer method checking allowed values (enum).
276
+ # @param [Object] lang Object to be assigned
277
+ def lang=(lang)
278
+ validator = EnumAttributeValidator.new('String', ["de", "en", "es", "fi", "fr", "it", "jp", "ka", "nl", "no", "pt", "pt-BR", "pl", "ru", "sv", "tr", "user", "unknown_default_open_api"])
279
+ unless validator.valid?(lang)
280
+ fail ArgumentError, "invalid value for \"lang\", must be one of #{validator.allowable_values}."
281
+ end
282
+ @lang = lang
283
+ end
284
+
285
+ # Checks equality by comparing each attribute.
286
+ # @param [Object] Object to be compared
287
+ def ==(o)
288
+ return true if self.equal?(o)
289
+ self.class == o.class &&
290
+ room_name == o.room_name &&
291
+ eject_at_token_exp == o.eject_at_token_exp &&
292
+ nbf == o.nbf &&
293
+ exp == o.exp &&
294
+ is_owner == o.is_owner &&
295
+ user_name == o.user_name &&
296
+ user_id == o.user_id &&
297
+ enable_screenshare == o.enable_screenshare &&
298
+ start_video_off == o.start_video_off &&
299
+ start_audio_off == o.start_audio_off &&
300
+ enable_recording == o.enable_recording &&
301
+ enable_prejoin_ui == o.enable_prejoin_ui &&
302
+ enable_live_captions_ui == o.enable_live_captions_ui &&
303
+ enable_recording_ui == o.enable_recording_ui &&
304
+ enable_terse_logging == o.enable_terse_logging &&
305
+ auto_start_transcription == o.auto_start_transcription &&
306
+ close_tab_on_exit == o.close_tab_on_exit &&
307
+ redirect_on_meeting_exit == o.redirect_on_meeting_exit &&
308
+ lang == o.lang &&
309
+ permissions == o.permissions
310
+ end
311
+
312
+ # @see the `==` method
313
+ # @param [Object] Object to be compared
314
+ def eql?(o)
315
+ self == o
316
+ end
317
+
318
+ # Calculates hash code according to all attributes.
319
+ # @return [Integer] Hash code
320
+ def hash
321
+ [room_name, eject_at_token_exp, nbf, exp, is_owner, user_name, user_id, enable_screenshare, start_video_off, start_audio_off, enable_recording, enable_prejoin_ui, enable_live_captions_ui, enable_recording_ui, enable_terse_logging, auto_start_transcription, close_tab_on_exit, redirect_on_meeting_exit, lang, permissions].hash
322
+ end
323
+
324
+ # Builds the object from hash
325
+ # @param [Hash] attributes Model attributes in the form of hash
326
+ # @return [Object] Returns the model itself
327
+ def self.build_from_hash(attributes)
328
+ return nil unless attributes.is_a?(Hash)
329
+ attributes = attributes.transform_keys(&:to_sym)
330
+ transformed_hash = {}
331
+ openapi_types.each_pair do |key, type|
332
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
333
+ transformed_hash["#{key}"] = nil
334
+ elsif type =~ /\AArray<(.*)>/i
335
+ # check to ensure the input is an array given that the attribute
336
+ # is documented as an array but the input is not
337
+ if attributes[attribute_map[key]].is_a?(Array)
338
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
339
+ end
340
+ elsif !attributes[attribute_map[key]].nil?
341
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
342
+ end
343
+ end
344
+ new(transformed_hash)
345
+ end
346
+
347
+ # Deserializes the data based on type
348
+ # @param string type Data type
349
+ # @param string value Value to be deserialized
350
+ # @return [Object] Deserialized data
351
+ def self._deserialize(type, value)
352
+ case type.to_sym
353
+ when :Time
354
+ Time.parse(value)
355
+ when :Date
356
+ Date.parse(value)
357
+ when :String
358
+ value.to_s
359
+ when :Integer
360
+ value.to_i
361
+ when :Float
362
+ value.to_f
363
+ when :Boolean
364
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
365
+ true
366
+ else
367
+ false
368
+ end
369
+ when :Object
370
+ # generic object (usually a Hash), return directly
371
+ value
372
+ when /\AArray<(?<inner_type>.+)>\z/
373
+ inner_type = Regexp.last_match[:inner_type]
374
+ value.map { |v| _deserialize(inner_type, v) }
375
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
376
+ k_type = Regexp.last_match[:k_type]
377
+ v_type = Regexp.last_match[:v_type]
378
+ {}.tap do |hash|
379
+ value.each do |k, v|
380
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
381
+ end
382
+ end
383
+ else # model
384
+ # models (e.g. Pet) or oneOf
385
+ klass = Daily.const_get(type)
386
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
387
+ end
388
+ end
389
+
390
+ # Returns the string representation of the object
391
+ # @return [String] String presentation of the object
392
+ def to_s
393
+ to_hash.to_s
394
+ end
395
+
396
+ # to_body is an alias to to_hash (backward compatibility)
397
+ # @return [Hash] Returns the object in the form of hash
398
+ def to_body
399
+ to_hash
400
+ end
401
+
402
+ # Returns the object in the form of hash
403
+ # @return [Hash] Returns the object in the form of hash
404
+ def to_hash
405
+ hash = {}
406
+ self.class.attribute_map.each_pair do |attr, param|
407
+ value = self.send(attr)
408
+ if value.nil?
409
+ is_nullable = self.class.openapi_nullable.include?(attr)
410
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
411
+ end
412
+
413
+ hash[param] = _to_hash(value)
414
+ end
415
+ hash
416
+ end
417
+
418
+ # Outputs non-array value in the form of hash
419
+ # For object, use to_hash. Otherwise, just return the value
420
+ # @param [Object] value Any valid value
421
+ # @return [Hash] Returns the value in the form of hash
422
+ def _to_hash(value)
423
+ if value.is_a?(Array)
424
+ value.compact.map { |v| _to_hash(v) }
425
+ elsif value.is_a?(Hash)
426
+ {}.tap do |hash|
427
+ value.each { |k, v| hash[k] = _to_hash(v) }
428
+ end
429
+ elsif value.respond_to? :to_hash
430
+ value.to_hash
431
+ else
432
+ value
433
+ end
434
+ end
435
+
436
+ end
437
+
438
+ end