activitysmith 1.8.0 → 1.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 997a69d88cda72ef415a4774c5af354d531b9d3b9b1cae31dad5393899042a90
4
- data.tar.gz: 41399899c3a8c9ff1854c39e69370d1fe21047beac360871f41ed5529cd80bfa
3
+ metadata.gz: 3c618daeffaa021171b3dc5c77d820ea1c4abb8eec2545dcf7238a00fefa98e5
4
+ data.tar.gz: 499260d8e84bb8c20dddfdbd0e26a19b3fbfdee738f1d9d802ea3505cb8aa17c
5
5
  SHA512:
6
- metadata.gz: 24f59510621de8d861c99e908091784a6b8a8f025324bf26d17e031e9e79145438320399239cf3e5cb0b8c8b6895e3f42b2950deecc3930044d6fd6d3517514a
7
- data.tar.gz: dfa17c2e1038bf9248dd25ab6f7472319301dd784f4e52c0fe866f6342428947b860492fa2146b9548c9b3045ab22e508cb9c3a1a0f51d0f3ff816e07eba22c6
6
+ metadata.gz: 8d19ad31e4d0377df4885ba054933aa87a78368056735e4877e637ec9035aecb9b7436f83342a5e8db8415b0ccb0a0f532effb5269587a7dde72dc2e2a5b0b6d
7
+ data.tar.gz: 91d7f07629f5ce83cffc2273bbb803b5710331d347d674005d1de3cfdd1fbe22291a9407b5c7b4f27593ea7e73437ab1e363f891aa8933b82b15f70f03becafc
data/README.md CHANGED
@@ -20,8 +20,9 @@ See [API reference](https://activitysmith.com/docs/api-reference/introduction).
20
20
  - [Live Activity Action](#live-activity-action)
21
21
  - [Icons and Badges](#icons-and-badges)
22
22
  - [Live Activity Colors](#live-activity-colors)
23
- - [Channels](#channels)
24
23
  - [Widgets](#widgets)
24
+ - [App Icon Badge Count](#app-icon-badge-count)
25
+ - [Channels](#channels)
25
26
 
26
27
  ## Installation
27
28
 
@@ -535,20 +536,6 @@ Choose from these colors for the Live Activity accent, including progress bars a
535
536
 
536
537
  `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
537
538
 
538
- ## Channels
539
-
540
- Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
541
-
542
- ```ruby
543
- activitysmith.notifications.send(
544
- {
545
- title: "New subscription 💸",
546
- message: "Customer upgraded to Pro plan",
547
- channels: ["sales", "customer-success"] # Optional
548
- }
549
- )
550
- ```
551
-
552
539
  ## Widgets
553
540
 
554
541
  <p align="center">
@@ -571,6 +558,64 @@ String metric values work too.
571
558
  activitysmith.metrics.update("prod.status", "healthy")
572
559
  ```
573
560
 
561
+ ## App Icon Badge Count
562
+
563
+ <p align="center">
564
+ <img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
565
+ </p>
566
+
567
+ Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view.
568
+
569
+ Set or update the badge value.
570
+
571
+ ```ruby
572
+ activitysmith.badge_count(8333)
573
+ ```
574
+
575
+ To clear the badge, set its value to 0.
576
+
577
+ ```ruby
578
+ activitysmith.badge_count(0)
579
+ ```
580
+
581
+ ## Channels
582
+
583
+ Use `channels` to target specific team members or devices
584
+
585
+ ### Push Notifications
586
+
587
+ ```ruby
588
+ activitysmith.notifications.send(
589
+ {
590
+ title: "New subscription 💸",
591
+ message: "Customer upgraded to Pro plan",
592
+ channels: ["sales", "customer-success"]
593
+ }
594
+ )
595
+ ```
596
+
597
+ ### Live Activities
598
+
599
+ ```ruby
600
+ activitysmith.live_activities.start(
601
+ {
602
+ content_state: {
603
+ title: "Nightly Database Backup",
604
+ subtitle: "verify restore",
605
+ type: "progress",
606
+ percentage: 62
607
+ },
608
+ channels: ["sales", "customer-success"]
609
+ }
610
+ )
611
+ ```
612
+
613
+ ### App Icon Badge Count
614
+
615
+ ```ruby
616
+ activitysmith.badge_count(3, channels: ["sales", "customer-success"])
617
+ ```
618
+
574
619
  ## Error Handling
575
620
 
576
621
  ```ruby
@@ -0,0 +1,90 @@
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 'cgi'
14
+
15
+ module OpenapiClient
16
+ class AppIconBadgesApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Update App Icon Badge Count
23
+ # Updates the App Icon Badge Count on devices matched by API key scope and optional target channels. Send `badge: 0` to clear the count. Badge updates are independent of push notifications and do not create a push notification history item.
24
+ # @param app_icon_badge_count_update_request [AppIconBadgeCountUpdateRequest]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [AppIconBadgeCountUpdateResponse]
27
+ def update_app_icon_badge_count(app_icon_badge_count_update_request, opts = {})
28
+ data, _status_code, _headers = update_app_icon_badge_count_with_http_info(app_icon_badge_count_update_request, opts)
29
+ data
30
+ end
31
+
32
+ # Update App Icon Badge Count
33
+ # Updates the App Icon Badge Count on devices matched by API key scope and optional target channels. Send &#x60;badge: 0&#x60; to clear the count. Badge updates are independent of push notifications and do not create a push notification history item.
34
+ # @param app_icon_badge_count_update_request [AppIconBadgeCountUpdateRequest]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(AppIconBadgeCountUpdateResponse, Integer, Hash)>] AppIconBadgeCountUpdateResponse data, response status code and response headers
37
+ def update_app_icon_badge_count_with_http_info(app_icon_badge_count_update_request, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: AppIconBadgesApi.update_app_icon_badge_count ...'
40
+ end
41
+ # verify the required parameter 'app_icon_badge_count_update_request' is set
42
+ if @api_client.config.client_side_validation && app_icon_badge_count_update_request.nil?
43
+ fail ArgumentError, "Missing the required parameter 'app_icon_badge_count_update_request' when calling AppIconBadgesApi.update_app_icon_badge_count"
44
+ end
45
+ # resource path
46
+ local_var_path = '/badge'
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+ # HTTP header 'Content-Type'
56
+ content_type = @api_client.select_header_content_type(['application/json'])
57
+ if !content_type.nil?
58
+ header_params['Content-Type'] = content_type
59
+ end
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(app_icon_badge_count_update_request)
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'AppIconBadgeCountUpdateResponse'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || ['apiKeyAuth']
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"AppIconBadgesApi.update_app_icon_badge_count",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: AppIconBadgesApi#update_app_icon_badge_count\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,260 @@
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
+ # App Icon Badge Count update. Send badge 0 to clear the count.
18
+ class AppIconBadgeCountUpdateRequest
19
+ # The count to show on the ActivitySmith app icon. Send 0 to clear it.
20
+ attr_accessor :badge
21
+
22
+ attr_accessor :target
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'badge' => :'badge',
28
+ :'target' => :'target'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'badge' => :'Integer',
41
+ :'target' => :'ChannelTarget'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::AppIconBadgeCountUpdateRequest` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::AppIconBadgeCountUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'badge')
67
+ self.badge = attributes[:'badge']
68
+ else
69
+ self.badge = nil
70
+ end
71
+
72
+ if attributes.key?(:'target')
73
+ self.target = attributes[:'target']
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
81
+ invalid_properties = Array.new
82
+ if @badge.nil?
83
+ invalid_properties.push('invalid value for "badge", badge cannot be nil.')
84
+ end
85
+
86
+ if @badge > 2147483647
87
+ invalid_properties.push('invalid value for "badge", must be smaller than or equal to 2147483647.')
88
+ end
89
+
90
+ if @badge < 0
91
+ invalid_properties.push('invalid value for "badge", must be greater than or equal to 0.')
92
+ end
93
+
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ warn '[DEPRECATED] the `valid?` method is obsolete'
101
+ return false if @badge.nil?
102
+ return false if @badge > 2147483647
103
+ return false if @badge < 0
104
+ true
105
+ end
106
+
107
+ # Custom attribute writer method with validation
108
+ # @param [Object] badge Value to be assigned
109
+ def badge=(badge)
110
+ if badge.nil?
111
+ fail ArgumentError, 'badge cannot be nil'
112
+ end
113
+
114
+ if badge > 2147483647
115
+ fail ArgumentError, 'invalid value for "badge", must be smaller than or equal to 2147483647.'
116
+ end
117
+
118
+ if badge < 0
119
+ fail ArgumentError, 'invalid value for "badge", must be greater than or equal to 0.'
120
+ end
121
+
122
+ @badge = badge
123
+ end
124
+
125
+ # Checks equality by comparing each attribute.
126
+ # @param [Object] Object to be compared
127
+ def ==(o)
128
+ return true if self.equal?(o)
129
+ self.class == o.class &&
130
+ badge == o.badge &&
131
+ target == o.target
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(o)
137
+ self == o
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Integer] Hash code
142
+ def hash
143
+ [badge, target].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def self.build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ attributes = attributes.transform_keys(&:to_sym)
152
+ transformed_hash = {}
153
+ openapi_types.each_pair do |key, type|
154
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
155
+ transformed_hash["#{key}"] = nil
156
+ elsif type =~ /\AArray<(.*)>/i
157
+ # check to ensure the input is an array given that the attribute
158
+ # is documented as an array but the input is not
159
+ if attributes[attribute_map[key]].is_a?(Array)
160
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
161
+ end
162
+ elsif !attributes[attribute_map[key]].nil?
163
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
164
+ end
165
+ end
166
+ new(transformed_hash)
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def self._deserialize(type, value)
174
+ case type.to_sym
175
+ when :Time
176
+ Time.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :Boolean
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+ when :Object
192
+ # generic object (usually a Hash), return directly
193
+ value
194
+ when /\AArray<(?<inner_type>.+)>\z/
195
+ inner_type = Regexp.last_match[:inner_type]
196
+ value.map { |v| _deserialize(inner_type, v) }
197
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
198
+ k_type = Regexp.last_match[:k_type]
199
+ v_type = Regexp.last_match[:v_type]
200
+ {}.tap do |hash|
201
+ value.each do |k, v|
202
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
203
+ end
204
+ end
205
+ else # model
206
+ # models (e.g. Pet) or oneOf
207
+ klass = OpenapiClient.const_get(type)
208
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
209
+ end
210
+ end
211
+
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
214
+ def to_s
215
+ to_hash.to_s
216
+ end
217
+
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_body
221
+ to_hash
222
+ end
223
+
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_hash
227
+ hash = {}
228
+ self.class.attribute_map.each_pair do |attr, param|
229
+ value = self.send(attr)
230
+ if value.nil?
231
+ is_nullable = self.class.openapi_nullable.include?(attr)
232
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
233
+ end
234
+
235
+ hash[param] = _to_hash(value)
236
+ end
237
+ hash
238
+ end
239
+
240
+ # Outputs non-array value in the form of hash
241
+ # For object, use to_hash. Otherwise, just return the value
242
+ # @param [Object] value Any valid value
243
+ # @return [Hash] Returns the value in the form of hash
244
+ def _to_hash(value)
245
+ if value.is_a?(Array)
246
+ value.compact.map { |v| _to_hash(v) }
247
+ elsif value.is_a?(Hash)
248
+ {}.tap do |hash|
249
+ value.each { |k, v| hash[k] = _to_hash(v) }
250
+ end
251
+ elsif value.respond_to? :to_hash
252
+ value.to_hash
253
+ else
254
+ value
255
+ end
256
+ end
257
+
258
+ end
259
+
260
+ end
@@ -0,0 +1,331 @@
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 AppIconBadgeCountUpdateResponse
18
+ attr_accessor :success
19
+
20
+ attr_accessor :badge
21
+
22
+ attr_accessor :devices_notified
23
+
24
+ attr_accessor :users_notified
25
+
26
+ attr_accessor :effective_channel_slugs
27
+
28
+ attr_accessor :timestamp
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'success' => :'success',
34
+ :'badge' => :'badge',
35
+ :'devices_notified' => :'devices_notified',
36
+ :'users_notified' => :'users_notified',
37
+ :'effective_channel_slugs' => :'effective_channel_slugs',
38
+ :'timestamp' => :'timestamp'
39
+ }
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'success' => :'Boolean',
51
+ :'badge' => :'Integer',
52
+ :'devices_notified' => :'Integer',
53
+ :'users_notified' => :'Integer',
54
+ :'effective_channel_slugs' => :'Array<String>',
55
+ :'timestamp' => :'Time'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ ])
63
+ end
64
+
65
+ # Initializes the object
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ def initialize(attributes = {})
68
+ if (!attributes.is_a?(Hash))
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::AppIconBadgeCountUpdateResponse` initialize method"
70
+ end
71
+
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::AppIconBadgeCountUpdateResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'success')
81
+ self.success = attributes[:'success']
82
+ else
83
+ self.success = nil
84
+ end
85
+
86
+ if attributes.key?(:'badge')
87
+ self.badge = attributes[:'badge']
88
+ else
89
+ self.badge = nil
90
+ end
91
+
92
+ if attributes.key?(:'devices_notified')
93
+ self.devices_notified = attributes[:'devices_notified']
94
+ else
95
+ self.devices_notified = nil
96
+ end
97
+
98
+ if attributes.key?(:'users_notified')
99
+ self.users_notified = attributes[:'users_notified']
100
+ else
101
+ self.users_notified = nil
102
+ end
103
+
104
+ if attributes.key?(:'effective_channel_slugs')
105
+ if (value = attributes[:'effective_channel_slugs']).is_a?(Array)
106
+ self.effective_channel_slugs = value
107
+ end
108
+ else
109
+ self.effective_channel_slugs = nil
110
+ end
111
+
112
+ if attributes.key?(:'timestamp')
113
+ self.timestamp = attributes[:'timestamp']
114
+ else
115
+ self.timestamp = nil
116
+ end
117
+ end
118
+
119
+ # Show invalid properties with the reasons. Usually used together with valid?
120
+ # @return Array for valid properties with the reasons
121
+ def list_invalid_properties
122
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
123
+ invalid_properties = Array.new
124
+ if @success.nil?
125
+ invalid_properties.push('invalid value for "success", success cannot be nil.')
126
+ end
127
+
128
+ if @badge.nil?
129
+ invalid_properties.push('invalid value for "badge", badge cannot be nil.')
130
+ end
131
+
132
+ if @badge > 2147483647
133
+ invalid_properties.push('invalid value for "badge", must be smaller than or equal to 2147483647.')
134
+ end
135
+
136
+ if @badge < 0
137
+ invalid_properties.push('invalid value for "badge", must be greater than or equal to 0.')
138
+ end
139
+
140
+ if @devices_notified.nil?
141
+ invalid_properties.push('invalid value for "devices_notified", devices_notified cannot be nil.')
142
+ end
143
+
144
+ if @users_notified.nil?
145
+ invalid_properties.push('invalid value for "users_notified", users_notified cannot be nil.')
146
+ end
147
+
148
+ if @effective_channel_slugs.nil?
149
+ invalid_properties.push('invalid value for "effective_channel_slugs", effective_channel_slugs cannot be nil.')
150
+ end
151
+
152
+ if @timestamp.nil?
153
+ invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
154
+ end
155
+
156
+ invalid_properties
157
+ end
158
+
159
+ # Check to see if the all the properties in the model are valid
160
+ # @return true if the model is valid
161
+ def valid?
162
+ warn '[DEPRECATED] the `valid?` method is obsolete'
163
+ return false if @success.nil?
164
+ return false if @badge.nil?
165
+ return false if @badge > 2147483647
166
+ return false if @badge < 0
167
+ return false if @devices_notified.nil?
168
+ return false if @users_notified.nil?
169
+ return false if @effective_channel_slugs.nil?
170
+ return false if @timestamp.nil?
171
+ true
172
+ end
173
+
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] badge Value to be assigned
176
+ def badge=(badge)
177
+ if badge.nil?
178
+ fail ArgumentError, 'badge cannot be nil'
179
+ end
180
+
181
+ if badge > 2147483647
182
+ fail ArgumentError, 'invalid value for "badge", must be smaller than or equal to 2147483647.'
183
+ end
184
+
185
+ if badge < 0
186
+ fail ArgumentError, 'invalid value for "badge", must be greater than or equal to 0.'
187
+ end
188
+
189
+ @badge = badge
190
+ end
191
+
192
+ # Checks equality by comparing each attribute.
193
+ # @param [Object] Object to be compared
194
+ def ==(o)
195
+ return true if self.equal?(o)
196
+ self.class == o.class &&
197
+ success == o.success &&
198
+ badge == o.badge &&
199
+ devices_notified == o.devices_notified &&
200
+ users_notified == o.users_notified &&
201
+ effective_channel_slugs == o.effective_channel_slugs &&
202
+ timestamp == o.timestamp
203
+ end
204
+
205
+ # @see the `==` method
206
+ # @param [Object] Object to be compared
207
+ def eql?(o)
208
+ self == o
209
+ end
210
+
211
+ # Calculates hash code according to all attributes.
212
+ # @return [Integer] Hash code
213
+ def hash
214
+ [success, badge, devices_notified, users_notified, effective_channel_slugs, timestamp].hash
215
+ end
216
+
217
+ # Builds the object from hash
218
+ # @param [Hash] attributes Model attributes in the form of hash
219
+ # @return [Object] Returns the model itself
220
+ def self.build_from_hash(attributes)
221
+ return nil unless attributes.is_a?(Hash)
222
+ attributes = attributes.transform_keys(&:to_sym)
223
+ transformed_hash = {}
224
+ openapi_types.each_pair do |key, type|
225
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
226
+ transformed_hash["#{key}"] = nil
227
+ elsif type =~ /\AArray<(.*)>/i
228
+ # check to ensure the input is an array given that the attribute
229
+ # is documented as an array but the input is not
230
+ if attributes[attribute_map[key]].is_a?(Array)
231
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
232
+ end
233
+ elsif !attributes[attribute_map[key]].nil?
234
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
235
+ end
236
+ end
237
+ new(transformed_hash)
238
+ end
239
+
240
+ # Deserializes the data based on type
241
+ # @param string type Data type
242
+ # @param string value Value to be deserialized
243
+ # @return [Object] Deserialized data
244
+ def self._deserialize(type, value)
245
+ case type.to_sym
246
+ when :Time
247
+ Time.parse(value)
248
+ when :Date
249
+ Date.parse(value)
250
+ when :String
251
+ value.to_s
252
+ when :Integer
253
+ value.to_i
254
+ when :Float
255
+ value.to_f
256
+ when :Boolean
257
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
258
+ true
259
+ else
260
+ false
261
+ end
262
+ when :Object
263
+ # generic object (usually a Hash), return directly
264
+ value
265
+ when /\AArray<(?<inner_type>.+)>\z/
266
+ inner_type = Regexp.last_match[:inner_type]
267
+ value.map { |v| _deserialize(inner_type, v) }
268
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
269
+ k_type = Regexp.last_match[:k_type]
270
+ v_type = Regexp.last_match[:v_type]
271
+ {}.tap do |hash|
272
+ value.each do |k, v|
273
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
274
+ end
275
+ end
276
+ else # model
277
+ # models (e.g. Pet) or oneOf
278
+ klass = OpenapiClient.const_get(type)
279
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
280
+ end
281
+ end
282
+
283
+ # Returns the string representation of the object
284
+ # @return [String] String presentation of the object
285
+ def to_s
286
+ to_hash.to_s
287
+ end
288
+
289
+ # to_body is an alias to to_hash (backward compatibility)
290
+ # @return [Hash] Returns the object in the form of hash
291
+ def to_body
292
+ to_hash
293
+ end
294
+
295
+ # Returns the object in the form of hash
296
+ # @return [Hash] Returns the object in the form of hash
297
+ def to_hash
298
+ hash = {}
299
+ self.class.attribute_map.each_pair do |attr, param|
300
+ value = self.send(attr)
301
+ if value.nil?
302
+ is_nullable = self.class.openapi_nullable.include?(attr)
303
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
304
+ end
305
+
306
+ hash[param] = _to_hash(value)
307
+ end
308
+ hash
309
+ end
310
+
311
+ # Outputs non-array value in the form of hash
312
+ # For object, use to_hash. Otherwise, just return the value
313
+ # @param [Object] value Any valid value
314
+ # @return [Hash] Returns the value in the form of hash
315
+ def _to_hash(value)
316
+ if value.is_a?(Array)
317
+ value.compact.map { |v| _to_hash(v) }
318
+ elsif value.is_a?(Hash)
319
+ {}.tap do |hash|
320
+ value.each { |k, v| hash[k] = _to_hash(v) }
321
+ end
322
+ elsif value.respond_to? :to_hash
323
+ value.to_hash
324
+ else
325
+ value
326
+ end
327
+ end
328
+
329
+ end
330
+
331
+ end
@@ -53,7 +53,7 @@ module OpenapiClient
53
53
  :'type' => :'LiveActivityActionType',
54
54
  :'url' => :'String',
55
55
  :'method' => :'LiveActivityWebhookMethod',
56
- :'body' => :'Hash<String, Object>'
56
+ :'body' => :'Object'
57
57
  }
58
58
  end
59
59
 
@@ -103,9 +103,7 @@ module OpenapiClient
103
103
  end
104
104
 
105
105
  if attributes.key?(:'body')
106
- if (value = attributes[:'body']).is_a?(Hash)
107
- self.body = value
108
- end
106
+ self.body = attributes[:'body']
109
107
  end
110
108
  end
111
109
 
@@ -52,7 +52,7 @@ module OpenapiClient
52
52
  :'type' => :'PushNotificationActionType',
53
53
  :'url' => :'String',
54
54
  :'method' => :'PushNotificationWebhookMethod',
55
- :'body' => :'Hash<String, Object>'
55
+ :'body' => :'Object'
56
56
  }
57
57
  end
58
58
 
@@ -102,9 +102,7 @@ module OpenapiClient
102
102
  end
103
103
 
104
104
  if attributes.key?(:'body')
105
- if (value = attributes[:'body']).is_a?(Hash)
106
- self.body = value
107
- end
105
+ self.body = attributes[:'body']
108
106
  end
109
107
  end
110
108
 
@@ -68,7 +68,7 @@ module OpenapiClient
68
68
  :'media' => :'String',
69
69
  :'redirection' => :'String',
70
70
  :'actions' => :'Array<PushNotificationAction>',
71
- :'payload' => :'Hash<String, Object>',
71
+ :'payload' => :'Object',
72
72
  :'badge' => :'Integer',
73
73
  :'sound' => :'String',
74
74
  :'target' => :'ChannelTarget'
@@ -125,9 +125,7 @@ module OpenapiClient
125
125
  end
126
126
 
127
127
  if attributes.key?(:'payload')
128
- if (value = attributes[:'payload']).is_a?(Hash)
129
- self.payload = value
130
- end
128
+ self.payload = attributes[:'payload']
131
129
  end
132
130
 
133
131
  if attributes.key?(:'badge')
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivitySmith
4
- VERSION = "1.8.0"
4
+ VERSION = "1.9.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.9.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-11 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