activitysmith 1.8.0 → 1.10.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 (25) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +75 -15
  3. data/generated/activitysmith_openapi/api/app_icon_badges_api.rb +90 -0
  4. data/generated/activitysmith_openapi/api/live_activities_api.rb +10 -10
  5. data/generated/activitysmith_openapi/api/push_notifications_api.rb +2 -2
  6. data/generated/activitysmith_openapi/models/app_icon_badge_count_update_request.rb +259 -0
  7. data/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb +331 -0
  8. data/generated/activitysmith_openapi/models/live_activity_action.rb +3 -5
  9. data/generated/activitysmith_openapi/models/live_activity_end_request.rb +1 -1
  10. data/generated/activitysmith_openapi/models/live_activity_start_request.rb +17 -5
  11. data/generated/activitysmith_openapi/models/live_activity_start_response.rb +13 -1
  12. data/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb +1 -1
  13. data/generated/activitysmith_openapi/models/live_activity_stream_put_response.rb +13 -1
  14. data/generated/activitysmith_openapi/models/live_activity_stream_request.rb +17 -5
  15. data/generated/activitysmith_openapi/models/live_activity_update_request.rb +1 -1
  16. data/generated/activitysmith_openapi/models/push_notification_action.rb +3 -5
  17. data/generated/activitysmith_openapi/models/push_notification_request.rb +22 -12
  18. data/generated/activitysmith_openapi/models/push_notification_response.rb +13 -1
  19. data/generated/activitysmith_openapi/version.rb +1 -1
  20. data/generated/activitysmith_openapi.rb +3 -0
  21. data/lib/activitysmith/client.rb +15 -1
  22. data/lib/activitysmith/live_activities.rb +30 -8
  23. data/lib/activitysmith/notifications.rb +19 -4
  24. data/lib/activitysmith/version.rb +1 -1
  25. metadata +5 -2
@@ -24,7 +24,7 @@ module OpenapiClient
24
24
  # Optional HTTPS URL for an image, audio file, or video that users can preview or play when they expand the notification. If `redirection` is omitted, tapping the notification opens this URL. Cannot be combined with `actions`.
25
25
  attr_accessor :media
26
26
 
27
- # Optional HTTPS URL or shortcuts://run-shortcut?name=... URL opened when the user taps the notification body. Use shortcuts://run-shortcut?name=... to run a specific iPhone Shortcut that already exists on the user's device. Overrides the default tap target from `media` when both are provided.
27
+ # Optional HTTP URL, HTTPS URL, or shortcuts://run-shortcut?name=... URL opened when the user taps the notification body. Use shortcuts://run-shortcut?name=... to run a specific iPhone Shortcut that already exists on the user's device. Overrides the default tap target from `media` when both are provided.
28
28
  attr_accessor :redirection
29
29
 
30
30
  # Optional interactive actions shown when users expand the notification. Cannot be combined with `media`.
@@ -38,6 +38,9 @@ module OpenapiClient
38
38
 
39
39
  attr_accessor :target
40
40
 
41
+ # Optional tags to organize and filter notification history.
42
+ attr_accessor :tags
43
+
41
44
  # Attribute mapping from ruby-style variable name to JSON key.
42
45
  def self.attribute_map
43
46
  {
@@ -50,7 +53,8 @@ module OpenapiClient
50
53
  :'payload' => :'payload',
51
54
  :'badge' => :'badge',
52
55
  :'sound' => :'sound',
53
- :'target' => :'target'
56
+ :'target' => :'target',
57
+ :'tags' => :'tags'
54
58
  }
55
59
  end
56
60
 
@@ -68,10 +72,11 @@ module OpenapiClient
68
72
  :'media' => :'String',
69
73
  :'redirection' => :'String',
70
74
  :'actions' => :'Array<PushNotificationAction>',
71
- :'payload' => :'Hash<String, Object>',
75
+ :'payload' => :'Object',
72
76
  :'badge' => :'Integer',
73
77
  :'sound' => :'String',
74
- :'target' => :'ChannelTarget'
78
+ :'target' => :'ChannelTarget',
79
+ :'tags' => :'Array<String>'
75
80
  }
76
81
  end
77
82
 
@@ -125,9 +130,7 @@ module OpenapiClient
125
130
  end
126
131
 
127
132
  if attributes.key?(:'payload')
128
- if (value = attributes[:'payload']).is_a?(Hash)
129
- self.payload = value
130
- end
133
+ self.payload = attributes[:'payload']
131
134
  end
132
135
 
133
136
  if attributes.key?(:'badge')
@@ -141,6 +144,12 @@ module OpenapiClient
141
144
  if attributes.key?(:'target')
142
145
  self.target = attributes[:'target']
143
146
  end
