activitysmith 1.13.0 → 1.15.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -9
  3. data/generated/activitysmith_openapi/api/app_icon_badges_api.rb +4 -4
  4. data/generated/activitysmith_openapi/api/devices_api.rb +100 -0
  5. data/generated/activitysmith_openapi/api/live_activities_api.rb +2 -2
  6. data/generated/activitysmith_openapi/api/metrics_api.rb +87 -4
  7. data/generated/activitysmith_openapi/api/push_notifications_api.rb +147 -2
  8. data/generated/activitysmith_openapi/models/account_device.rb +367 -0
  9. data/generated/activitysmith_openapi/models/account_device_list_response.rb +239 -0
  10. data/generated/activitysmith_openapi/models/account_device_list_response_meta.rb +299 -0
  11. data/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb +35 -5
  12. data/generated/activitysmith_openapi/models/live_activity_end_response.rb +64 -4
  13. data/generated/activitysmith_openapi/models/live_activity_start_response.rb +35 -4
  14. data/generated/activitysmith_openapi/models/live_activity_stream_delete_response.rb +64 -4
  15. data/generated/activitysmith_openapi/models/live_activity_stream_put_response.rb +54 -4
  16. data/generated/activitysmith_openapi/models/live_activity_update_response.rb +76 -4
  17. data/generated/activitysmith_openapi/models/metric.rb +411 -0
  18. data/generated/activitysmith_openapi/models/metric_response.rb +221 -0
  19. data/generated/activitysmith_openapi/models/metric_upsert_request.rb +370 -0
  20. data/generated/activitysmith_openapi/models/metric_value_update_response.rb +14 -4
  21. data/generated/activitysmith_openapi/models/no_recipients_error.rb +21 -1
  22. data/generated/activitysmith_openapi/models/push_notification_dismiss_response.rb +257 -0
  23. data/generated/activitysmith_openapi/models/push_notification_replace_request.rb +434 -0
  24. data/generated/activitysmith_openapi/models/push_notification_replace_response.rb +298 -0
  25. data/generated/activitysmith_openapi/models/push_notification_response.rb +63 -4
  26. data/generated/activitysmith_openapi/version.rb +1 -1
  27. data/generated/activitysmith_openapi.rb +10 -0
  28. data/generated/openapi-source.json +2 -2
  29. data/lib/activitysmith/client.rb +3 -1
  30. data/lib/activitysmith/devices.rb +30 -0
  31. data/lib/activitysmith/metrics.rb +15 -1
  32. data/lib/activitysmith/notifications.rb +23 -0
  33. data/lib/activitysmith/version.rb +1 -1
  34. data/lib/activitysmith.rb +1 -0
  35. metadata +13 -2
@@ -37,8 +37,21 @@ module OpenapiClient
37
37
  # Optional tags to organize and filter notification history.
38
38
  attr_accessor :tags
39
39
 
40
+ # Present on `updated` responses when the current Live Activity has received more than 12 updates and has averaged more than one update every 2 minutes since it started. The update is still sent, but iOS may throttle Live Activities that update this often.
41
+ attr_accessor :warning
42
+
40
43
  attr_accessor :timestamp
41
44
 
45
+ # True when the request had no effect.
46
+ attr_accessor :ignored
47
+
48
+ attr_accessor :remote_push_sent
49
+
50
+ attr_accessor :message
51
+
52
+ # Per-device delivery errors when some devices could not be reached.
53
+ attr_accessor :errors
54
+
42
55
  class EnumAttributeValidator
43
56
  attr_reader :datatype
44
57
  attr_reader :allowable_values
@@ -74,7 +87,12 @@ module OpenapiClient
74
87
  :'users_notified' => :'users_notified',
75
88
  :'effective_channel_slugs' => :'effective_channel_slugs',
76
89
  :'tags' => :'tags',
77
- :'timestamp' => :'timestamp'
90
+ :'warning' => :'warning',
91
+ :'timestamp' => :'timestamp',
92
+ :'ignored' => :'ignored',
93
+ :'remote_push_sent' => :'remote_push_sent',
94
+ :'message' => :'message',
95
+ :'errors' => :'errors'
78
96
  }
