activitysmith 1.14.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 (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -5
  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 +67 -0
  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 +1 -1
  12. data/generated/activitysmith_openapi/models/live_activity_stream_delete_response.rb +12 -1
  13. data/generated/activitysmith_openapi/models/metric.rb +411 -0
  14. data/generated/activitysmith_openapi/models/metric_response.rb +221 -0
  15. data/generated/activitysmith_openapi/models/metric_upsert_request.rb +370 -0
  16. data/generated/activitysmith_openapi/models/metric_value_update_response.rb +14 -4
  17. data/generated/activitysmith_openapi/models/no_recipients_error.rb +21 -1
  18. data/generated/activitysmith_openapi/models/push_notification_dismiss_response.rb +257 -0
  19. data/generated/activitysmith_openapi/version.rb +1 -1
  20. data/generated/activitysmith_openapi.rb +8 -0
  21. data/generated/openapi-source.json +2 -2
  22. data/lib/activitysmith/client.rb +3 -1
  23. data/lib/activitysmith/devices.rb +30 -0
  24. data/lib/activitysmith/metrics.rb +15 -1
  25. data/lib/activitysmith/notifications.rb +11 -0
  26. data/lib/activitysmith/version.rb +1 -1
  27. data/lib/activitysmith.rb +1 -0
  28. metadata +11 -2
@@ -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
@@ -0,0 +1,221 @@
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 MetricResponse
18
+ attr_accessor :metric
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'metric' => :'metric'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'metric' => :'Metric'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::MetricResponse` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::MetricResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'metric')
61
+ self.metric = attributes[:'metric']
62
+ else
63
+ self.metric = nil
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
71
+ invalid_properties = Array.new
72
+ if @metric.nil?
73
+ invalid_properties.push('invalid value for "metric", metric cannot be nil.')
74
+ end
75
+
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ warn '[DEPRECATED] the `valid?` method is obsolete'
83
+ return false if @metric.nil?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ metric == o.metric
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [metric].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
122
+ end
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
125
+ end
126
+ end
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def self._deserialize(type, value)
135
+ case type.to_sym
136
+ when :Time
137
+ Time.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ # models (e.g. Pet) or oneOf
168
+ klass = OpenapiClient.const_get(type)
169
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ if value.nil?
192
+ is_nullable = self.class.openapi_nullable.include?(attr)
193
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
+ end
195
+
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end