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,257 @@
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
+ # Dismissal result. Devices clear the notification after this response, so it does not confirm that any device has cleared it.
18
+ class PushNotificationDismissResponse
19
+ # True when the dismissal is recorded.
20
+ attr_accessor :success
21
+
22
+ # ID of the dismissed Push Notification.
23
+ attr_accessor :notification_id
24
+
25
+ # When the notification was first dismissed. Repeat calls return the same time.
26
+ attr_accessor :dismissed_at
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'success' => :'success',
32
+ :'notification_id' => :'notification_id',
33
+ :'dismissed_at' => :'dismissed_at'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'success' => :'Boolean',
46
+ :'notification_id' => :'String',
47
+ :'dismissed_at' => :'Time'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::PushNotificationDismissResponse` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::PushNotificationDismissResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'success')
73
+ self.success = attributes[:'success']
74
+ else
75
+ self.success = nil
76
+ end
77
+
78
+ if attributes.key?(:'notification_id')
79
+ self.notification_id = attributes[:'notification_id']
80
+ else
81
+ self.notification_id = nil
82
+ end
83
+
84
+ if attributes.key?(:'dismissed_at')
85
+ self.dismissed_at = attributes[:'dismissed_at']
86
+ else
87
+ self.dismissed_at = nil
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
95
+ invalid_properties = Array.new
96
+ if @success.nil?
97
+ invalid_properties.push('invalid value for "success", success cannot be nil.')
98
+ end
99
+
100
+ if @notification_id.nil?
101
+ invalid_properties.push('invalid value for "notification_id", notification_id cannot be nil.')
102
+ end
103
+
104
+ if @dismissed_at.nil?
105
+ invalid_properties.push('invalid value for "dismissed_at", dismissed_at cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ return false if @success.nil?
116
+ return false if @notification_id.nil?
117
+ return false if @dismissed_at.nil?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ success == o.success &&
127
+ notification_id == o.notification_id &&
128
+ dismissed_at == o.dismissed_at
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [success, notification_id, dismissed_at].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = OpenapiClient.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end
@@ -11,5 +11,5 @@ Generator version: 7.7.0
11
11
  =end
12
12
 
13
13
  module OpenapiClient
14
- VERSION = '1.13.0'
14
+ VERSION = '1.14.0'
15
15
  end
@@ -17,6 +17,9 @@ require 'activitysmith_openapi/version'
17
17
  require 'activitysmith_openapi/configuration'
18
18
 
19
19
  # Models
20
+ require 'activitysmith_openapi/models/account_device'
21
+ require 'activitysmith_openapi/models/account_device_list_response'
22
+ require 'activitysmith_openapi/models/account_device_list_response_meta'
20
23
  require 'activitysmith_openapi/models/activity_metric'
21
24
  require 'activitysmith_openapi/models/activity_metric_value'
22
25
  require 'activitysmith_openapi/models/alert_payload'
@@ -50,7 +53,10 @@ require 'activitysmith_openapi/models/live_activity_update_response'
50
53
  require 'activitysmith_openapi/models/live_activity_value'
51
54
  require 'activitysmith_openapi/models/live_activity_webhook_method'
52
55
  require 'activitysmith_openapi/models/metadata_value'
56
+ require 'activitysmith_openapi/models/metric'
53
57
  require 'activitysmith_openapi/models/metric_error'
58
+ require 'activitysmith_openapi/models/metric_response'
59
+ require 'activitysmith_openapi/models/metric_upsert_request'
54
60
  require 'activitysmith_openapi/models/metric_value_update_request'
55
61
  require 'activitysmith_openapi/models/metric_value_update_request_value'
56
62
  require 'activitysmith_openapi/models/metric_value_update_response'
@@ -59,6 +65,7 @@ require 'activitysmith_openapi/models/not_found_error'
59
65
  require 'activitysmith_openapi/models/push_interruption_level'
60
66
  require 'activitysmith_openapi/models/push_notification_action'
61
67
  require 'activitysmith_openapi/models/push_notification_action_type'
68
+ require 'activitysmith_openapi/models/push_notification_dismiss_response'
62
69
  require 'activitysmith_openapi/models/push_notification_replace_request'
63
70
  require 'activitysmith_openapi/models/push_notification_replace_response'
64
71
  require 'activitysmith_openapi/models/push_notification_request'
@@ -71,6 +78,7 @@ require 'activitysmith_openapi/models/update_app_icon_badge_count422_response'
71
78
 
72
79
  # APIs
73
80
  require 'activitysmith_openapi/api/app_icon_badges_api'
81
+ require 'activitysmith_openapi/api/devices_api'
74
82
  require 'activitysmith_openapi/api/live_activities_api'
75
83
  require 'activitysmith_openapi/api/metrics_api'
76
84
  require 'activitysmith_openapi/api/push_notifications_api'
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "repository": "ActivitySmithHQ/activitysmith-backend",
3
- "commit": "dd6757c5defa3d1e6524faef789b6829184fb852",
3
+ "commit": "278d980633d4b1fc735ca96948fdd8ff8fd27642",
4
4
  "path": "openapi.json",
5
- "sha256": "24dae2d064095351d5e5cf800228e64a2d23c40b1e31a9754503081ddf31c5d8"
5
+ "sha256": "0dbbba13bf497eceea4de0759943481a6e085cdf9a9a5445a60cf2b27457de40"
6
6
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ActivitySmith
4
4
  class Client
5
- attr_reader :notifications, :live_activities, :metrics
5
+ attr_reader :notifications, :live_activities, :metrics, :devices
6
6
 
7
7
  def initialize(api_key:)
8
8
  raise ArgumentError, "ActivitySmith: api_key is required" if api_key.to_s.strip.empty?
@@ -19,6 +19,7 @@ module ActivitySmith
19
19
  @notifications = Notifications.new(OpenapiClient::PushNotificationsApi.new(api_client))
20
20
  @live_activities = LiveActivities.new(OpenapiClient::LiveActivitiesApi.new(api_client))
21
21
  @metrics = Metrics.new(OpenapiClient::MetricsApi.new(api_client))
22
+ @devices = Devices.new(OpenapiClient::DevicesApi.new(api_client))
22
23
  @app_icon_badges = OpenapiClient::AppIconBadgesApi.new(api_client)
23
24
  end
24
25
 
@@ -53,6 +54,7 @@ module ActivitySmith
53
54
  "OpenapiClient::PushNotificationsApi",
54
55
  "OpenapiClient::LiveActivitiesApi",
55
56
  "OpenapiClient::MetricsApi",
57
+ "OpenapiClient::DevicesApi",
56
58
  "OpenapiClient::AppIconBadgesApi"
57
59
  ].reject { |name| constant_defined?(name) }
58
60
 
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActivitySmith
4
+ class Devices
5
+ def initialize(api)
6
+ @api = api
7
+ end
8
+
9
+ # Lists the iPhones and iPads paired to the account, active devices first.
10
+ def list(limit: nil, offset: nil, include_inactive: nil, **opts)
11
+ query = { limit: limit, offset: offset, include_inactive: include_inactive }.compact
12
+ @api.list_account_devices(opts.merge(query))
13
+ end
14
+
15
+ # Generated-style alias.
16
+ def list_account_devices(opts = {})
17
+ @api.list_account_devices(opts)
18
+ end
19
+
20
+ def method_missing(name, *args, &block)
21
+ return @api.public_send(name, *args, &block) if @api.respond_to?(name)
22
+
23
+ super
24
+ end
25
+
26
+ def respond_to_missing?(name, include_private = false)
27
+ @api.respond_to?(name, include_private) || super
28
+ end
29
+ end
30
+ end
@@ -10,7 +10,21 @@ module ActivitySmith
10
10
  @api.update_metric_value(key, metric_value_request(value_or_request, timestamp), opts)
11
11
  end
12
12
 
13
- # Backward-compatible generated-style alias.
13
+ # Creates the metric, or updates the fields sent for an existing one.
14
+ # Omitted fields keep their current values, so it is safe to call on every start.
15
+ def create(key, definition = nil, label: nil, format: nil, currency_code: nil, unit: nil, unit_spacing: nil, **opts)
16
+ fields = { label: label, format: format, currency_code: currency_code, unit: unit, unit_spacing: unit_spacing }.compact
17
+ request = fields.empty? ? definition : (definition || {}).to_h.merge(fields)
18
+ request = nil if request.respond_to?(:empty?) && request.empty?
19
+ opts = opts.merge(metric_upsert_request: request) unless request.nil?
20
+ @api.upsert_metric(key, opts)
21
+ end
22
+
23
+ # Backward-compatible generated-style aliases.
24
+ def upsert_metric(key, opts = {})
25
+ @api.upsert_metric(key, opts)
26
+ end
27
+
14
28
  def update_metric_value(key, metric_value_update_request, opts = {})
15
29
  @api.update_metric_value(key, metric_value_update_request, opts)
16
30
  end
@@ -30,6 +30,17 @@ module ActivitySmith
30
30
  replace(notification_id, push_notification_replace_request, opts, tags: tags, **request_fields)
31
31
  end
32
32
 
33
+ # Clears a sent Push Notification from the Lock Screen and Notification Center,
34
+ # using the notification_id returned by send. History keeps it.
35
+ def dismiss(notification_id, opts = {})
36
+ @api.dismiss_push_notification(notification_id, opts)
37
+ end
38
+
39
+ # Generated-style alias.
40
+ def dismiss_push_notification(notification_id, opts = {})
41
+ dismiss(notification_id, opts)
42
+ end
43
+
33
44
  def method_missing(name, *args, &block)
34
45
  return @api.public_send(name, *args, &block) if @api.respond_to?(name)
35
46
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivitySmith
4
- VERSION = "1.14.0"
4
+ VERSION = "1.15.0"
5
5
  end
data/lib/activitysmith.rb CHANGED
@@ -6,4 +6,5 @@ require_relative "activitysmith/push_interruption_level"
6
6
  require_relative "activitysmith/notifications"
7
7
  require_relative "activitysmith/live_activities"
8
8
  require_relative "activitysmith/metrics"
9
+ require_relative "activitysmith/devices"
9
10
  require_relative "activitysmith/client"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activitysmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ActivitySmith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-12 00:00:00.000000000 Z
11
+ date: 2026-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -77,12 +77,16 @@ files:
77
77
  - README.md
78
78
  - generated/activitysmith_openapi.rb
79
79
  - generated/activitysmith_openapi/api/app_icon_badges_api.rb
80
+ - generated/activitysmith_openapi/api/devices_api.rb
80
81
  - generated/activitysmith_openapi/api/live_activities_api.rb
81
82
  - generated/activitysmith_openapi/api/metrics_api.rb
82
83
  - generated/activitysmith_openapi/api/push_notifications_api.rb
83
84
  - generated/activitysmith_openapi/api_client.rb
84
85
  - generated/activitysmith_openapi/api_error.rb
85
86
  - generated/activitysmith_openapi/configuration.rb
87
+ - generated/activitysmith_openapi/models/account_device.rb
88
+ - generated/activitysmith_openapi/models/account_device_list_response.rb
89
+ - generated/activitysmith_openapi/models/account_device_list_response_meta.rb
86
90
  - generated/activitysmith_openapi/models/activity_metric.rb
87
91
  - generated/activitysmith_openapi/models/activity_metric_value.rb
88
92
  - generated/activitysmith_openapi/models/alert_payload.rb
@@ -116,7 +120,10 @@ files:
116
120
  - generated/activitysmith_openapi/models/live_activity_value.rb
117
121
  - generated/activitysmith_openapi/models/live_activity_webhook_method.rb
118
122
  - generated/activitysmith_openapi/models/metadata_value.rb
123
+ - generated/activitysmith_openapi/models/metric.rb
119
124
  - generated/activitysmith_openapi/models/metric_error.rb
125
+ - generated/activitysmith_openapi/models/metric_response.rb
126
+ - generated/activitysmith_openapi/models/metric_upsert_request.rb
120
127
  - generated/activitysmith_openapi/models/metric_value_update_request.rb
121
128
  - generated/activitysmith_openapi/models/metric_value_update_request_value.rb
122
129
  - generated/activitysmith_openapi/models/metric_value_update_response.rb
@@ -125,6 +132,7 @@ files:
125
132
  - generated/activitysmith_openapi/models/push_interruption_level.rb
126
133
  - generated/activitysmith_openapi/models/push_notification_action.rb
127
134
  - generated/activitysmith_openapi/models/push_notification_action_type.rb
135
+ - generated/activitysmith_openapi/models/push_notification_dismiss_response.rb
128
136
  - generated/activitysmith_openapi/models/push_notification_replace_request.rb
129
137
  - generated/activitysmith_openapi/models/push_notification_replace_response.rb
130
138
  - generated/activitysmith_openapi/models/push_notification_request.rb
@@ -138,6 +146,7 @@ files:
138
146
  - generated/openapi-source.json
139
147
  - lib/activitysmith.rb
140
148
  - lib/activitysmith/client.rb
149
+ - lib/activitysmith/devices.rb
141
150
  - lib/activitysmith/live_activities.rb
142
151
  - lib/activitysmith/metrics.rb
143
152
  - lib/activitysmith/notifications.rb