activitysmith 0.1.6 → 1.0.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 +4 -4
- data/README.md +122 -38
- data/generated/activitysmith_openapi/api/push_notifications_api.rb +2 -2
- data/generated/activitysmith_openapi/models/live_activity_action.rb +323 -0
- data/generated/activitysmith_openapi/models/live_activity_action_type.rb +40 -0
- data/generated/activitysmith_openapi/models/live_activity_end_request.rb +13 -4
- data/generated/activitysmith_openapi/models/live_activity_start_request.rb +10 -1
- data/generated/activitysmith_openapi/models/live_activity_update_request.rb +13 -4
- data/generated/activitysmith_openapi/models/live_activity_webhook_method.rb +40 -0
- data/generated/activitysmith_openapi/models/push_notification_request.rb +34 -3
- data/generated/activitysmith_openapi/version.rb +1 -1
- data/generated/activitysmith_openapi.rb +3 -0
- data/lib/activitysmith/client.rb +1 -0
- data/lib/activitysmith/notifications.rb +30 -2
- data/lib/activitysmith/version.rb +1 -1
- data/lib/activitysmith/versioned_user_agent.rb +9 -0
- data/lib/activitysmith.rb +1 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2f19ff232a66a24046463a9e5c902981f4f6372c5f5b159c5c4dbd34599bfc3
|
|
4
|
+
data.tar.gz: 770153b7ebc383f129c2c19247e452bce49786171d1e32a02b919e49648cee43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec35e8a04066ec01d2b17aafd100f9ee82107a1645149999c2095f8565e8e92a16fbcb05fae09330aa199912093c8ff982278660a538c074a4c15c61f3803b55
|
|
7
|
+
data.tar.gz: acdfddcc23f59dba508b71e4711a59d6084b37c74eb0303e386502ab50518b25f460671128a2ac0842c723ba095759ee21a2043392ad75689e999f376a5aaa40
|
data/README.md
CHANGED
|
@@ -20,7 +20,7 @@ require "activitysmith"
|
|
|
20
20
|
activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY"))
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Push Notifications
|
|
24
24
|
|
|
25
25
|
### Send a Push Notification
|
|
26
26
|
|
|
@@ -29,15 +29,78 @@ activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_
|
|
|
29
29
|
</p>
|
|
30
30
|
|
|
31
31
|
```ruby
|
|
32
|
-
|
|
32
|
+
activitysmith.notifications.send(
|
|
33
33
|
{
|
|
34
34
|
title: "New subscription 💸",
|
|
35
35
|
message: "Customer upgraded to Pro plan"
|
|
36
36
|
}
|
|
37
37
|
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Rich Push Notifications with Media
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
<p align="center">
|
|
43
|
+
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
activitysmith.notifications.send(
|
|
48
|
+
{
|
|
49
|
+
title: "Homepage ready",
|
|
50
|
+
message: "Your agent finished the redesign.",
|
|
51
|
+
media: "https://cdn.example.com/output/homepage-v2.png",
|
|
52
|
+
redirection: "https://github.com/acme/web/pull/482"
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Send images, videos, or audio with your push notifications, press and hold to preview media directly from the notification, then tap through to open the linked content.
|
|
58
|
+
|
|
59
|
+
<p align="center">
|
|
60
|
+
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
|
|
61
|
+
</p>
|
|
62
|
+
|
|
63
|
+
What will work:
|
|
64
|
+
|
|
65
|
+
- direct image URL: `.jpg`, `.png`, `.gif`, etc.
|
|
66
|
+
- direct audio file URL: `.mp3`, `.m4a`, etc.
|
|
67
|
+
- direct video file URL: `.mp4`, `.mov`, etc.
|
|
68
|
+
- URL that responds with a proper media `Content-Type`, even if the path has no extension
|
|
69
|
+
|
|
70
|
+
### Actionable Push Notifications
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
Actionable push notifications can open a URL on tap or trigger actions when someone long-presses the notification.
|
|
77
|
+
Webhooks are executed by the ActivitySmith backend.
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
activitysmith.notifications.send(
|
|
81
|
+
{
|
|
82
|
+
title: "New subscription 💸",
|
|
83
|
+
message: "Customer upgraded to Pro plan",
|
|
84
|
+
redirection: "https://crm.example.com/customers/cus_9f3a1d", # Optional
|
|
85
|
+
actions: [ # Optional (max 4)
|
|
86
|
+
{
|
|
87
|
+
title: "Open CRM Profile",
|
|
88
|
+
type: "open_url",
|
|
89
|
+
url: "https://crm.example.com/customers/cus_9f3a1d"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
title: "Start Onboarding Workflow",
|
|
93
|
+
type: "webhook",
|
|
94
|
+
url: "https://hooks.example.com/activitysmith/onboarding/start",
|
|
95
|
+
method: "POST",
|
|
96
|
+
body: {
|
|
97
|
+
customer_id: "cus_9f3a1d",
|
|
98
|
+
plan: "pro"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
)
|
|
41
104
|
```
|
|
42
105
|
|
|
43
106
|
## Live Activities
|
|
@@ -95,7 +158,7 @@ activity_id = start.activity_id
|
|
|
95
158
|
</p>
|
|
96
159
|
|
|
97
160
|
```ruby
|
|
98
|
-
|
|
161
|
+
activitysmith.live_activities.update(
|
|
99
162
|
{
|
|
100
163
|
activity_id: activity_id,
|
|
101
164
|
content_state: {
|
|
@@ -106,8 +169,6 @@ update = activitysmith.live_activities.update(
|
|
|
106
169
|
}
|
|
107
170
|
}
|
|
108
171
|
)
|
|
109
|
-
|
|
110
|
-
puts update.devices_notified
|
|
111
172
|
```
|
|
112
173
|
|
|
113
174
|
#### End
|
|
@@ -117,7 +178,7 @@ puts update.devices_notified
|
|
|
117
178
|
</p>
|
|
118
179
|
|
|
119
180
|
```ruby
|
|
120
|
-
|
|
181
|
+
activitysmith.live_activities.end(
|
|
121
182
|
{
|
|
122
183
|
activity_id: activity_id,
|
|
123
184
|
content_state: {
|
|
@@ -129,8 +190,6 @@ finish = activitysmith.live_activities.end(
|
|
|
129
190
|
}
|
|
130
191
|
}
|
|
131
192
|
)
|
|
132
|
-
|
|
133
|
-
puts finish.success
|
|
134
193
|
```
|
|
135
194
|
|
|
136
195
|
### Progress Type
|
|
@@ -200,48 +259,73 @@ activitysmith.live_activities.end(
|
|
|
200
259
|
)
|
|
201
260
|
```
|
|
202
261
|
|
|
203
|
-
|
|
262
|
+
### Live Activity Action
|
|
204
263
|
|
|
205
|
-
|
|
264
|
+
Just like Actionable Push Notifications, Live Activities can have a button that opens provided URL in a browser or triggers a webhook. Webhooks are executed by the ActivitySmith backend.
|
|
265
|
+
|
|
266
|
+
<p align="center">
|
|
267
|
+
<img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action" width="680" />
|
|
268
|
+
</p>
|
|
269
|
+
|
|
270
|
+
#### Open URL action
|
|
206
271
|
|
|
207
272
|
```ruby
|
|
208
|
-
|
|
273
|
+
start = activitysmith.live_activities.start(
|
|
209
274
|
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
275
|
+
content_state: {
|
|
276
|
+
title: "Deploying payments-api",
|
|
277
|
+
subtitle: "Running database migrations",
|
|
278
|
+
number_of_steps: 5,
|
|
279
|
+
current_step: 3,
|
|
280
|
+
type: "segmented_progress"
|
|
281
|
+
},
|
|
282
|
+
action: {
|
|
283
|
+
title: "Open Workflow",
|
|
284
|
+
type: "open_url",
|
|
285
|
+
url: "https://github.com/acme/payments-api/actions/runs/1234567890"
|
|
286
|
+
}
|
|
213
287
|
}
|
|
214
288
|
)
|
|
289
|
+
|
|
290
|
+
activity_id = start.activity_id
|
|
215
291
|
```
|
|
216
292
|
|
|
217
|
-
|
|
293
|
+
#### Webhook action
|
|
218
294
|
|
|
219
|
-
|
|
220
|
-
|
|
295
|
+
```ruby
|
|
296
|
+
activitysmith.live_activities.update(
|
|
297
|
+
{
|
|
298
|
+
activity_id: activity_id,
|
|
299
|
+
content_state: {
|
|
300
|
+
title: "Reindexing product search",
|
|
301
|
+
subtitle: "Shard 7 of 12",
|
|
302
|
+
number_of_steps: 12,
|
|
303
|
+
current_step: 7
|
|
304
|
+
},
|
|
305
|
+
action: {
|
|
306
|
+
title: "Pause Reindex",
|
|
307
|
+
type: "webhook",
|
|
308
|
+
url: "https://ops.example.com/hooks/search/reindex/pause",
|
|
309
|
+
method: "POST",
|
|
310
|
+
body: {
|
|
311
|
+
job_id: "reindex-2026-03-19",
|
|
312
|
+
requested_by: "activitysmith-ruby"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Channels
|
|
320
|
+
|
|
321
|
+
Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
|
|
221
322
|
|
|
222
323
|
```ruby
|
|
223
|
-
|
|
324
|
+
activitysmith.notifications.send(
|
|
224
325
|
{
|
|
225
326
|
title: "New subscription 💸",
|
|
226
327
|
message: "Customer upgraded to Pro plan",
|
|
227
|
-
|
|
228
|
-
actions: [ # Optional (max 4)
|
|
229
|
-
{
|
|
230
|
-
title: "Open CRM Profile",
|
|
231
|
-
type: "open_url",
|
|
232
|
-
url: "https://crm.example.com/customers/cus_9f3a1d"
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
title: "Start Onboarding Workflow",
|
|
236
|
-
type: "webhook",
|
|
237
|
-
url: "https://hooks.example.com/activitysmith/onboarding/start",
|
|
238
|
-
method: "POST",
|
|
239
|
-
body: {
|
|
240
|
-
customer_id: "cus_9f3a1d",
|
|
241
|
-
plan: "pro"
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
]
|
|
328
|
+
channels: ["sales", "customer-success"] # Optional
|
|
245
329
|
}
|
|
246
330
|
)
|
|
247
331
|
```
|
|
@@ -20,7 +20,7 @@ module OpenapiClient
|
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
22
|
# Send a push notification
|
|
23
|
-
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL
|
|
23
|
+
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`.
|
|
24
24
|
# @param push_notification_request [PushNotificationRequest]
|
|
25
25
|
# @param [Hash] opts the optional parameters
|
|
26
26
|
# @return [PushNotificationResponse]
|
|
@@ -30,7 +30,7 @@ module OpenapiClient
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# Send a push notification
|
|
33
|
-
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL
|
|
33
|
+
# Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`.
|
|
34
34
|
# @param push_notification_request [PushNotificationRequest]
|
|
35
35
|
# @param [Hash] opts the optional parameters
|
|
36
36
|
# @return [Array<(PushNotificationResponse, Integer, Hash)>] PushNotificationResponse data, response status code and response headers
|
|
@@ -0,0 +1,323 @@
|
|
|
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
|
+
# Optional single action button shown in the Live Activity UI.
|
|
18
|
+
class LiveActivityAction
|
|
19
|
+
# Button title displayed in the Live Activity UI.
|
|
20
|
+
attr_accessor :title
|
|
21
|
+
|
|
22
|
+
attr_accessor :type
|
|
23
|
+
|
|
24
|
+
# HTTPS URL. For open_url it is opened in browser. For webhook it is called by ActivitySmith backend.
|
|
25
|
+
attr_accessor :url
|
|
26
|
+
|
|
27
|
+
# Webhook HTTP method. Used only when type=webhook.
|
|
28
|
+
attr_accessor :method
|
|
29
|
+
|
|
30
|
+
# Optional webhook payload body. Used only when type=webhook.
|
|
31
|
+
attr_accessor :body
|
|
32
|
+
|
|
33
|
+
class EnumAttributeValidator
|
|
34
|
+
attr_reader :datatype
|
|
35
|
+
attr_reader :allowable_values
|
|
36
|
+
|
|
37
|
+
def initialize(datatype, allowable_values)
|
|
38
|
+
@allowable_values = allowable_values.map do |value|
|
|
39
|
+
case datatype.to_s
|
|
40
|
+
when /Integer/i
|
|
41
|
+
value.to_i
|
|
42
|
+
when /Float/i
|
|
43
|
+
value.to_f
|
|
44
|
+
else
|
|
45
|
+
value
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def valid?(value)
|
|
51
|
+
!value || allowable_values.include?(value)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
56
|
+
def self.attribute_map
|
|
57
|
+
{
|
|
58
|
+
:'title' => :'title',
|
|
59
|
+
:'type' => :'type',
|
|
60
|
+
:'url' => :'url',
|
|
61
|
+
:'method' => :'method',
|
|
62
|
+
:'body' => :'body'
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Returns all the JSON keys this model knows about
|
|
67
|
+
def self.acceptable_attributes
|
|
68
|
+
attribute_map.values
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Attribute type mapping.
|
|
72
|
+
def self.openapi_types
|
|
73
|
+
{
|
|
74
|
+
:'title' => :'String',
|
|
75
|
+
:'type' => :'LiveActivityActionType',
|
|
76
|
+
:'url' => :'String',
|
|
77
|
+
:'method' => :'LiveActivityWebhookMethod',
|
|
78
|
+
:'body' => :'Hash<String, Object>'
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# List of attributes with nullable: true
|
|
83
|
+
def self.openapi_nullable
|
|
84
|
+
Set.new([
|
|
85
|
+
])
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Initializes the object
|
|
89
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
90
|
+
def initialize(attributes = {})
|
|
91
|
+
if (!attributes.is_a?(Hash))
|
|
92
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::LiveActivityAction` initialize method"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
96
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
97
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
98
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::LiveActivityAction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
99
|
+
end
|
|
100
|
+
h[k.to_sym] = v
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if attributes.key?(:'title')
|
|
104
|
+
self.title = attributes[:'title']
|
|
105
|
+
else
|
|
106
|
+
self.title = nil
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'type')
|
|
110
|
+
self.type = attributes[:'type']
|
|
111
|
+
else
|
|
112
|
+
self.type = nil
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if attributes.key?(:'url')
|
|
116
|
+
self.url = attributes[:'url']
|
|
117
|
+
else
|
|
118
|
+
self.url = nil
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if attributes.key?(:'method')
|
|
122
|
+
self.method = attributes[:'method']
|
|
123
|
+
else
|
|
124
|
+
self.method = 'POST'
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
if attributes.key?(:'body')
|
|
128
|
+
if (value = attributes[:'body']).is_a?(Hash)
|
|
129
|
+
self.body = value
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
135
|
+
# @return Array for valid properties with the reasons
|
|
136
|
+
def list_invalid_properties
|
|
137
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
138
|
+
invalid_properties = Array.new
|
|
139
|
+
if @title.nil?
|
|
140
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
if @type.nil?
|
|
144
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
if @url.nil?
|
|
148
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
pattern = Regexp.new(/^https:\/\//)
|
|
152
|
+
if @url !~ pattern
|
|
153
|
+
invalid_properties.push("invalid value for \"url\", must conform to the pattern #{pattern}.")
|
|
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 @title.nil?
|
|
164
|
+
return false if @type.nil?
|
|
165
|
+
return false if @url.nil?
|
|
166
|
+
return false if @url !~ Regexp.new(/^https:\/\//)
|
|
167
|
+
true
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Custom attribute writer method with validation
|
|
171
|
+
# @param [Object] url Value to be assigned
|
|
172
|
+
def url=(url)
|
|
173
|
+
if url.nil?
|
|
174
|
+
fail ArgumentError, 'url cannot be nil'
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
pattern = Regexp.new(/^https:\/\//)
|
|
178
|
+
if url !~ pattern
|
|
179
|
+
fail ArgumentError, "invalid value for \"url\", must conform to the pattern #{pattern}."
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
@url = url
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Checks equality by comparing each attribute.
|
|
186
|
+
# @param [Object] Object to be compared
|
|
187
|
+
def ==(o)
|
|
188
|
+
return true if self.equal?(o)
|
|
189
|
+
self.class == o.class &&
|
|
190
|
+
title == o.title &&
|
|
191
|
+
type == o.type &&
|
|
192
|
+
url == o.url &&
|
|
193
|
+
method == o.method &&
|
|
194
|
+
body == o.body
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# @see the `==` method
|
|
198
|
+
# @param [Object] Object to be compared
|
|
199
|
+
def eql?(o)
|
|
200
|
+
self == o
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Calculates hash code according to all attributes.
|
|
204
|
+
# @return [Integer] Hash code
|
|
205
|
+
def hash
|
|
206
|
+
[title, type, url, method, body].hash
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Builds the object from hash
|
|
210
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
211
|
+
# @return [Object] Returns the model itself
|
|
212
|
+
def self.build_from_hash(attributes)
|
|
213
|
+
return nil unless attributes.is_a?(Hash)
|
|
214
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
215
|
+
transformed_hash = {}
|
|
216
|
+
openapi_types.each_pair do |key, type|
|
|
217
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
218
|
+
transformed_hash["#{key}"] = nil
|
|
219
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
220
|
+
# check to ensure the input is an array given that the attribute
|
|
221
|
+
# is documented as an array but the input is not
|
|
222
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
223
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
224
|
+
end
|
|
225
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
226
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
new(transformed_hash)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Deserializes the data based on type
|
|
233
|
+
# @param string type Data type
|
|
234
|
+
# @param string value Value to be deserialized
|
|
235
|
+
# @return [Object] Deserialized data
|
|
236
|
+
def self._deserialize(type, value)
|
|
237
|
+
case type.to_sym
|
|
238
|
+
when :Time
|
|
239
|
+
Time.parse(value)
|
|
240
|
+
when :Date
|
|
241
|
+
Date.parse(value)
|
|
242
|
+
when :String
|
|
243
|
+
value.to_s
|
|
244
|
+
when :Integer
|
|
245
|
+
value.to_i
|
|
246
|
+
when :Float
|
|
247
|
+
value.to_f
|
|
248
|
+
when :Boolean
|
|
249
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
250
|
+
true
|
|
251
|
+
else
|
|
252
|
+
false
|
|
253
|
+
end
|
|
254
|
+
when :Object
|
|
255
|
+
# generic object (usually a Hash), return directly
|
|
256
|
+
value
|
|
257
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
258
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
259
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
260
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
261
|
+
k_type = Regexp.last_match[:k_type]
|
|
262
|
+
v_type = Regexp.last_match[:v_type]
|
|
263
|
+
{}.tap do |hash|
|
|
264
|
+
value.each do |k, v|
|
|
265
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
else # model
|
|
269
|
+
# models (e.g. Pet) or oneOf
|
|
270
|
+
klass = OpenapiClient.const_get(type)
|
|
271
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# Returns the string representation of the object
|
|
276
|
+
# @return [String] String presentation of the object
|
|
277
|
+
def to_s
|
|
278
|
+
to_hash.to_s
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
282
|
+
# @return [Hash] Returns the object in the form of hash
|
|
283
|
+
def to_body
|
|
284
|
+
to_hash
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Returns the object in the form of hash
|
|
288
|
+
# @return [Hash] Returns the object in the form of hash
|
|
289
|
+
def to_hash
|
|
290
|
+
hash = {}
|
|
291
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
292
|
+
value = self.send(attr)
|
|
293
|
+
if value.nil?
|
|
294
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
295
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
hash[param] = _to_hash(value)
|
|
299
|
+
end
|
|
300
|
+
hash
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Outputs non-array value in the form of hash
|
|
304
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
305
|
+
# @param [Object] value Any valid value
|
|
306
|
+
# @return [Hash] Returns the value in the form of hash
|
|
307
|
+
def _to_hash(value)
|
|
308
|
+
if value.is_a?(Array)
|
|
309
|
+
value.compact.map { |v| _to_hash(v) }
|
|
310
|
+
elsif value.is_a?(Hash)
|
|
311
|
+
{}.tap do |hash|
|
|
312
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
313
|
+
end
|
|
314
|
+
elsif value.respond_to? :to_hash
|
|
315
|
+
value.to_hash
|
|
316
|
+
else
|
|
317
|
+
value
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
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 LiveActivityActionType
|
|
18
|
+
OPEN_URL = "open_url".freeze
|
|
19
|
+
WEBHOOK = "webhook".freeze
|
|
20
|
+
|
|
21
|
+
def self.all_vars
|
|
22
|
+
@all_vars ||= [OPEN_URL, WEBHOOK].freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Builds the enum from string
|
|
26
|
+
# @param [String] The enum value in the form of the string
|
|
27
|
+
# @return [String] The enum value
|
|
28
|
+
def self.build_from_hash(value)
|
|
29
|
+
new.build_from_hash(value)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Builds the enum from string
|
|
33
|
+
# @param [String] The enum value in the form of the string
|
|
34
|
+
# @return [String] The enum value
|
|
35
|
+
def build_from_hash(value)
|
|
36
|
+
return value if LiveActivityActionType.all_vars.include?(value)
|
|
37
|
+
raise "Invalid ENUM value #{value} for class #LiveActivityActionType"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -20,11 +20,14 @@ module OpenapiClient
|
|
|
20
20
|
|
|
21
21
|
attr_accessor :content_state
|
|
22
22
|
|
|
23
|
+
attr_accessor :action
|
|
24
|
+
|
|
23
25
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
24
26
|
def self.attribute_map
|
|
25
27
|
{
|
|
26
28
|
:'activity_id' => :'activity_id',
|
|
27
|
-
:'content_state' => :'content_state'
|
|
29
|
+
:'content_state' => :'content_state',
|
|
30
|
+
:'action' => :'action'
|
|
28
31
|
}
|
|
29
32
|
end
|
|
30
33
|
|
|
@@ -37,7 +40,8 @@ module OpenapiClient
|
|
|
37
40
|
def self.openapi_types
|
|
38
41
|
{
|
|
39
42
|
:'activity_id' => :'String',
|
|
40
|
-
:'content_state' => :'ContentStateEnd'
|
|
43
|
+
:'content_state' => :'ContentStateEnd',
|
|
44
|
+
:'action' => :'LiveActivityAction'
|
|
41
45
|
}
|
|
42
46
|
end
|
|
43
47
|
|
|
@@ -73,6 +77,10 @@ module OpenapiClient
|
|
|
73
77
|
else
|
|
74
78
|
self.content_state = nil
|
|
75
79
|
end
|
|
80
|
+
|
|
81
|
+
if attributes.key?(:'action')
|
|
82
|
+
self.action = attributes[:'action']
|
|
83
|
+
end
|
|
76
84
|
end
|
|
77
85
|
|
|
78
86
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -106,7 +114,8 @@ module OpenapiClient
|
|
|
106
114
|
return true if self.equal?(o)
|
|
107
115
|
self.class == o.class &&
|
|
108
116
|
activity_id == o.activity_id &&
|
|
109
|
-
content_state == o.content_state
|
|
117
|
+
content_state == o.content_state &&
|
|
118
|
+
action == o.action
|
|
110
119
|
end
|
|
111
120
|
|
|
112
121
|
# @see the `==` method
|
|
@@ -118,7 +127,7 @@ module OpenapiClient
|
|
|
118
127
|
# Calculates hash code according to all attributes.
|
|
119
128
|
# @return [Integer] Hash code
|
|
120
129
|
def hash
|
|
121
|
-
[activity_id, content_state].hash
|
|
130
|
+
[activity_id, content_state, action].hash
|
|
122
131
|
end
|
|
123
132
|
|
|
124
133
|
# Builds the object from hash
|
|
@@ -18,6 +18,8 @@ module OpenapiClient
|
|
|
18
18
|
class LiveActivityStartRequest
|
|
19
19
|
attr_accessor :content_state
|
|
20
20
|
|
|
21
|
+
attr_accessor :action
|
|
22
|
+
|
|
21
23
|
attr_accessor :alert
|
|
22
24
|
|
|
23
25
|
attr_accessor :target
|
|
@@ -26,6 +28,7 @@ module OpenapiClient
|
|
|
26
28
|
def self.attribute_map
|
|
27
29
|
{
|
|
28
30
|
:'content_state' => :'content_state',
|
|
31
|
+
:'action' => :'action',
|
|
29
32
|
:'alert' => :'alert',
|
|
30
33
|
:'target' => :'target'
|
|
31
34
|
}
|
|
@@ -40,6 +43,7 @@ module OpenapiClient
|
|
|
40
43
|
def self.openapi_types
|
|
41
44
|
{
|
|
42
45
|
:'content_state' => :'ContentStateStart',
|
|
46
|
+
:'action' => :'LiveActivityAction',
|
|
43
47
|
:'alert' => :'AlertPayload',
|
|
44
48
|
:'target' => :'ChannelTarget'
|
|
45
49
|
}
|
|
@@ -72,6 +76,10 @@ module OpenapiClient
|
|
|
72
76
|
self.content_state = nil
|
|
73
77
|
end
|
|
74
78
|
|
|
79
|
+
if attributes.key?(:'action')
|
|
80
|
+
self.action = attributes[:'action']
|
|
81
|
+
end
|
|
82
|
+
|
|
75
83
|
if attributes.key?(:'alert')
|
|
76
84
|
self.alert = attributes[:'alert']
|
|
77
85
|
end
|
|
@@ -107,6 +115,7 @@ module OpenapiClient
|
|
|
107
115
|
return true if self.equal?(o)
|
|
108
116
|
self.class == o.class &&
|
|
109
117
|
content_state == o.content_state &&
|
|
118
|
+
action == o.action &&
|
|
110
119
|
alert == o.alert &&
|
|
111
120
|
target == o.target
|
|
112
121
|
end
|
|
@@ -120,7 +129,7 @@ module OpenapiClient
|
|
|
120
129
|
# Calculates hash code according to all attributes.
|
|
121
130
|
# @return [Integer] Hash code
|
|
122
131
|
def hash
|
|
123
|
-
[content_state, alert, target].hash
|
|
132
|
+
[content_state, action, alert, target].hash
|
|
124
133
|
end
|
|
125
134
|
|
|
126
135
|
# Builds the object from hash
|
|
@@ -20,11 +20,14 @@ module OpenapiClient
|
|
|
20
20
|
|
|
21
21
|
attr_accessor :content_state
|
|
22
22
|
|
|
23
|
+
attr_accessor :action
|
|
24
|
+
|
|
23
25
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
24
26
|
def self.attribute_map
|
|
25
27
|
{
|
|
26
28
|
:'activity_id' => :'activity_id',
|
|
27
|
-
:'content_state' => :'content_state'
|
|
29
|
+
:'content_state' => :'content_state',
|
|
30
|
+
:'action' => :'action'
|
|
28
31
|
}
|
|
29
32
|
end
|
|
30
33
|
|
|
@@ -37,7 +40,8 @@ module OpenapiClient
|
|
|
37
40
|
def self.openapi_types
|
|
38
41
|
{
|
|
39
42
|
:'activity_id' => :'String',
|
|
40
|
-
:'content_state' => :'ContentStateUpdate'
|
|
43
|
+
:'content_state' => :'ContentStateUpdate',
|
|
44
|
+
:'action' => :'LiveActivityAction'
|
|
41
45
|
}
|
|
42
46
|
end
|
|
43
47
|
|
|
@@ -73,6 +77,10 @@ module OpenapiClient
|
|
|
73
77
|
else
|
|
74
78
|
self.content_state = nil
|
|
75
79
|
end
|
|
80
|
+
|
|
81
|
+
if attributes.key?(:'action')
|
|
82
|
+
self.action = attributes[:'action']
|
|
83
|
+
end
|
|
76
84
|
end
|
|
77
85
|
|
|
78
86
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -106,7 +114,8 @@ module OpenapiClient
|
|
|
106
114
|
return true if self.equal?(o)
|
|
107
115
|
self.class == o.class &&
|
|
108
116
|
activity_id == o.activity_id &&
|
|
109
|
-
content_state == o.content_state
|
|
117
|
+
content_state == o.content_state &&
|
|
118
|
+
action == o.action
|
|
110
119
|
end
|
|
111
120
|
|
|
112
121
|
# @see the `==` method
|
|
@@ -118,7 +127,7 @@ module OpenapiClient
|
|
|
118
127
|
# Calculates hash code according to all attributes.
|
|
119
128
|
# @return [Integer] Hash code
|
|
120
129
|
def hash
|
|
121
|
-
[activity_id, content_state].hash
|
|
130
|
+
[activity_id, content_state, action].hash
|
|
122
131
|
end
|
|
123
132
|
|
|
124
133
|
# Builds the object from hash
|
|
@@ -0,0 +1,40 @@
|
|
|
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 LiveActivityWebhookMethod
|
|
18
|
+
GET = "GET".freeze
|
|
19
|
+
POST = "POST".freeze
|
|
20
|
+
|
|
21
|
+
def self.all_vars
|
|
22
|
+
@all_vars ||= [GET, POST].freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Builds the enum from string
|
|
26
|
+
# @param [String] The enum value in the form of the string
|
|
27
|
+
# @return [String] The enum value
|
|
28
|
+
def self.build_from_hash(value)
|
|
29
|
+
new.build_from_hash(value)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Builds the enum from string
|
|
33
|
+
# @param [String] The enum value in the form of the string
|
|
34
|
+
# @return [String] The enum value
|
|
35
|
+
def build_from_hash(value)
|
|
36
|
+
return value if LiveActivityWebhookMethod.all_vars.include?(value)
|
|
37
|
+
raise "Invalid ENUM value #{value} for class #LiveActivityWebhookMethod"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -21,10 +21,13 @@ module OpenapiClient
|
|
|
21
21
|
|
|
22
22
|
attr_accessor :subtitle
|
|
23
23
|
|
|
24
|
-
# Optional HTTPS URL
|
|
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
|
+
attr_accessor :media
|
|
26
|
+
|
|
27
|
+
# Optional HTTPS URL opened when user taps the notification body. Overrides the default tap target from `media` when both are provided.
|
|
25
28
|
attr_accessor :redirection
|
|
26
29
|
|
|
27
|
-
# Optional interactive actions shown
|
|
30
|
+
# Optional interactive actions shown when users expand the notification. Cannot be combined with `media`.
|
|
28
31
|
attr_accessor :actions
|
|
29
32
|
|
|
30
33
|
attr_accessor :payload
|
|
@@ -41,6 +44,7 @@ module OpenapiClient
|
|
|
41
44
|
:'title' => :'title',
|
|
42
45
|
:'message' => :'message',
|
|
43
46
|
:'subtitle' => :'subtitle',
|
|
47
|
+
:'media' => :'media',
|
|
44
48
|
:'redirection' => :'redirection',
|
|
45
49
|
:'actions' => :'actions',
|
|
46
50
|
:'payload' => :'payload',
|
|
@@ -61,6 +65,7 @@ module OpenapiClient
|
|
|
61
65
|
:'title' => :'String',
|
|
62
66
|
:'message' => :'String',
|
|
63
67
|
:'subtitle' => :'String',
|
|
68
|
+
:'media' => :'String',
|
|
64
69
|
:'redirection' => :'String',
|
|
65
70
|
:'actions' => :'Array<PushNotificationAction>',
|
|
66
71
|
:'payload' => :'Hash<String, Object>',
|
|
@@ -105,6 +110,10 @@ module OpenapiClient
|
|
|
105
110
|
self.subtitle = attributes[:'subtitle']
|
|
106
111
|
end
|
|
107
112
|
|
|
113
|
+
if attributes.key?(:'media')
|
|
114
|
+
self.media = attributes[:'media']
|
|
115
|
+
end
|
|
116
|
+
|
|
108
117
|
if attributes.key?(:'redirection')
|
|
109
118
|
self.redirection = attributes[:'redirection']
|
|
110
119
|
end
|
|
@@ -143,6 +152,11 @@ module OpenapiClient
|
|
|
143
152
|
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
|
144
153
|
end
|
|
145
154
|
|
|
155
|
+
pattern = Regexp.new(/^https:\/\//)
|
|
156
|
+
if !@media.nil? && @media !~ pattern
|
|
157
|
+
invalid_properties.push("invalid value for \"media\", must conform to the pattern #{pattern}.")
|
|
158
|
+
end
|
|
159
|
+
|
|
146
160
|
pattern = Regexp.new(/^https:\/\//)
|
|
147
161
|
if !@redirection.nil? && @redirection !~ pattern
|
|
148
162
|
invalid_properties.push("invalid value for \"redirection\", must conform to the pattern #{pattern}.")
|
|
@@ -160,11 +174,27 @@ module OpenapiClient
|
|
|
160
174
|
def valid?
|
|
161
175
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
162
176
|
return false if @title.nil?
|
|
177
|
+
return false if !@media.nil? && @media !~ Regexp.new(/^https:\/\//)
|
|
163
178
|
return false if !@redirection.nil? && @redirection !~ Regexp.new(/^https:\/\//)
|
|
164
179
|
return false if !@actions.nil? && @actions.length > 4
|
|
165
180
|
true
|
|
166
181
|
end
|
|
167
182
|
|
|
183
|
+
# Custom attribute writer method with validation
|
|
184
|
+
# @param [Object] media Value to be assigned
|
|
185
|
+
def media=(media)
|
|
186
|
+
if media.nil?
|
|
187
|
+
fail ArgumentError, 'media cannot be nil'
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
pattern = Regexp.new(/^https:\/\//)
|
|
191
|
+
if media !~ pattern
|
|
192
|
+
fail ArgumentError, "invalid value for \"media\", must conform to the pattern #{pattern}."
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
@media = media
|
|
196
|
+
end
|
|
197
|
+
|
|
168
198
|
# Custom attribute writer method with validation
|
|
169
199
|
# @param [Object] redirection Value to be assigned
|
|
170
200
|
def redirection=(redirection)
|
|
@@ -202,6 +232,7 @@ module OpenapiClient
|
|
|
202
232
|
title == o.title &&
|
|
203
233
|
message == o.message &&
|
|
204
234
|
subtitle == o.subtitle &&
|
|
235
|
+
media == o.media &&
|
|
205
236
|
redirection == o.redirection &&
|
|
206
237
|
actions == o.actions &&
|
|
207
238
|
payload == o.payload &&
|
|
@@ -219,7 +250,7 @@ module OpenapiClient
|
|
|
219
250
|
# Calculates hash code according to all attributes.
|
|
220
251
|
# @return [Integer] Hash code
|
|
221
252
|
def hash
|
|
222
|
-
[title, message, subtitle, redirection, actions, payload, badge, sound, target].hash
|
|
253
|
+
[title, message, subtitle, media, redirection, actions, payload, badge, sound, target].hash
|
|
223
254
|
end
|
|
224
255
|
|
|
225
256
|
# Builds the object from hash
|
|
@@ -24,6 +24,8 @@ require 'activitysmith_openapi/models/content_state_end'
|
|
|
24
24
|
require 'activitysmith_openapi/models/content_state_start'
|
|
25
25
|
require 'activitysmith_openapi/models/content_state_update'
|
|
26
26
|
require 'activitysmith_openapi/models/forbidden_error'
|
|
27
|
+
require 'activitysmith_openapi/models/live_activity_action'
|
|
28
|
+
require 'activitysmith_openapi/models/live_activity_action_type'
|
|
27
29
|
require 'activitysmith_openapi/models/live_activity_end_request'
|
|
28
30
|
require 'activitysmith_openapi/models/live_activity_end_response'
|
|
29
31
|
require 'activitysmith_openapi/models/live_activity_limit_error'
|
|
@@ -31,6 +33,7 @@ require 'activitysmith_openapi/models/live_activity_start_request'
|
|
|
31
33
|
require 'activitysmith_openapi/models/live_activity_start_response'
|
|
32
34
|
require 'activitysmith_openapi/models/live_activity_update_request'
|
|
33
35
|
require 'activitysmith_openapi/models/live_activity_update_response'
|
|
36
|
+
require 'activitysmith_openapi/models/live_activity_webhook_method'
|
|
34
37
|
require 'activitysmith_openapi/models/no_recipients_error'
|
|
35
38
|
require 'activitysmith_openapi/models/push_notification_action'
|
|
36
39
|
require 'activitysmith_openapi/models/push_notification_action_type'
|
data/lib/activitysmith/client.rb
CHANGED
|
@@ -11,6 +11,7 @@ module ActivitySmith
|
|
|
11
11
|
|
|
12
12
|
config = OpenapiClient::Configuration.new
|
|
13
13
|
config.access_token = api_key
|
|
14
|
+
config.user_agent = VersionedUserAgent.value if config.respond_to?(:user_agent=)
|
|
14
15
|
|
|
15
16
|
api_client = OpenapiClient::ApiClient.new(config)
|
|
16
17
|
@notifications = Notifications.new(OpenapiClient::PushNotificationsApi.new(api_client))
|
|
@@ -7,12 +7,16 @@ module ActivitySmith
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def send(request, opts = {})
|
|
10
|
-
|
|
10
|
+
normalized = normalize_channels_target(request)
|
|
11
|
+
assert_valid_media_actions!(normalized)
|
|
12
|
+
@api.send_push_notification(normalized, opts)
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
# Backward-compatible alias.
|
|
14
16
|
def send_push_notification(push_notification_request, opts = {})
|
|
15
|
-
|
|
17
|
+
normalized = normalize_channels_target(push_notification_request)
|
|
18
|
+
assert_valid_media_actions!(normalized)
|
|
19
|
+
@api.send_push_notification(normalized, opts)
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def method_missing(name, *args, &block)
|
|
@@ -49,5 +53,29 @@ module ActivitySmith
|
|
|
49
53
|
[]
|
|
50
54
|
end
|
|
51
55
|
end
|
|
56
|
+
|
|
57
|
+
def assert_valid_media_actions!(request)
|
|
58
|
+
media = request_value(request, :media)
|
|
59
|
+
actions = request_value(request, :actions)
|
|
60
|
+
has_media = media.is_a?(String) ? !media.strip.empty? : !media.nil?
|
|
61
|
+
has_actions = actions.respond_to?(:empty?) ? !actions.empty? : !actions.nil?
|
|
62
|
+
|
|
63
|
+
return unless has_media && has_actions
|
|
64
|
+
|
|
65
|
+
raise ArgumentError, "ActivitySmith: media cannot be combined with actions"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def request_value(request, key)
|
|
69
|
+
if request.is_a?(Hash)
|
|
70
|
+
return request[key] if request.key?(key)
|
|
71
|
+
return request[key.to_s] if request.key?(key.to_s)
|
|
72
|
+
|
|
73
|
+
return nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
return request.public_send(key) if request.respond_to?(key)
|
|
77
|
+
|
|
78
|
+
nil
|
|
79
|
+
end
|
|
52
80
|
end
|
|
53
81
|
end
|
data/lib/activitysmith.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "activitysmith/version"
|
|
4
|
+
require_relative "activitysmith/versioned_user_agent"
|
|
4
5
|
require_relative "activitysmith/notifications"
|
|
5
6
|
require_relative "activitysmith/live_activities"
|
|
6
7
|
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: 0.
|
|
4
|
+
version: 1.0.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-03-
|
|
11
|
+
date: 2026-03-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -88,6 +88,8 @@ files:
|
|
|
88
88
|
- generated/activitysmith_openapi/models/content_state_start.rb
|
|
89
89
|
- generated/activitysmith_openapi/models/content_state_update.rb
|
|
90
90
|
- generated/activitysmith_openapi/models/forbidden_error.rb
|
|
91
|
+
- generated/activitysmith_openapi/models/live_activity_action.rb
|
|
92
|
+
- generated/activitysmith_openapi/models/live_activity_action_type.rb
|
|
91
93
|
- generated/activitysmith_openapi/models/live_activity_end_request.rb
|
|
92
94
|
- generated/activitysmith_openapi/models/live_activity_end_response.rb
|
|
93
95
|
- generated/activitysmith_openapi/models/live_activity_limit_error.rb
|
|
@@ -95,6 +97,7 @@ files:
|
|
|
95
97
|
- generated/activitysmith_openapi/models/live_activity_start_response.rb
|
|
96
98
|
- generated/activitysmith_openapi/models/live_activity_update_request.rb
|
|
97
99
|
- generated/activitysmith_openapi/models/live_activity_update_response.rb
|
|
100
|
+
- generated/activitysmith_openapi/models/live_activity_webhook_method.rb
|
|
98
101
|
- generated/activitysmith_openapi/models/no_recipients_error.rb
|
|
99
102
|
- generated/activitysmith_openapi/models/push_notification_action.rb
|
|
100
103
|
- generated/activitysmith_openapi/models/push_notification_action_type.rb
|
|
@@ -109,6 +112,7 @@ files:
|
|
|
109
112
|
- lib/activitysmith/live_activities.rb
|
|
110
113
|
- lib/activitysmith/notifications.rb
|
|
111
114
|
- lib/activitysmith/version.rb
|
|
115
|
+
- lib/activitysmith/versioned_user_agent.rb
|
|
112
116
|
homepage: https://activitysmith.com/docs/sdks/ruby
|
|
113
117
|
licenses:
|
|
114
118
|
- MIT
|