79
97
  end
80
98
 
@@ -96,7 +114,12 @@ module OpenapiClient
96
114
  :'users_notified' => :'Integer',
97
115
  :'effective_channel_slugs' => :'Array<String>',
98
116
  :'tags' => :'Array<String>',
99
- :'timestamp' => :'Time'
117
+ :'warning' => :'String',
118
+ :'timestamp' => :'Time',
119
+ :'ignored' => :'Boolean',
120
+ :'remote_push_sent' => :'Boolean',
121
+ :'message' => :'String',
122
+ :'errors' => :'Array<String>'
100
123
  }
101
124
  end
102
125
 
@@ -172,11 +195,33 @@ module OpenapiClient
172
195
  end
173
196
  end
174
197
 
198
+ if attributes.key?(:'warning')
199
+ self.warning = attributes[:'warning']
200
+ end
201
+
175
202
  if attributes.key?(:'timestamp')
176
203
  self.timestamp = attributes[:'timestamp']
177
204
  else
178
205
  self.timestamp = nil
179
206
  end
207
+
208
+ if attributes.key?(:'ignored')
209
+ self.ignored = attributes[:'ignored']
210
+ end
211
+
212
+ if attributes.key?(:'remote_push_sent')
213
+ self.remote_push_sent = attributes[:'remote_push_sent']
214
+ end
215
+
216
+ if attributes.key?(:'message')
217
+ self.message = attributes[:'message']
218
+ end
219
+
220
+ if attributes.key?(:'errors')
221
+ if (value = attributes[:'errors']).is_a?(Array)
222
+ self.errors = value
223
+ end
224
+ end
180
225
  end
181
226
 
182
227
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -241,7 +286,12 @@ module OpenapiClient
241
286
  users_notified == o.users_notified &&
242
287
  effective_channel_slugs == o.effective_channel_slugs &&
243
288
  tags == o.tags &&
244
- timestamp == o.timestamp
289
+ warning == o.warning &&
290
+ timestamp == o.timestamp &&
291
+ ignored == o.ignored &&
292
+ remote_push_sent == o.remote_push_sent &&
293
+ message == o.message &&
294
+ errors == o.errors
245
295
  end
246
296
 
247
297
  # @see the `==` method
@@ -253,7 +303,7 @@ module OpenapiClient
253
303
  # Calculates hash code according to all attributes.
254
304
  # @return [Integer] Hash code
255
305
  def hash
256
- [success, operation, stream_key, activity_id, previous_activity_id, devices_notified, devices_queued, users_notified, effective_channel_slugs, tags, timestamp].hash
306
+ [success, operation, stream_key, activity_id, previous_activity_id, devices_notified, devices_queued, users_notified, effective_channel_slugs, tags, warning, timestamp, ignored, remote_push_sent, message, errors].hash
257
307
  end
258
308
 
259
309
  # Builds the object from hash
@@ -26,6 +26,23 @@ module OpenapiClient
26
26
 
27
27
  attr_accessor :timestamp
28
28
 
29
+ attr_accessor :users_notified
30
+
31
+ attr_accessor :effective_channel_slugs
32
+
33
+ # Optional tags to organize and filter notification history.
34
+ attr_accessor :tags
35
+
36
+ # Present when the update started a new Live Activity for a managed stream.
37
+ attr_accessor :operation
38
+
39
+ attr_accessor :stream_key
40
+
41
+ attr_accessor :previous_activity_id
42
+
43
+ # Per-device delivery errors when some devices could not be reached.
44
+ attr_accessor :errors
45
+
29
46
  # Attribute mapping from ruby-style variable name to JSON key.
30
47
  def self.attribute_map
31
48
  {
@@ -33,7 +50,14 @@ module OpenapiClient
33
50
  :'activity_id' => :'activity_id',
34
51
  :'devices_queued' => :'devices_queued',
35
52
  :'devices_notified' => :'devices_notified',
36
- :'timestamp' => :'timestamp'
53
+ :'timestamp' => :'timestamp',
54
+ :'users_notified' => :'users_notified',
55
+ :'effective_channel_slugs' => :'effective_channel_slugs',
56
+ :'tags' => :'tags',
57
+ :'operation' => :'operation',
58
+ :'stream_key' => :'stream_key',
59
+ :'previous_activity_id' => :'previous_activity_id',
60
+ :'errors' => :'errors'
37
61
  }
