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,370 @@
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
+ # Metric definition. Omitted fields keep their current values, or use defaults for a new metric: a label made from the key and the number format.
18
+ class MetricUpsertRequest
19
+ # Name shown on the widget.
20
+ attr_accessor :label
21
+
22
+ # How widgets display the value: number (1,234), currency (requires currency_code), percent (send 99.9 to show 99.9%), unit (a number with a unit suffix, such as 120 ms), or string (text up to 64 characters). Defaults to number for a new metric.
23
+ attr_accessor :format
24
+
25
+ # 3-letter ISO 4217 currency code, such as USD. Required for the currency format.
26
+ attr_accessor :currency_code
27
+
28
+ # Unit suffix for the unit format, such as ms or GB.
29
+ attr_accessor :unit
30
+
31
+ # For the unit format: none shows 120ms, space shows 120 ms.
32
+ attr_accessor :unit_spacing
33
+
34
+ class EnumAttributeValidator
35
+ attr_reader :datatype
36
+ attr_reader :allowable_values
37
+
38
+ def initialize(datatype, allowable_values)
39
+ @allowable_values = allowable_values.map do |value|
40
+ case datatype.to_s
41
+ when /Integer/i
42
+ value.to_i
43
+ when /Float/i
44
+ value.to_f
45
+ else
46
+ value
47
+ end
48
+ end
49
+ end
50
+
51
+ def valid?(value)
52
+ !value || allowable_values.include?(value)
53
+ end
54
+ end
55
+
56
+ # Attribute mapping from ruby-style variable name to JSON key.
57
+ def self.attribute_map
58
+ {
59
+ :'label' => :'label',
60
+ :'format' => :'format',
61
+ :'currency_code' => :'currency_code',
62
+ :'unit' => :'unit',
63
+ :'unit_spacing' => :'unit_spacing'
64
+ }
65
+ end
66
+
67
+ # Returns all the JSON keys this model knows about
68
+ def self.acceptable_attributes
69
+ attribute_map.values
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'label' => :'String',
76
+ :'format' => :'String',
77
+ :'currency_code' => :'String',
78
+ :'unit' => :'String',
79
+ :'unit_spacing' => :'String'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ ])
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ if (!attributes.is_a?(Hash))
93
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::MetricUpsertRequest` initialize method"
94
+ end
95
+
96
+ # check to see if the attribute exists and convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!self.class.attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::MetricUpsertRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'label')
105
+ self.label = attributes[:'label']
106
+ end
107
+
108
+ if attributes.key?(:'format')
109
+ self.format = attributes[:'format']
110
+ end
111
+
112
+ if attributes.key?(:'currency_code')
113
+ self.currency_code = attributes[:'currency_code']
114
+ end
115
+
116
+ if attributes.key?(:'unit')
117
+ self.unit = attributes[:'unit']
118
+ end
119
+
120
+ if attributes.key?(:'unit_spacing')
121
+ self.unit_spacing = attributes[:'unit_spacing']
122
+ end
123
+ end
124
+
125
+ # Show invalid properties with the reasons. Usually used together with valid?
126
+ # @return Array for valid properties with the reasons
127
+ def list_invalid_properties
128
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
129
+ invalid_properties = Array.new
130
+ if !@label.nil? && @label.to_s.length > 80
131
+ invalid_properties.push('invalid value for "label", the character length must be smaller than or equal to 80.')
132
+ end
133
+
134
+ if !@label.nil? && @label.to_s.length < 1
135
+ invalid_properties.push('invalid value for "label", the character length must be great than or equal to 1.')
136
+ end
137
+
138
+ pattern = Regexp.new(/^[A-Za-z]{3}$/)
139
+ if !@currency_code.nil? && @currency_code !~ pattern
140
+ invalid_properties.push("invalid value for \"currency_code\", must conform to the pattern #{pattern}.")
141
+ end
142
+
143
+ if !@unit.nil? && @unit.to_s.length > 16
144
+ invalid_properties.push('invalid value for "unit", the character length must be smaller than or equal to 16.')
145
+ end
146
+
147
+ invalid_properties
148
+ end
149
+
150
+ # Check to see if the all the properties in the model are valid
151
+ # @return true if the model is valid
152
+ def valid?
153
+ warn '[DEPRECATED] the `valid?` method is obsolete'
154
+ return false if !@label.nil? && @label.to_s.length > 80
155
+ return false if !@label.nil? && @label.to_s.length < 1
156
+ format_validator = EnumAttributeValidator.new('String', ["number", "currency", "percent", "unit", "string"])
157
+ return false unless format_validator.valid?(@format)
158
+ return false if !@currency_code.nil? && @currency_code !~ Regexp.new(/^[A-Za-z]{3}$/)
159
+ return false if !@unit.nil? && @unit.to_s.length > 16
160
+ unit_spacing_validator = EnumAttributeValidator.new('String', ["none", "space"])
161
+ return false unless unit_spacing_validator.valid?(@unit_spacing)
162
+ true
163
+ end
164
+
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] label Value to be assigned
167
+ def label=(label)
168
+ if label.nil?
169
+ fail ArgumentError, 'label cannot be nil'
170
+ end
171
+
172
+ if label.to_s.length > 80
173
+ fail ArgumentError, 'invalid value for "label", the character length must be smaller than or equal to 80.'
174
+ end
175
+
176
+ if label.to_s.length < 1
177
+ fail ArgumentError, 'invalid value for "label", the character length must be great than or equal to 1.'
178
+ end
179
+
180
+ @label = label
181
+ end
182
+
183
+ # Custom attribute writer method checking allowed values (enum).
184
+ # @param [Object] format Object to be assigned
185
+ def format=(format)
186
+ validator = EnumAttributeValidator.new('String', ["number", "currency", "percent", "unit", "string"])
187
+ unless validator.valid?(format)
188
+ fail ArgumentError, "invalid value for \"format\", must be one of #{validator.allowable_values}."
189
+ end
190
+ @format = format
191
+ end
192
+
193
+ # Custom attribute writer method with validation
194
+ # @param [Object] currency_code Value to be assigned
195
+ def currency_code=(currency_code)
196
+ if currency_code.nil?
197
+ fail ArgumentError, 'currency_code cannot be nil'
198
+ end
199
+
200
+ pattern = Regexp.new(/^[A-Za-z]{3}$/)
201
+ if currency_code !~ pattern
202
+ fail ArgumentError, "invalid value for \"currency_code\", must conform to the pattern #{pattern}."
203
+ end
204
+
205
+ @currency_code = currency_code
206
+ end
207
+
208
+ # Custom attribute writer method with validation
209
+ # @param [Object] unit Value to be assigned
210
+ def unit=(unit)
211
+ if unit.nil?
212
+ fail ArgumentError, 'unit cannot be nil'
213
+ end
214
+
215
+ if unit.to_s.length > 16
216
+ fail ArgumentError, 'invalid value for "unit", the character length must be smaller than or equal to 16.'
217
+ end
218
+
219
+ @unit = unit
220
+ end
221
+
222
+ # Custom attribute writer method checking allowed values (enum).
223
+ # @param [Object] unit_spacing Object to be assigned
224
+ def unit_spacing=(unit_spacing)
225
+ validator = EnumAttributeValidator.new('String', ["none", "space"])
226
+ unless validator.valid?(unit_spacing)
227
+ fail ArgumentError, "invalid value for \"unit_spacing\", must be one of #{validator.allowable_values}."
228
+ end
229
+ @unit_spacing = unit_spacing
230
+ end
231
+
232
+ # Checks equality by comparing each attribute.
233
+ # @param [Object] Object to be compared
234
+ def ==(o)
235
+ return true if self.equal?(o)
236
+ self.class == o.class &&
237
+ label == o.label &&
238
+ format == o.format &&
239
+ currency_code == o.currency_code &&
240
+ unit == o.unit &&
241
+ unit_spacing == o.unit_spacing
242
+ end
243
+
244
+ # @see the `==` method
245
+ # @param [Object] Object to be compared
246
+ def eql?(o)
247
+ self == o
248
+ end
249
+
250
+ # Calculates hash code according to all attributes.
251
+ # @return [Integer] Hash code
252
+ def hash
253
+ [label, format, currency_code, unit, unit_spacing].hash
254
+ end
255
+
256
+ # Builds the object from hash
257
+ # @param [Hash] attributes Model attributes in the form of hash
258
+ # @return [Object] Returns the model itself
259
+ def self.build_from_hash(attributes)
260
+ return nil unless attributes.is_a?(Hash)
261
+ attributes = attributes.transform_keys(&:to_sym)
262
+ transformed_hash = {}
263
+ openapi_types.each_pair do |key, type|
264
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
265
+ transformed_hash["#{key}"] = nil
266
+ elsif type =~ /\AArray<(.*)>/i
267
+ # check to ensure the input is an array given that the attribute
268
+ # is documented as an array but the input is not
269
+ if attributes[attribute_map[key]].is_a?(Array)
270
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
271
+ end
272
+ elsif !attributes[attribute_map[key]].nil?
273
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
274
+ end
275
+ end
276
+ new(transformed_hash)
277
+ end
278
+
279
+ # Deserializes the data based on type
280
+ # @param string type Data type
281
+ # @param string value Value to be deserialized
282
+ # @return [Object] Deserialized data
283
+ def self._deserialize(type, value)
284
+ case type.to_sym
285
+ when :Time
286
+ Time.parse(value)
287
+ when :Date
288
+ Date.parse(value)
289
+ when :String
290
+ value.to_s
291
+ when :Integer
292
+ value.to_i
293
+ when :Float
294
+ value.to_f
295
+ when :Boolean
296
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
297
+ true
298
+ else
299
+ false
300
+ end
301
+ when :Object
302
+ # generic object (usually a Hash), return directly
303
+ value
304
+ when /\AArray<(?<inner_type>.+)>\z/
305
+ inner_type = Regexp.last_match[:inner_type]
306
+ value.map { |v| _deserialize(inner_type, v) }
307
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
308
+ k_type = Regexp.last_match[:k_type]
309
+ v_type = Regexp.last_match[:v_type]
310
+ {}.tap do |hash|
311
+ value.each do |k, v|
312
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
313
+ end
314
+ end
315
+ else # model
316
+ # models (e.g. Pet) or oneOf
317
+ klass = OpenapiClient.const_get(type)
318
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
319
+ end
320
+ end
321
+
322
+ # Returns the string representation of the object
323
+ # @return [String] String presentation of the object
324
+ def to_s
325
+ to_hash.to_s
326
+ end
327
+
328
+ # to_body is an alias to to_hash (backward compatibility)
329
+ # @return [Hash] Returns the object in the form of hash
330
+ def to_body
331
+ to_hash
332
+ end
333
+
334
+ # Returns the object in the form of hash
335
+ # @return [Hash] Returns the object in the form of hash
336
+ def to_hash
337
+ hash = {}
338
+ self.class.attribute_map.each_pair do |attr, param|
339
+ value = self.send(attr)
340
+ if value.nil?
341
+ is_nullable = self.class.openapi_nullable.include?(attr)
342
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
343
+ end
344
+
345
+ hash[param] = _to_hash(value)
346
+ end
347
+ hash
348
+ end
349
+
350
+ # Outputs non-array value in the form of hash
351
+ # For object, use to_hash. Otherwise, just return the value
352
+ # @param [Object] value Any valid value
353
+ # @return [Hash] Returns the value in the form of hash
354
+ def _to_hash(value)
355
+ if value.is_a?(Array)
356
+ value.compact.map { |v| _to_hash(v) }
357
+ elsif value.is_a?(Hash)
358
+ {}.tap do |hash|
359
+ value.each { |k, v| hash[k] = _to_hash(v) }
360
+ end
361
+ elsif value.respond_to? :to_hash
362
+ value.to_hash
363
+ else
364
+ value
365
+ end
366
+ end
367
+
368
+ end
369
+
370
+ end
@@ -17,10 +17,14 @@ module OpenapiClient
17
17
  class MetricValueUpdateResponse
18
18
  attr_accessor :success
19
19
 
20
+ # true when this request created the metric because no metric used the key yet.
21
+ attr_accessor :created
22
+
20
23
  # Attribute mapping from ruby-style variable name to JSON key.
21
24
  def self.attribute_map
22
25
  {
23
- :'success' => :'success'
26
+ :'success' => :'success',
27
+ :'created' => :'created'
24
28
  }
25
29
  end
26
30
 
@@ -32,7 +36,8 @@ module OpenapiClient
32
36
  # Attribute type mapping.
33
37
  def self.openapi_types
34
38
  {
35
- :'success' => :'Boolean'
39
+ :'success' => :'Boolean',
40
+ :'created' => :'Boolean'
36
41
  }
37
42
  end
38
43
 
@@ -62,6 +67,10 @@ module OpenapiClient
62
67
  else
63
68
  self.success = nil
64
69
  end
70
+
71
+ if attributes.key?(:'created')
72
+ self.created = attributes[:'created']
73
+ end
65
74
  end
66
75
 
67
76
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -89,7 +98,8 @@ module OpenapiClient
89
98
  def ==(o)
90
99
  return true if self.equal?(o)
91
100
  self.class == o.class &&
92
- success == o.success
101
+ success == o.success &&
102
+ created == o.created
93
103
  end
94
104
 
95
105
  # @see the `==` method
@@ -101,7 +111,7 @@ module OpenapiClient
101
111
  # Calculates hash code according to all attributes.
102
112
  # @return [Integer] Hash code
103
113
  def hash
104
- [success].hash
114
+ [success, created].hash
105
115
  end
106
116
 
107
117
  # Builds the object from hash
@@ -17,15 +17,23 @@ module OpenapiClient
17
17
  class NoRecipientsError
18
18
  attr_accessor :error
19
19
 
20
+ # Machine-readable reason. no_paired_devices: the account has no active paired iOS devices; pair an iPhone with the ActivitySmith app. no_recipients_found: devices are paired, but none matched the targeted channels. Treat unknown values as a generic no-delivery error.
21
+ attr_accessor :code
22
+
20
23
  attr_accessor :message
21
24
 
25
+ # ActivitySmith App Store link. Present when code is no_paired_devices.
26
+ attr_accessor :app_store_url
27
+
22
28
  attr_accessor :effective_channel_slugs
23
29
 
24
30
  # Attribute mapping from ruby-style variable name to JSON key.
25
31
  def self.attribute_map
26
32
  {
27
33
  :'error' => :'error',
34
+ :'code' => :'code',
28
35
  :'message' => :'message',
36
+ :'app_store_url' => :'app_store_url',
29
37
  :'effective_channel_slugs' => :'effective_channel_slugs'
30
38
  }
31
39
  end
@@ -39,7 +47,9 @@ module OpenapiClient
39
47
  def self.openapi_types
40
48
  {
41
49
  :'error' => :'String',
50
+ :'code' => :'String',
42
51
  :'message' => :'String',
52
+ :'app_store_url' => :'String',
43
53
  :'effective_channel_slugs' => :'Array<String>'
44
54
  }
45
55
  end
@@ -71,12 +81,20 @@ module OpenapiClient
71
81
  self.error = nil
72
82
  end
73
83
 
84
+ if attributes.key?(:'code')
85
+ self.code = attributes[:'code']
86
+ end
87
+
74
88
  if attributes.key?(:'message')
75
89
  self.message = attributes[:'message']
76
90
  else
77
91
  self.message = nil
78
92
  end
79
93
 
94
+ if attributes.key?(:'app_store_url')
95
+ self.app_store_url = attributes[:'app_store_url']
96
+ end
97
+
80
98
  if attributes.key?(:'effective_channel_slugs')
81
99
  if (value = attributes[:'effective_channel_slugs']).is_a?(Array)
82
100
  self.effective_channel_slugs = value
@@ -115,7 +133,9 @@ module OpenapiClient
115
133
  return true if self.equal?(o)
116
134
  self.class == o.class &&
117
135
  error == o.error &&
136
+ code == o.code &&
118
137
  message == o.message &&
138
+ app_store_url == o.app_store_url &&
119
139
  effective_channel_slugs == o.effective_channel_slugs
120
140
  end
121
141
 
@@ -128,7 +148,7 @@ module OpenapiClient
128
148
  # Calculates hash code according to all attributes.
129
149
  # @return [Integer] Hash code
130
150
  def hash
131
- [error, message, effective_channel_slugs].hash
151
+ [error, code, message, app_store_url, effective_channel_slugs].hash
132
152
  end
133
153
 
134
154
  # Builds the object from hash