147
+
148
+ if attributes.key?(:'tags')
149
+ if (value = attributes[:'tags']).is_a?(Array)
150
+ self.tags = value
151
+ end
152
+ end
144
153
  end
145
154
 
146
155
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -157,7 +166,7 @@ module OpenapiClient
157
166
  invalid_properties.push("invalid value for \"media\", must conform to the pattern #{pattern}.")
158
167
  end
159
168
 
160
- pattern = Regexp.new(/^(https|shortcuts):\/\//)
169
+ pattern = Regexp.new(/^(http|https|shortcuts):\/\//)
161
170
  if !@redirection.nil? && @redirection !~ pattern
162
171
  invalid_properties.push("invalid value for \"redirection\", must conform to the pattern #{pattern}.")
163
172
  end
@@ -175,7 +184,7 @@ module OpenapiClient
175
184
  warn '[DEPRECATED] the `valid?` method is obsolete'
176
185
  return false if @title.nil?
177
186
  return false if !@media.nil? && @media !~ Regexp.new(/^https:\/\//)
178
- return false if !@redirection.nil? && @redirection !~ Regexp.new(/^(https|shortcuts):\/\//)
187
+ return false if !@redirection.nil? && @redirection !~ Regexp.new(/^(http|https|shortcuts):\/\//)
179
188
  return false if !@actions.nil? && @actions.length > 4
180
189
  true
181
190
  end
@@ -202,7 +211,7 @@ module OpenapiClient
202
211
  fail ArgumentError, 'redirection cannot be nil'
203
212
  end
204
213
 
205
- pattern = Regexp.new(/^(https|shortcuts):\/\//)
214
+ pattern = Regexp.new(/^(http|https|shortcuts):\/\//)
206
215
  if redirection !~ pattern
207
216
  fail ArgumentError, "invalid value for \"redirection\", must conform to the pattern #{pattern}."
208
217
  end
@@ -238,7 +247,8 @@ module OpenapiClient
238
247
  payload == o.payload &&
239
248
  badge == o.badge &&
240
249
  sound == o.sound &&
241
- target == o.target
250
+ target == o.target &&
251
+ tags == o.tags
242
252
  end
243
253
 
244
254
  # @see the `==` method
@@ -250,7 +260,7 @@ module OpenapiClient
250
260
  # Calculates hash code according to all attributes.
251
261
  # @return [Integer] Hash code
252
262
  def hash
253
- [title, message, subtitle, media, redirection, actions, payload, badge, sound, target].hash
263
+ [title, message, subtitle, media, redirection, actions, payload, badge, sound, target, tags].hash
254
264
  end
255
265
 
256
266
  # Builds the object from hash
@@ -23,6 +23,9 @@ module OpenapiClient
23
23
 
24
24
  attr_accessor :effective_channel_slugs
25
25
 
26
+ # Optional tags to organize and filter notification history.
27
+ attr_accessor :tags
28
+
26
29
  attr_accessor :timestamp
27
30
 
28
31
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -32,6 +35,7 @@ module OpenapiClient
32
35
  :'devices_notified' => :'devices_notified',
33
36
  :'users_notified' => :'users_notified',
34
37
  :'effective_channel_slugs' => :'effective_channel_slugs',
38
+ :'tags' => :'tags',
35
39
  :'timestamp' => :'timestamp'
36
40
  }
37
41
  end
@@ -48,6 +52,7 @@ module OpenapiClient
48
52
  :'devices_notified' => :'Integer',
49
53
  :'users_notified' => :'Integer',
50
54
  :'effective_channel_slugs' => :'Array<String>',
55
+ :'tags' => :'Array<String>',
51
56
  :'timestamp' => :'Time'
52
57
  }
53
58
  end
@@ -93,6 +98,12 @@ module OpenapiClient
93
98
  end
94
99
  end
95
100
 
101
+ if attributes.key?(:'tags')
102
+ if (value = attributes[:'tags']).is_a?(Array)
103
+ self.tags = value
104
+ end
105
+ end
106
+
96
107
  if attributes.key?(:'timestamp')
97
108
  self.timestamp = attributes[:'timestamp']
98
109
  else
@@ -134,6 +145,7 @@ module OpenapiClient
134
145
  devices_notified == o.devices_notified &&
135
146
  users_notified == o.users_notified &&
136
147
  effective_channel_slugs == o.effective_channel_slugs &&
148
+ tags == o.tags &&
137
149
  timestamp == o.timestamp
138
150
  end
139
151
 
@@ -146,7 +158,7 @@ module OpenapiClient
146
158
  # Calculates hash code according to all attributes.
147
159
  # @return [Integer] Hash code
148
160
  def hash
149
- [success, devices_notified, users_notified, effective_channel_slugs, timestamp].hash
161
+ [success, devices_notified, users_notified, effective_channel_slugs, tags, timestamp].hash
150
162
  end
151
163
 
152
164
  # Builds the object from hash
@@ -11,5 +11,5 @@ Generator version: 7.7.0
11
11
  =end
12
12
 
13
13
  module OpenapiClient
14
- VERSION = '1.8.0'
14
+ VERSION = '1.10.0'
15
15
  end
@@ -20,6 +20,8 @@ require 'activitysmith_openapi/configuration'
20
20
  require 'activitysmith_openapi/models/activity_metric'
21
21
  require 'activitysmith_openapi/models/activity_metric_value'
22
22
  require 'activitysmith_openapi/models/alert_payload'
23
+ require 'activitysmith_openapi/models/app_icon_badge_count_update_request'
24
+ require 'activitysmith_openapi/models/app_icon_badge_count_update_response'
23
25
  require 'activitysmith_openapi/models/bad_request_error'
24
26
  require 'activitysmith_openapi/models/channel_target'
25
27
  require 'activitysmith_openapi/models/content_state_end'
@@ -59,6 +61,7 @@ require 'activitysmith_openapi/models/send_push_notification429_response'
59
61
  require 'activitysmith_openapi/models/stream_content_state'
60
62
 
61
63
  # APIs
64
+ require 'activitysmith_openapi/api/app_icon_badges_api'
62
65
  require 'activitysmith_openapi/api/live_activities_api'
63
66
  require 'activitysmith_openapi/api/metrics_api'
64
67
  require 'activitysmith_openapi/api/push_notifications_api'
@@ -19,6 +19,14 @@ 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
+ @app_icon_badges = OpenapiClient::AppIconBadgesApi.new(api_client)
23
+ end
24
+
25
+ def badge_count(value, channels: nil)
26
+ request = { badge: value }
27
+ normalized_channels = normalize_channels(channels)
28
+ request[:target] = { channels: normalized_channels } unless normalized_channels.empty?
29
+ @app_icon_badges.update_app_icon_badge_count(request)
22
30
  end
23
31
 
24
32
  private
@@ -44,7 +52,8 @@ module ActivitySmith
44
52
  "OpenapiClient::ApiClient",
45
53
  "OpenapiClient::PushNotificationsApi",
46
54
  "OpenapiClient::LiveActivitiesApi",
47
- "OpenapiClient::MetricsApi"
55
+ "OpenapiClient::MetricsApi",
56
+ "OpenapiClient::AppIconBadgesApi"
48
57
  ].reject { |name| constant_defined?(name) }
49
58
 
50
59
  missing.empty?
@@ -56,5 +65,10 @@ module ActivitySmith
56
65
  rescue NameError
57
66
  false
58
67
  end
68
+
69
+ def normalize_channels(channels)
70
+ values = channels.is_a?(String) ? channels.split(",") : Array(channels)
71
+ values.map { |channel| channel.to_s.strip }.reject(&:empty?)
72
+ end
59
73
  end
60
74
  end
@@ -38,8 +38,13 @@ module ActivitySmith
38
38
  @api = api
39
39
  end
40
40
 
41
- def start(request, opts = {})
42
- @api.start_live_activity(normalize_live_activity_request(normalize_channels_target(request)), opts)
41
+ def start(request = nil, opts = {}, tags: nil, **request_fields)
42
+ @api.start_live_activity(
43
+ normalize_live_activity_request(
44
+ normalize_channels_target(with_tags(combine_request(request, request_fields), tags))
45
+ ),
46
+ opts
47
+ )
43
48
  end
44
49
 
45
50
  def update(request, opts = {})
@@ -50,10 +55,12 @@ module ActivitySmith
50
55
  @api.end_live_activity(normalize_live_activity_request(request), opts)
51
56
  end
52
57
 
53
- def stream(stream_key, request, opts = {})
58
+ def stream(stream_key, request = nil, opts = {}, tags: nil, **request_fields)
54
59
  @api.reconcile_live_activity_stream(
55
60
  stream_key,
56
- normalize_live_activity_request(normalize_channels_target(request)),
61
+ normalize_live_activity_request(
62
+ normalize_channels_target(with_tags(combine_request(request, request_fields), tags))
63
+ ),
57
64
  opts
58
65
  )
59
66
  end
@@ -66,9 +73,9 @@ module ActivitySmith
66
73
  end
67
74
 
68
75
  # Backward-compatible aliases.
69
- def start_live_activity(live_activity_start_request, opts = {})
76
+ def start_live_activity(live_activity_start_request, opts = {}, tags: nil)
70
77
  @api.start_live_activity(
71
- normalize_live_activity_request(normalize_channels_target(live_activity_start_request)),
78
+ normalize_live_activity_request(normalize_channels_target(with_tags(live_activity_start_request, tags))),
72
79
  opts
73
80
  )
74
81
  end
@@ -81,10 +88,10 @@ module ActivitySmith
81
88
  @api.end_live_activity(normalize_live_activity_request(live_activity_end_request), opts)
82
89
  end
83
90
 
84
- def reconcile_live_activity_stream(stream_key, live_activity_stream_request, opts = {})
91
+ def reconcile_live_activity_stream(stream_key, live_activity_stream_request, opts = {}, tags: nil)
85
92
  @api.reconcile_live_activity_stream(
86
93
  stream_key,
87
- normalize_live_activity_request(normalize_channels_target(live_activity_stream_request)),
94
+ normalize_live_activity_request(normalize_channels_target(with_tags(live_activity_stream_request, tags))),
88
95
  opts
89
96
  )
90
97
  end
@@ -110,6 +117,21 @@ module ActivitySmith
110
117
 
111
118
  private
112
119
 
120
+ def combine_request(request, request_fields)
121
+ return request if request_fields.empty?
122
+ return request_fields if request.nil?
123
+ raise ArgumentError, "ActivitySmith: keyword request fields can only be combined with a Hash request" unless request.is_a?(Hash)
124
+
125
+ request.merge(request_fields)
126
+ end
127
+
128
+ def with_tags(request, tags)
129
+ return request if tags.nil?
130
+ raise ArgumentError, "ActivitySmith: tags can only be combined with a Hash request" unless request.is_a?(Hash)
131
+
132
+ request.merge(tags: tags)
133
+ end
134
+
113
135
  def normalize_live_activity_request(request)
114
136
  return request unless request.is_a?(Hash)
115
137
 
@@ -6,15 +6,15 @@ module ActivitySmith
6
6
  @api = api
7
7
  end
8
8
 
9
- def send(request, opts = {})
10
- normalized = normalize_channels_target(request)
9
+ def send(request = nil, opts = {}, tags: nil, **request_fields)
10
+ normalized = normalize_channels_target(with_tags(combine_request(request, request_fields), tags))
11
11
  assert_valid_media_actions!(normalized)
12
12
  @api.send_push_notification(normalized, opts)
13
13
  end
14
14
 
15
15
  # Backward-compatible alias.
16
- def send_push_notification(push_notification_request, opts = {})
17
- normalized = normalize_channels_target(push_notification_request)
16
+ def send_push_notification(push_notification_request, opts = {}, tags: nil)
17
+ normalized = normalize_channels_target(with_tags(push_notification_request, tags))
18
18
  assert_valid_media_actions!(normalized)
19
19
  @api.send_push_notification(normalized, opts)
20
20
  end
@@ -31,6 +31,21 @@ module ActivitySmith
31
31
 
32
32
  private
33
33
 
34
+ def combine_request(request, request_fields)
35
+ return request if request_fields.empty?
36
+ return request_fields if request.nil?
37
+ raise ArgumentError, "ActivitySmith: keyword request fields can only be combined with a Hash request" unless request.is_a?(Hash)
38
+
39
+ request.merge(request_fields)
40
+ end
41
+
42
+ def with_tags(request, tags)
43
+ return request if tags.nil?
44
+ raise ArgumentError, "ActivitySmith: tags can only be combined with a Hash request" unless request.is_a?(Hash)
45
+
46
+ request.merge(tags: tags)
47
+ end
48
+
34
49
  def normalize_channels_target(request)
35
50
  return request unless request.is_a?(Hash)
36
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivitySmith
4
- VERSION = "1.8.0"
4
+ VERSION = "1.10.0"
5
5
  end
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.8.0
4
+ version: 1.10.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-06-16 00:00:00.000000000 Z
11
+ date: 2026-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -76,6 +76,7 @@ files:
76
76
  - LICENSE
77
77
  - README.md
78
78
  - generated/activitysmith_openapi.rb
79
+ - generated/activitysmith_openapi/api/app_icon_badges_api.rb
79
80
  - generated/activitysmith_openapi/api/live_activities_api.rb
80
81
  - generated/activitysmith_openapi/api/metrics_api.rb
81
82
  - generated/activitysmith_openapi/api/push_notifications_api.rb
@@ -85,6 +86,8 @@ files:
85
86
  - generated/activitysmith_openapi/models/activity_metric.rb
86
87
  - generated/activitysmith_openapi/models/activity_metric_value.rb
87
88
  - generated/activitysmith_openapi/models/alert_payload.rb
89
+ - generated/activitysmith_openapi/models/app_icon_badge_count_update_request.rb
90
+ - generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb
88
91
  - generated/activitysmith_openapi/models/bad_request_error.rb
89
92
  - generated/activitysmith_openapi/models/channel_target.rb
90
93
  - generated/activitysmith_openapi/models/content_state_end.rb