38
62
  end
39
63
 
@@ -49,7 +73,14 @@ module OpenapiClient
49
73
  :'activity_id' => :'String',
50
74
  :'devices_queued' => :'Integer',
51
75
  :'devices_notified' => :'Integer',
52
- :'timestamp' => :'Time'
76
+ :'timestamp' => :'Time',
77
+ :'users_notified' => :'Integer',
78
+ :'effective_channel_slugs' => :'Array<String>',
79
+ :'tags' => :'Array<String>',
80
+ :'operation' => :'String',
81
+ :'stream_key' => :'String',
82
+ :'previous_activity_id' => :'String',
83
+ :'errors' => :'Array<String>'
53
84
  }
54
85
  end
55
86
 
@@ -99,6 +130,40 @@ module OpenapiClient
99
130
  else
100
131
  self.timestamp = nil
101
132
  end
133
+
134
+ if attributes.key?(:'users_notified')
135
+ self.users_notified = attributes[:'users_notified']
136
+ end
137
+
138
+ if attributes.key?(:'effective_channel_slugs')
139
+ if (value = attributes[:'effective_channel_slugs']).is_a?(Array)
140
+ self.effective_channel_slugs = value
141
+ end
142
+ end
143
+
144
+ if attributes.key?(:'tags')
145
+ if (value = attributes[:'tags']).is_a?(Array)
146
+ self.tags = value
147
+ end
148
+ end
149
+
150
+ if attributes.key?(:'operation')
151
+ self.operation = attributes[:'operation']
152
+ end
153
+
154
+ if attributes.key?(:'stream_key')
155
+ self.stream_key = attributes[:'stream_key']
156
+ end
157
+
158
+ if attributes.key?(:'previous_activity_id')
159
+ self.previous_activity_id = attributes[:'previous_activity_id']
160
+ end
161
+
162
+ if attributes.key?(:'errors')
163
+ if (value = attributes[:'errors']).is_a?(Array)
164
+ self.errors = value
165
+ end
166
+ end
102
167
  end
103
168
 
104
169
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -140,7 +205,14 @@ module OpenapiClient
140
205
  activity_id == o.activity_id &&
141
206
  devices_queued == o.devices_queued &&
142
207
  devices_notified == o.devices_notified &&
143
- timestamp == o.timestamp
208
+ timestamp == o.timestamp &&
209
+ users_notified == o.users_notified &&
210
+ effective_channel_slugs == o.effective_channel_slugs &&
211
+ tags == o.tags &&
212
+ operation == o.operation &&
213
+ stream_key == o.stream_key &&
214
+ previous_activity_id == o.previous_activity_id &&
215
+ errors == o.errors
144
216
  end
145
217
 
146
218
  # @see the `==` method
@@ -152,7 +224,7 @@ module OpenapiClient
152
224
  # Calculates hash code according to all attributes.
153
225
  # @return [Integer] Hash code
154
226
  def hash
155
- [success, activity_id, devices_queued, devices_notified, timestamp].hash
227
+ [success, activity_id, devices_queued, devices_notified, timestamp, users_notified, effective_channel_slugs, tags, operation, stream_key, previous_activity_id, errors].hash
156
228
  end
157
229
 
158
230
  # Builds the object from hash
@@ -0,0 +1,411 @@
1
+ =begin
2
+ #ActivitySmith API
3
+
4
+ #Send push notifications and Live Activities to your own devices via a single API key.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.7.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class Metric
18
+ attr_accessor :public_id
19
+
20
+ attr_accessor :key
21
+
22
+ attr_accessor :label
23
+
24
+ attr_accessor :format
25
+
26
+ attr_accessor :currency_code
27
+
28
+ attr_accessor :unit
29
+
30
+ attr_accessor :unit_spacing
31
+
32
+ attr_accessor :latest_value
33
+
34
+ attr_accessor :latest_value_at
35
+
36
+ attr_accessor :created_at
37
+
38
+ attr_accessor :updated_at
39
+
40
+ class EnumAttributeValidator
41
+ attr_reader :datatype
42
+ attr_reader :allowable_values
43
+
44
+ def initialize(datatype, allowable_values)
45
+ @allowable_values = allowable_values.map do |value|
46
+ case datatype.to_s
47
+ when /Integer/i
48
+ value.to_i
49
+ when /Float/i
50
+ value.to_f
51
+ else
52
+ value
53
+ end
54
+ end
55
+ end
56
+
57
+ def valid?(value)
58
+ !value || allowable_values.include?(value)
59
+ end
60
+ end
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :'public_id' => :'public_id',
66
+ :'key' => :'key',
67
+ :'label' => :'label',
68
+ :'format' => :'format',
69
+ :'currency_code' => :'currency_code',
70
+ :'unit' => :'unit',
71
+ :'unit_spacing' => :'unit_spacing',
72
+ :'latest_value' => :'latest_value',
73
+ :'latest_value_at' => :'latest_value_at',
74
+ :'created_at' => :'created_at',
75
+ :'updated_at' => :'updated_at'
76
+ }
77
+ end
78
+
79
+ # Returns all the JSON keys this model knows about
80
+ def self.acceptable_attributes
81
+ attribute_map.values
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.openapi_types
86
+ {
87
+ :'public_id' => :'String',
88
+ :'key' => :'String',
89
+ :'label' => :'String',
90
+ :'format' => :'String',
91
+ :'currency_code' => :'String',
92
+ :'unit' => :'String',
93
+ :'unit_spacing' => :'String',
94
+ :'latest_value' => :'Object',
95
+ :'latest_value_at' => :'Time',
96
+ :'created_at' => :'Time',
97
+ :'updated_at' => :'Time'
98
+ }
99
+ end
100
+
101
+ # List of attributes with nullable: true
102
+ def self.openapi_nullable
103
+ Set.new([
104
+ :'currency_code',
105
+ :'unit',
106
+ :'latest_value',
107
+ :'latest_value_at',
108
+ ])
109
+ end
110
+
111
+ # Initializes the object
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ def initialize(attributes = {})
114
+ if (!attributes.is_a?(Hash))
115
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Metric` initialize method"
116
+ end
117
+
118
+ # check to see if the attribute exists and convert string to symbol for hash key
119
+ attributes = attributes.each_with_object({}) { |(k, v), h|
120
+ if (!self.class.attribute_map.key?(k.to_sym))
121
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Metric`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
122
+ end
123
+ h[k.to_sym] = v
124
+ }
125
+
126
+ if attributes.key?(:'public_id')
127
+ self.public_id = attributes[:'public_id']
128
+ else
129
+ self.public_id = nil
130
+ end
131
+
132
+ if attributes.key?(:'key')
133
+ self.key = attributes[:'key']
134
+ else
135
+ self.key = nil
136
+ end
137
+
138
+ if attributes.key?(:'label')
139
+ self.label = attributes[:'label']
140
+ else
141
+ self.label = nil
142
+ end
143
+
144
+ if attributes.key?(:'format')
145
+ self.format = attributes[:'format']
146
+ else
147
+ self.format = nil
148
+ end
149
+
150
+ if attributes.key?(:'currency_code')
151
+ self.currency_code = attributes[:'currency_code']
152
+ else
153
+ self.currency_code = nil
154
+ end
155
+
156
+ if attributes.key?(:'unit')
157
+ self.unit = attributes[:'unit']
158
+ else
159
+ self.unit = nil
160
+ end
161
+
162
+ if attributes.key?(:'unit_spacing')
163
+ self.unit_spacing = attributes[:'unit_spacing']
164
+ else
165
+ self.unit_spacing = nil
166
+ end
167
+
168
+ if attributes.key?(:'latest_value')
169
+ self.latest_value = attributes[:'latest_value']
170
+ else
171
+ self.latest_value = nil
172
+ end
173
+
174
+ if attributes.key?(:'latest_value_at')
175
+ self.latest_value_at = attributes[:'latest_value_at']
176
+ else
177
+ self.latest_value_at = nil
178
+ end
179
+
180
+ if attributes.key?(:'created_at')
181
+ self.created_at = attributes[:'created_at']
182
+ else
183
+ self.created_at = nil
184
+ end
185
+
186
+ if attributes.key?(:'updated_at')
187
+ self.updated_at = attributes[:'updated_at']
188
+ else
189
+ self.updated_at = nil
190
+ end
191
+ end
192
+
193
+ # Show invalid properties with the reasons. Usually used together with valid?
194
+ # @return Array for valid properties with the reasons
195
+ def list_invalid_properties
196
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
197
+ invalid_properties = Array.new
198
+ if @public_id.nil?
199
+ invalid_properties.push('invalid value for "public_id", public_id cannot be nil.')
200
+ end
201
+
202
+ if @key.nil?
203
+ invalid_properties.push('invalid value for "key", key cannot be nil.')
204
+ end
205
+
206
+ if @label.nil?
207
+ invalid_properties.push('invalid value for "label", label cannot be nil.')
208
+ end
209
+
210
+ if @format.nil?
211
+ invalid_properties.push('invalid value for "format", format cannot be nil.')
212
+ end
213
+
214
+ if @unit_spacing.nil?
215
+ invalid_properties.push('invalid value for "unit_spacing", unit_spacing cannot be nil.')
216
+ end
217
+
218
+ if @created_at.nil?
219
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
220
+ end
221
+
222
+ if @updated_at.nil?
223
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
224
+ end
225
+
226
+ invalid_properties
227
+ end
228
+
229
+ # Check to see if the all the properties in the model are valid
230
+ # @return true if the model is valid
231
+ def valid?
232
+ warn '[DEPRECATED] the `valid?` method is obsolete'
233
+ return false if @public_id.nil?
234
+ return false if @key.nil?
235
+ return false if @label.nil?
236
+ return false if @format.nil?
237
+ format_validator = EnumAttributeValidator.new('String', ["number", "currency", "percent", "unit", "string"])
238
+ return false unless format_validator.valid?(@format)
239
+ return false if @unit_spacing.nil?
240
+ unit_spacing_validator = EnumAttributeValidator.new('String', ["none", "space"])
241
+ return false unless unit_spacing_validator.valid?(@unit_spacing)
242
+ return false if @created_at.nil?
243
+ return false if @updated_at.nil?
244
+ true
245
+ end
246
+
247
+ # Custom attribute writer method checking allowed values (enum).
248
+ # @param [Object] format Object to be assigned
249
+ def format=(format)
250
+ validator = EnumAttributeValidator.new('String', ["number", "currency", "percent", "unit", "string"])
251
+ unless validator.valid?(format)
252
+ fail ArgumentError, "invalid value for \"format\", must be one of #{validator.allowable_values}."
253
+ end
254
+ @format = format
255
+ end
256
+
257
+ # Custom attribute writer method checking allowed values (enum).
258
+ # @param [Object] unit_spacing Object to be assigned
259
+ def unit_spacing=(unit_spacing)
260
+ validator = EnumAttributeValidator.new('String', ["none", "space"])
261
+ unless validator.valid?(unit_spacing)
262
+ fail ArgumentError, "invalid value for \"unit_spacing\", must be one of #{validator.allowable_values}."
263
+ end
264
+ @unit_spacing = unit_spacing
265
+ end
266
+
267
+ # Checks equality by comparing each attribute.
268
+ # @param [Object] Object to be compared
269
+ def ==(o)
270
+ return true if self.equal?(o)
271
+ self.class == o.class &&
272
+ public_id == o.public_id &&
273
+ key == o.key &&
274
+ label == o.label &&
275
+ format == o.format &&
276
+ currency_code == o.currency_code &&
277
+ unit == o.unit &&
278
+ unit_spacing == o.unit_spacing &&
279
+ latest_value == o.latest_value &&
280
+ latest_value_at == o.latest_value_at &&
281
+ created_at == o.created_at &&
282
+ updated_at == o.updated_at
283
+ end
284
+
285
+ # @see the `==` method
286
+ # @param [Object] Object to be compared
287
+ def eql?(o)
288
+ self == o
289
+ end
290
+
291
+ # Calculates hash code according to all attributes.
292
+ # @return [Integer] Hash code
293
+ def hash
294
+ [public_id, key, label, format, currency_code, unit, unit_spacing, latest_value, latest_value_at, created_at, updated_at].hash
295
+ end
296
+
297
+ # Builds the object from hash
298
+ # @param [Hash] attributes Model attributes in the form of hash
299
+ # @return [Object] Returns the model itself
300
+ def self.build_from_hash(attributes)
301
+ return nil unless attributes.is_a?(Hash)
302
+ attributes = attributes.transform_keys(&:to_sym)
303
+ transformed_hash = {}
304
+ openapi_types.each_pair do |key, type|
305
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
306
+ transformed_hash["#{key}"] = nil
307
+ elsif type =~ /\AArray<(.*)>/i
308
+ # check to ensure the input is an array given that the attribute
309
+ # is documented as an array but the input is not
310
+ if attributes[attribute_map[key]].is_a?(Array)
311
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
312
+ end
313
+ elsif !attributes[attribute_map[key]].nil?
314
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
315
+ end
316
+ end
317
+ new(transformed_hash)
318
+ end
319
+
320
+ # Deserializes the data based on type
321
+ # @param string type Data type
322
+ # @param string value Value to be deserialized
323
+ # @return [Object] Deserialized data
324
+ def self._deserialize(type, value)
325
+ case type.to_sym
326
+ when :Time
327
+ Time.parse(value)
328
+ when :Date
329
+ Date.parse(value)
330
+ when :String
331
+ value.to_s
332
+ when :Integer
333
+ value.to_i
334
+ when :Float
335
+ value.to_f
336
+ when :Boolean
337
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
338
+ true
339
+ else
340
+ false
341
+ end
342
+ when :Object
343
+ # generic object (usually a Hash), return directly
344
+ value
345
+ when /\AArray<(?<inner_type>.+)>\z/
346
+ inner_type = Regexp.last_match[:inner_type]
347
+ value.map { |v| _deserialize(inner_type, v) }
348
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
349
+ k_type = Regexp.last_match[:k_type]
350
+ v_type = Regexp.last_match[:v_type]
351
+ {}.tap do |hash|
352
+ value.each do |k, v|
353
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
354
+ end
355
+ end
356
+ else # model
357
+ # models (e.g. Pet) or oneOf
358
+ klass = OpenapiClient.const_get(type)
359
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
360
+ end
361
+ end
362
+
363
+ # Returns the string representation of the object
364
+ # @return [String] String presentation of the object
365
+ def to_s
366
+ to_hash.to_s
367
+ end
368
+
369
+ # to_body is an alias to to_hash (backward compatibility)
370
+ # @return [Hash] Returns the object in the form of hash
371
+ def to_body
372
+ to_hash
373
+ end
374
+
375
+ # Returns the object in the form of hash
376
+ # @return [Hash] Returns the object in the form of hash
377
+ def to_hash
378
+ hash = {}
379
+ self.class.attribute_map.each_pair do |attr, param|
380
+ value = self.send(attr)
381
+ if value.nil?
382
+ is_nullable = self.class.openapi_nullable.include?(attr)
383
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
384
+ end
385
+
386
+ hash[param] = _to_hash(value)
387
+ end
388
+ hash
389
+ end
390
+
391
+ # Outputs non-array value in the form of hash
392
+ # For object, use to_hash. Otherwise, just return the value
393
+ # @param [Object] value Any valid value
394
+ # @return [Hash] Returns the value in the form of hash
395
+ def _to_hash(value)
396
+ if value.is_a?(Array)
397
+ value.compact.map { |v| _to_hash(v) }
398
+ elsif value.is_a?(Hash)
399
+ {}.tap do |hash|
400
+ value.each { |k, v| hash[k] = _to_hash(v) }
401
+ end
402
+ elsif value.respond_to? :to_hash
403
+ value.to_hash
404
+ else
405
+ value
406
+ end
407
+ end
408
+
409
+ end
410
+
411
+ end