activitysmith 1.2.1 → 1.3.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 +113 -1
- data/generated/activitysmith_openapi/api/live_activities_api.rb +6 -6
- data/generated/activitysmith_openapi/models/activity_metric.rb +46 -30
- data/generated/activitysmith_openapi/models/activity_metric_value.rb +105 -0
- data/generated/activitysmith_openapi/models/content_state_end.rb +13 -4
- data/generated/activitysmith_openapi/models/content_state_start.rb +13 -4
- data/generated/activitysmith_openapi/models/content_state_update.rb +13 -4
- data/generated/activitysmith_openapi/models/stream_content_state.rb +13 -4
- data/generated/activitysmith_openapi/version.rb +1 -1
- data/generated/activitysmith_openapi.rb +1 -0
- data/lib/activitysmith/live_activities.rb +5 -0
- data/lib/activitysmith/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d97dda055e4f02cb5a23a068d6cf926aa298df90d535ed90b04f04a054274d5
|
|
4
|
+
data.tar.gz: 1f7207214477f6dad9a1421b57664f644d181234e061e554531f461f5cfd9ad7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b458cd36f4170e00116fe5e443a4e4590ea9c1d1d9b493d49daced2b3bf41b70ed0a6e9d5a2fc5e0a625e07fdfb7b61ac84125d099f5abba024fa0f60678ce1
|
|
7
|
+
data.tar.gz: a544c93e039ed071d9f0627d406f6577ca63ed03db7d160f719e0b37a66ec725b15a8696cefa8ef971ed51aea66cdb18fb3e9e022b8eda98dda939f9c510248a
|
data/README.md
CHANGED
|
@@ -17,6 +17,7 @@ See [API reference](https://activitysmith.com/docs/api-reference/introduction).
|
|
|
17
17
|
- [Live Activities](#live-activities)
|
|
18
18
|
- [Simple: Let ActivitySmith manage the Live Activity for you](#simple-let-activitysmith-manage-the-live-activity-for-you)
|
|
19
19
|
- [Advanced: Full lifecycle control](#advanced-full-lifecycle-control)
|
|
20
|
+
- [Stats Type](#stats-type)
|
|
20
21
|
- [Metrics Type](#metrics-type)
|
|
21
22
|
- [Segmented Progress Type](#segmented-progress-type)
|
|
22
23
|
- [Progress Type](#progress-type)
|
|
@@ -127,8 +128,9 @@ activitysmith.notifications.send(
|
|
|
127
128
|
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Metrics Live Activity screenshot" width="680" />
|
|
128
129
|
</p>
|
|
129
130
|
|
|
130
|
-
There are
|
|
131
|
+
There are four types of Live Activities:
|
|
131
132
|
|
|
133
|
+
- `stats`: best for compact business or product stats like revenue, orders, conversion, and average order value
|
|
132
134
|
- `metrics`: best for live operational stats like server CPU and memory, queue depth, or replica lag
|
|
133
135
|
- `segmented_progress`: best for step-based workflows like deployments, backups, and ETL pipelines
|
|
134
136
|
- `progress`: best for continuous jobs like uploads, reindexes, and long-running migrations tracked as a percentage
|
|
@@ -155,6 +157,33 @@ such as a server, deployment, build pipeline, cron job, or charging session.
|
|
|
155
157
|
This is especially useful for cron jobs and other scheduled tasks where you do
|
|
156
158
|
not want to store `activity_id` between runs.
|
|
157
159
|
|
|
160
|
+
#### Stats
|
|
161
|
+
|
|
162
|
+
<p align="center">
|
|
163
|
+
<img src="https://cdn.activitysmith.com/features/stats-live-activity.png" alt="Stats stream example" width="680" />
|
|
164
|
+
</p>
|
|
165
|
+
|
|
166
|
+
```ruby
|
|
167
|
+
status = activitysmith.live_activities.stream(
|
|
168
|
+
"sales-hourly",
|
|
169
|
+
{
|
|
170
|
+
content_state: {
|
|
171
|
+
title: "Sales",
|
|
172
|
+
subtitle: "last hour",
|
|
173
|
+
type: "stats",
|
|
174
|
+
metrics: [
|
|
175
|
+
{ label: "Revenue", value: "$2430", color: "blue" },
|
|
176
|
+
{ label: "Orders", value: "37", color: "green" },
|
|
177
|
+
{ label: "Conversion", value: "4.8%", color: "magenta" },
|
|
178
|
+
{ label: "Avg Order", value: "$65.68", color: "yellow" },
|
|
179
|
+
{ label: "Refunds", value: "$84", color: "red" },
|
|
180
|
+
{ label: "New Buyers", value: "18", color: "cyan" }
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
```
|
|
186
|
+
|
|
158
187
|
#### Metrics
|
|
159
188
|
|
|
160
189
|
<p align="center">
|
|
@@ -265,6 +294,89 @@ Use these methods when you want to manage the Live Activity lifecycle yourself:
|
|
|
265
294
|
3. Call `activitysmith.live_activities.update(...)` as progress changes.
|
|
266
295
|
4. Call `activitysmith.live_activities.end(...)` when the work is finished.
|
|
267
296
|
|
|
297
|
+
### Stats Type
|
|
298
|
+
|
|
299
|
+
Keep your key numbers on your Lock Screen. `stats` fits 1 to 8 labeled values,
|
|
300
|
+
such as revenue, orders, conversion, uptime, or any other business metric you
|
|
301
|
+
want visible at a glance. Each metric can use a formatted string or number as
|
|
302
|
+
its `value`. Add `color` to a metric to show an accent dot next to its label;
|
|
303
|
+
omit `color` to show the label without a dot.
|
|
304
|
+
|
|
305
|
+
#### Start
|
|
306
|
+
|
|
307
|
+
<p align="center">
|
|
308
|
+
<img src="https://cdn.activitysmith.com/features/stats-live-activity.png" alt="Stats Live Activity with sales revenue, orders, conversion, and average order value" width="680" />
|
|
309
|
+
</p>
|
|
310
|
+
|
|
311
|
+
```ruby
|
|
312
|
+
start = activitysmith.live_activities.start(
|
|
313
|
+
{
|
|
314
|
+
content_state: {
|
|
315
|
+
title: "Sales",
|
|
316
|
+
subtitle: "last hour",
|
|
317
|
+
type: "stats",
|
|
318
|
+
metrics: [
|
|
319
|
+
{ label: "Revenue", value: "$2430", color: "blue" },
|
|
320
|
+
{ label: "Orders", value: "37", color: "green" },
|
|
321
|
+
{ label: "Conversion", value: "4.8%", color: "magenta" },
|
|
322
|
+
{ label: "Avg Order", value: "$65.68", color: "yellow" },
|
|
323
|
+
{ label: "Refunds", value: "$84", color: "red" },
|
|
324
|
+
{ label: "New Buyers", value: "18", color: "cyan" }
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
activity_id = start.activity_id
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Update
|
|
334
|
+
|
|
335
|
+
```ruby
|
|
336
|
+
activitysmith.live_activities.update(
|
|
337
|
+
{
|
|
338
|
+
activity_id: activity_id,
|
|
339
|
+
content_state: {
|
|
340
|
+
title: "Sales",
|
|
341
|
+
subtitle: "last hour",
|
|
342
|
+
type: "stats",
|
|
343
|
+
metrics: [
|
|
344
|
+
{ label: "Revenue", value: "$3180", color: "blue" },
|
|
345
|
+
{ label: "Orders", value: "51", color: "green" },
|
|
346
|
+
{ label: "Conversion", value: "5.2%", color: "magenta" },
|
|
347
|
+
{ label: "Avg Order", value: "$62.35", color: "yellow" },
|
|
348
|
+
{ label: "Refunds", value: "$126", color: "red" },
|
|
349
|
+
{ label: "New Buyers", value: "24", color: "cyan" }
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
#### End
|
|
357
|
+
|
|
358
|
+
```ruby
|
|
359
|
+
activitysmith.live_activities.end(
|
|
360
|
+
{
|
|
361
|
+
activity_id: activity_id,
|
|
362
|
+
content_state: {
|
|
363
|
+
title: "Sales",
|
|
364
|
+
subtitle: "last hour",
|
|
365
|
+
type: "stats",
|
|
366
|
+
metrics: [
|
|
367
|
+
{ label: "Revenue", value: "$3460", color: "blue" },
|
|
368
|
+
{ label: "Orders", value: "58", color: "green" },
|
|
369
|
+
{ label: "Conversion", value: "5.4%", color: "magenta" },
|
|
370
|
+
{ label: "Avg Order", value: "$59.66", color: "yellow" },
|
|
371
|
+
{ label: "Refunds", value: "$92", color: "red" },
|
|
372
|
+
{ label: "New Buyers", value: "31", color: "cyan" }
|
|
373
|
+
],
|
|
374
|
+
auto_dismiss_minutes: 2
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
)
|
|
378
|
+
```
|
|
379
|
+
|
|
268
380
|
### Metrics Type
|
|
269
381
|
|
|
270
382
|
Use `metrics` when you want to keep a small set of live stats visible, such as
|
|
@@ -20,7 +20,7 @@ module OpenapiClient
|
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
22
|
# End a Live Activity
|
|
23
|
-
# Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and
|
|
23
|
+
# Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
|
|
24
24
|
# @param live_activity_end_request [LiveActivityEndRequest]
|
|
25
25
|
# @param [Hash] opts the optional parameters
|
|
26
26
|
# @return [LiveActivityEndResponse]
|
|
@@ -30,7 +30,7 @@ module OpenapiClient
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# End a Live Activity
|
|
33
|
-
# Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and
|
|
33
|
+
# Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
|
|
34
34
|
# @param live_activity_end_request [LiveActivityEndRequest]
|
|
35
35
|
# @param [Hash] opts the optional parameters
|
|
36
36
|
# @return [Array<(LiveActivityEndResponse, Integer, Hash)>] LiveActivityEndResponse data, response status code and response headers
|
|
@@ -250,7 +250,7 @@ module OpenapiClient
|
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
# Start a Live Activity
|
|
253
|
-
# Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and
|
|
253
|
+
# Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
|
|
254
254
|
# @param live_activity_start_request [LiveActivityStartRequest]
|
|
255
255
|
# @param [Hash] opts the optional parameters
|
|
256
256
|
# @return [LiveActivityStartResponse]
|
|
@@ -260,7 +260,7 @@ module OpenapiClient
|
|
|
260
260
|
end
|
|
261
261
|
|
|
262
262
|
# Start a Live Activity
|
|
263
|
-
# Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and
|
|
263
|
+
# Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
|
|
264
264
|
# @param live_activity_start_request [LiveActivityStartRequest]
|
|
265
265
|
# @param [Hash] opts the optional parameters
|
|
266
266
|
# @return [Array<(LiveActivityStartResponse, Integer, Hash)>] LiveActivityStartResponse data, response status code and response headers
|
|
@@ -318,7 +318,7 @@ module OpenapiClient
|
|
|
318
318
|
end
|
|
319
319
|
|
|
320
320
|
# Update a Live Activity
|
|
321
|
-
# Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and
|
|
321
|
+
# Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
|
|
322
322
|
# @param live_activity_update_request [LiveActivityUpdateRequest]
|
|
323
323
|
# @param [Hash] opts the optional parameters
|
|
324
324
|
# @return [LiveActivityUpdateResponse]
|
|
@@ -328,7 +328,7 @@ module OpenapiClient
|
|
|
328
328
|
end
|
|
329
329
|
|
|
330
330
|
# Update a Live Activity
|
|
331
|
-
# Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and
|
|
331
|
+
# Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and stats activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
|
|
332
332
|
# @param live_activity_update_request [LiveActivityUpdateRequest]
|
|
333
333
|
# @param [Hash] opts the optional parameters
|
|
334
334
|
# @return [Array<(LiveActivityUpdateResponse, Integer, Hash)>] LiveActivityUpdateResponse data, response status code and response headers
|
|
@@ -21,12 +21,38 @@ module OpenapiClient
|
|
|
21
21
|
|
|
22
22
|
attr_accessor :unit
|
|
23
23
|
|
|
24
|
+
# Optional per-metric accent color for metrics and stats activities.
|
|
25
|
+
attr_accessor :color
|
|
26
|
+
|
|
27
|
+
class EnumAttributeValidator
|
|
28
|
+
attr_reader :datatype
|
|
29
|
+
attr_reader :allowable_values
|
|
30
|
+
|
|
31
|
+
def initialize(datatype, allowable_values)
|
|
32
|
+
@allowable_values = allowable_values.map do |value|
|
|
33
|
+
case datatype.to_s
|
|
34
|
+
when /Integer/i
|
|
35
|
+
value.to_i
|
|
36
|
+
when /Float/i
|
|
37
|
+
value.to_f
|
|
38
|
+
else
|
|
39
|
+
value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def valid?(value)
|
|
45
|
+
!value || allowable_values.include?(value)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
24
49
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
25
50
|
def self.attribute_map
|
|
26
51
|
{
|
|
27
52
|
:'label' => :'label',
|
|
28
53
|
:'value' => :'value',
|
|
29
|
-
:'unit' => :'unit'
|
|
54
|
+
:'unit' => :'unit',
|
|
55
|
+
:'color' => :'color'
|
|
30
56
|
}
|
|
31
57
|
end
|
|
32
58
|
|
|
@@ -39,8 +65,9 @@ module OpenapiClient
|
|
|
39
65
|
def self.openapi_types
|
|
40
66
|
{
|
|
41
67
|
:'label' => :'String',
|
|
42
|
-
:'value' => :'
|
|
43
|
-
:'unit' => :'String'
|
|
68
|
+
:'value' => :'ActivityMetricValue',
|
|
69
|
+
:'unit' => :'String',
|
|
70
|
+
:'color' => :'String'
|
|
44
71
|
}
|
|
45
72
|
end
|
|
46
73
|
|
|
@@ -80,6 +107,10 @@ module OpenapiClient
|
|
|
80
107
|
if attributes.key?(:'unit')
|
|
81
108
|
self.unit = attributes[:'unit']
|
|
82
109
|
end
|
|
110
|
+
|
|
111
|
+
if attributes.key?(:'color')
|
|
112
|
+
self.color = attributes[:'color']
|
|
113
|
+
end
|
|
83
114
|
end
|
|
84
115
|
|
|
85
116
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -99,14 +130,6 @@ module OpenapiClient
|
|
|
99
130
|
invalid_properties.push('invalid value for "value", value cannot be nil.')
|
|
100
131
|
end
|
|
101
132
|
|
|
102
|
-
if @value > 100
|
|
103
|
-
invalid_properties.push('invalid value for "value", must be smaller than or equal to 100.')
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
if @value < 0
|
|
107
|
-
invalid_properties.push('invalid value for "value", must be greater than or equal to 0.')
|
|
108
|
-
end
|
|
109
|
-
|
|
110
133
|
invalid_properties
|
|
111
134
|
end
|
|
112
135
|
|
|
@@ -117,8 +140,8 @@ module OpenapiClient
|
|
|
117
140
|
return false if @label.nil?
|
|
118
141
|
return false if @label.to_s.length < 1
|
|
119
142
|
return false if @value.nil?
|
|
120
|
-
|
|
121
|
-
return false
|
|
143
|
+
color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
|
|
144
|
+
return false unless color_validator.valid?(@color)
|
|
122
145
|
true
|
|
123
146
|
end
|
|
124
147
|
|
|
@@ -136,22 +159,14 @@ module OpenapiClient
|
|
|
136
159
|
@label = label
|
|
137
160
|
end
|
|
138
161
|
|
|
139
|
-
# Custom attribute writer method
|
|
140
|
-
# @param [Object]
|
|
141
|
-
def
|
|
142
|
-
|
|
143
|
-
|
|
162
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
163
|
+
# @param [Object] color Object to be assigned
|
|
164
|
+
def color=(color)
|
|
165
|
+
validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
|
|
166
|
+
unless validator.valid?(color)
|
|
167
|
+
fail ArgumentError, "invalid value for \"color\", must be one of #{validator.allowable_values}."
|
|
144
168
|
end
|
|
145
|
-
|
|
146
|
-
if value > 100
|
|
147
|
-
fail ArgumentError, 'invalid value for "value", must be smaller than or equal to 100.'
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
if value < 0
|
|
151
|
-
fail ArgumentError, 'invalid value for "value", must be greater than or equal to 0.'
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
@value = value
|
|
169
|
+
@color = color
|
|
155
170
|
end
|
|
156
171
|
|
|
157
172
|
# Checks equality by comparing each attribute.
|
|
@@ -161,7 +176,8 @@ module OpenapiClient
|
|
|
161
176
|
self.class == o.class &&
|
|
162
177
|
label == o.label &&
|
|
163
178
|
value == o.value &&
|
|
164
|
-
unit == o.unit
|
|
179
|
+
unit == o.unit &&
|
|
180
|
+
color == o.color
|
|
165
181
|
end
|
|
166
182
|
|
|
167
183
|
# @see the `==` method
|
|
@@ -173,7 +189,7 @@ module OpenapiClient
|
|
|
173
189
|
# Calculates hash code according to all attributes.
|
|
174
190
|
# @return [Integer] Hash code
|
|
175
191
|
def hash
|
|
176
|
-
[label, value, unit].hash
|
|
192
|
+
[label, value, unit, color].hash
|
|
177
193
|
end
|
|
178
194
|
|
|
179
195
|
# Builds the object from hash
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
module ActivityMetricValue
|
|
18
|
+
class << self
|
|
19
|
+
# List of class defined in oneOf (OpenAPI v3)
|
|
20
|
+
def openapi_one_of
|
|
21
|
+
[
|
|
22
|
+
:'Float',
|
|
23
|
+
:'String'
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Builds the object
|
|
28
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
|
29
|
+
# @return [Object] Returns the model or the data itself
|
|
30
|
+
def build(data)
|
|
31
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
|
32
|
+
# Note:
|
|
33
|
+
# - We do not attempt to check whether exactly one item matches.
|
|
34
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
35
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
36
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
37
|
+
# - TODO: logging when debugging is set.
|
|
38
|
+
openapi_one_of.each do |klass|
|
|
39
|
+
begin
|
|
40
|
+
next if klass == :AnyType # "nullable: true"
|
|
41
|
+
typed_data = find_and_cast_into_type(klass, data)
|
|
42
|
+
return typed_data if typed_data
|
|
43
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
53
|
+
|
|
54
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
55
|
+
def find_and_cast_into_type(klass, data)
|
|
56
|
+
return if data.nil?
|
|
57
|
+
|
|
58
|
+
case klass.to_s
|
|
59
|
+
when 'Boolean'
|
|
60
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
61
|
+
when 'Float'
|
|
62
|
+
return data if data.instance_of?(Float)
|
|
63
|
+
when 'Integer'
|
|
64
|
+
return data if data.instance_of?(Integer)
|
|
65
|
+
when 'Time'
|
|
66
|
+
return Time.parse(data)
|
|
67
|
+
when 'Date'
|
|
68
|
+
return Date.parse(data)
|
|
69
|
+
when 'String'
|
|
70
|
+
return data if data.instance_of?(String)
|
|
71
|
+
when 'Object' # "type: object"
|
|
72
|
+
return data if data.instance_of?(Hash)
|
|
73
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
74
|
+
if data.instance_of?(Array)
|
|
75
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
76
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
77
|
+
end
|
|
78
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
79
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
80
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
81
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
82
|
+
end
|
|
83
|
+
else # model
|
|
84
|
+
const = OpenapiClient.const_get(klass)
|
|
85
|
+
if const
|
|
86
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
|
87
|
+
model = const.build(data)
|
|
88
|
+
return model if model
|
|
89
|
+
else
|
|
90
|
+
# raise if data contains keys that are not known to the model
|
|
91
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
92
|
+
model = const.build_from_hash(data)
|
|
93
|
+
return model if model
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
raise # if no match by now, raise
|
|
99
|
+
rescue
|
|
100
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
@@ -14,7 +14,7 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module OpenapiClient
|
|
17
|
-
# End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
|
|
17
|
+
# End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
|
|
18
18
|
class ContentStateEnd
|
|
19
19
|
attr_accessor :title
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@ module OpenapiClient
|
|
|
35
35
|
# Maximum progress value. Use with value for type=progress.
|
|
36
36
|
attr_accessor :upper_limit
|
|
37
37
|
|
|
38
|
-
# Use for type=metrics.
|
|
38
|
+
# Use for type=metrics or type=stats.
|
|
39
39
|
attr_accessor :metrics
|
|
40
40
|
|
|
41
41
|
# Optional. When omitted, the API uses the existing Live Activity type.
|
|
@@ -227,6 +227,10 @@ module OpenapiClient
|
|
|
227
227
|
invalid_properties.push('invalid value for "percentage", must be greater than or equal to 0.')
|
|
228
228
|
end
|
|
229
229
|
|
|
230
|
+
if !@metrics.nil? && @metrics.length > 8
|
|
231
|
+
invalid_properties.push('invalid value for "metrics", number of items must be less than or equal to 8.')
|
|
232
|
+
end
|
|
233
|
+
|
|
230
234
|
if !@metrics.nil? && @metrics.length < 1
|
|
231
235
|
invalid_properties.push('invalid value for "metrics", number of items must be greater than or equal to 1.')
|
|
232
236
|
end
|
|
@@ -247,8 +251,9 @@ module OpenapiClient
|
|
|
247
251
|
return false if !@current_step.nil? && @current_step < 1
|
|
248
252
|
return false if !@percentage.nil? && @percentage > 100
|
|
249
253
|
return false if !@percentage.nil? && @percentage < 0
|
|
254
|
+
return false if !@metrics.nil? && @metrics.length > 8
|
|
250
255
|
return false if !@metrics.nil? && @metrics.length < 1
|
|
251
|
-
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
256
|
+
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
252
257
|
return false unless type_validator.valid?(@type)
|
|
253
258
|
color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
|
|
254
259
|
return false unless color_validator.valid?(@color)
|
|
@@ -311,6 +316,10 @@ module OpenapiClient
|
|
|
311
316
|
fail ArgumentError, 'metrics cannot be nil'
|
|
312
317
|
end
|
|
313
318
|
|
|
319
|
+
if metrics.length > 8
|
|
320
|
+
fail ArgumentError, 'invalid value for "metrics", number of items must be less than or equal to 8.'
|
|
321
|
+
end
|
|
322
|
+
|
|
314
323
|
if metrics.length < 1
|
|
315
324
|
fail ArgumentError, 'invalid value for "metrics", number of items must be greater than or equal to 1.'
|
|
316
325
|
end
|
|
@@ -321,7 +330,7 @@ module OpenapiClient
|
|
|
321
330
|
# Custom attribute writer method checking allowed values (enum).
|
|
322
331
|
# @param [Object] type Object to be assigned
|
|
323
332
|
def type=(type)
|
|
324
|
-
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
333
|
+
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
325
334
|
unless validator.valid?(type)
|
|
326
335
|
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
327
336
|
end
|
|
@@ -14,7 +14,7 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module OpenapiClient
|
|
17
|
-
# Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls.
|
|
17
|
+
# Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls.
|
|
18
18
|
class ContentStateStart
|
|
19
19
|
attr_accessor :title
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@ module OpenapiClient
|
|
|
35
35
|
# Maximum progress value. Use with value for type=progress.
|
|
36
36
|
attr_accessor :upper_limit
|
|
37
37
|
|
|
38
|
-
# Use for type=metrics.
|
|
38
|
+
# Use for type=metrics or type=stats.
|
|
39
39
|
attr_accessor :metrics
|
|
40
40
|
|
|
41
41
|
attr_accessor :type
|
|
@@ -217,6 +217,10 @@ module OpenapiClient
|
|
|
217
217
|
invalid_properties.push('invalid value for "percentage", must be greater than or equal to 0.')
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
+
if !@metrics.nil? && @metrics.length > 8
|
|
221
|
+
invalid_properties.push('invalid value for "metrics", number of items must be less than or equal to 8.')
|
|
222
|
+
end
|
|
223
|
+
|
|
220
224
|
if !@metrics.nil? && @metrics.length < 1
|
|
221
225
|
invalid_properties.push('invalid value for "metrics", number of items must be greater than or equal to 1.')
|
|
222
226
|
end
|
|
@@ -237,9 +241,10 @@ module OpenapiClient
|
|
|
237
241
|
return false if !@current_step.nil? && @current_step < 1
|
|
238
242
|
return false if !@percentage.nil? && @percentage > 100
|
|
239
243
|
return false if !@percentage.nil? && @percentage < 0
|
|
244
|
+
return false if !@metrics.nil? && @metrics.length > 8
|
|
240
245
|
return false if !@metrics.nil? && @metrics.length < 1
|
|
241
246
|
return false if @type.nil?
|
|
242
|
-
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
247
|
+
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
243
248
|
return false unless type_validator.valid?(@type)
|
|
244
249
|
color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
|
|
245
250
|
return false unless color_validator.valid?(@color)
|
|
@@ -301,6 +306,10 @@ module OpenapiClient
|
|
|
301
306
|
fail ArgumentError, 'metrics cannot be nil'
|
|
302
307
|
end
|
|
303
308
|
|
|
309
|
+
if metrics.length > 8
|
|
310
|
+
fail ArgumentError, 'invalid value for "metrics", number of items must be less than or equal to 8.'
|
|
311
|
+
end
|
|
312
|
+
|
|
304
313
|
if metrics.length < 1
|
|
305
314
|
fail ArgumentError, 'invalid value for "metrics", number of items must be greater than or equal to 1.'
|
|
306
315
|
end
|
|
@@ -311,7 +320,7 @@ module OpenapiClient
|
|
|
311
320
|
# Custom attribute writer method checking allowed values (enum).
|
|
312
321
|
# @param [Object] type Object to be assigned
|
|
313
322
|
def type=(type)
|
|
314
|
-
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
323
|
+
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
315
324
|
unless validator.valid?(type)
|
|
316
325
|
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
317
326
|
end
|
|
@@ -14,7 +14,7 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module OpenapiClient
|
|
17
|
-
# Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
|
|
17
|
+
# Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
|
|
18
18
|
class ContentStateUpdate
|
|
19
19
|
attr_accessor :title
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@ module OpenapiClient
|
|
|
35
35
|
# Maximum progress value. Use with value for type=progress.
|
|
36
36
|
attr_accessor :upper_limit
|
|
37
37
|
|
|
38
|
-
# Use for type=metrics.
|
|
38
|
+
# Use for type=metrics or type=stats.
|
|
39
39
|
attr_accessor :metrics
|
|
40
40
|
|
|
41
41
|
# Optional. When omitted, the API uses the existing Live Activity type.
|
|
@@ -216,6 +216,10 @@ module OpenapiClient
|
|
|
216
216
|
invalid_properties.push('invalid value for "percentage", must be greater than or equal to 0.')
|
|
217
217
|
end
|
|
218
218
|
|
|
219
|
+
if !@metrics.nil? && @metrics.length > 8
|
|
220
|
+
invalid_properties.push('invalid value for "metrics", number of items must be less than or equal to 8.')
|
|
221
|
+
end
|
|
222
|
+
|
|
219
223
|
if !@metrics.nil? && @metrics.length < 1
|
|
220
224
|
invalid_properties.push('invalid value for "metrics", number of items must be greater than or equal to 1.')
|
|
221
225
|
end
|
|
@@ -232,8 +236,9 @@ module OpenapiClient
|
|
|
232
236
|
return false if !@current_step.nil? && @current_step < 1
|
|
233
237
|
return false if !@percentage.nil? && @percentage > 100
|
|
234
238
|
return false if !@percentage.nil? && @percentage < 0
|
|
239
|
+
return false if !@metrics.nil? && @metrics.length > 8
|
|
235
240
|
return false if !@metrics.nil? && @metrics.length < 1
|
|
236
|
-
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
241
|
+
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
237
242
|
return false unless type_validator.valid?(@type)
|
|
238
243
|
color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
|
|
239
244
|
return false unless color_validator.valid?(@color)
|
|
@@ -295,6 +300,10 @@ module OpenapiClient
|
|
|
295
300
|
fail ArgumentError, 'metrics cannot be nil'
|
|
296
301
|
end
|
|
297
302
|
|
|
303
|
+
if metrics.length > 8
|
|
304
|
+
fail ArgumentError, 'invalid value for "metrics", number of items must be less than or equal to 8.'
|
|
305
|
+
end
|
|
306
|
+
|
|
298
307
|
if metrics.length < 1
|
|
299
308
|
fail ArgumentError, 'invalid value for "metrics", number of items must be greater than or equal to 1.'
|
|
300
309
|
end
|
|
@@ -305,7 +314,7 @@ module OpenapiClient
|
|
|
305
314
|
# Custom attribute writer method checking allowed values (enum).
|
|
306
315
|
# @param [Object] type Object to be assigned
|
|
307
316
|
def type=(type)
|
|
308
|
-
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
317
|
+
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
309
318
|
unless validator.valid?(type)
|
|
310
319
|
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
311
320
|
end
|
|
@@ -14,7 +14,7 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module OpenapiClient
|
|
17
|
-
# Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, and
|
|
17
|
+
# Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, metrics, and stats types.
|
|
18
18
|
class StreamContentState
|
|
19
19
|
attr_accessor :title
|
|
20
20
|
|
|
@@ -47,7 +47,7 @@ module OpenapiClient
|
|
|
47
47
|
# Optional. Colors for completed steps. When used with segmented_progress, the array length should match current_step.
|
|
48
48
|
attr_accessor :step_colors
|
|
49
49
|
|
|
50
|
-
# Use for metrics activities.
|
|
50
|
+
# Use for metrics and stats activities.
|
|
51
51
|
attr_accessor :metrics
|
|
52
52
|
|
|
53
53
|
# Optional. Seconds before the ended Live Activity is dismissed.
|
|
@@ -234,6 +234,10 @@ module OpenapiClient
|
|
|
234
234
|
invalid_properties.push('invalid value for "percentage", must be greater than or equal to 0.')
|
|
235
235
|
end
|
|
236
236
|
|
|
237
|
+
if !@metrics.nil? && @metrics.length > 8
|
|
238
|
+
invalid_properties.push('invalid value for "metrics", number of items must be less than or equal to 8.')
|
|
239
|
+
end
|
|
240
|
+
|
|
237
241
|
if !@metrics.nil? && @metrics.length < 1
|
|
238
242
|
invalid_properties.push('invalid value for "metrics", number of items must be greater than or equal to 1.')
|
|
239
243
|
end
|
|
@@ -258,12 +262,13 @@ module OpenapiClient
|
|
|
258
262
|
return false if !@current_step.nil? && @current_step < 1
|
|
259
263
|
return false if !@percentage.nil? && @percentage > 100
|
|
260
264
|
return false if !@percentage.nil? && @percentage < 0
|
|
261
|
-
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
265
|
+
type_validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
262
266
|
return false unless type_validator.valid?(@type)
|
|
263
267
|
color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
|
|
264
268
|
return false unless color_validator.valid?(@color)
|
|
265
269
|
step_color_validator = EnumAttributeValidator.new('String', ["lime", "green", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow"])
|
|
266
270
|
return false unless step_color_validator.valid?(@step_color)
|
|
271
|
+
return false if !@metrics.nil? && @metrics.length > 8
|
|
267
272
|
return false if !@metrics.nil? && @metrics.length < 1
|
|
268
273
|
return false if !@auto_dismiss_seconds.nil? && @auto_dismiss_seconds < 0
|
|
269
274
|
return false if !@auto_dismiss_minutes.nil? && @auto_dismiss_minutes < 0
|
|
@@ -319,7 +324,7 @@ module OpenapiClient
|
|
|
319
324
|
# Custom attribute writer method checking allowed values (enum).
|
|
320
325
|
# @param [Object] type Object to be assigned
|
|
321
326
|
def type=(type)
|
|
322
|
-
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics"])
|
|
327
|
+
validator = EnumAttributeValidator.new('String', ["segmented_progress", "progress", "metrics", "stats"])
|
|
323
328
|
unless validator.valid?(type)
|
|
324
329
|
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
325
330
|
end
|
|
@@ -353,6 +358,10 @@ module OpenapiClient
|
|
|
353
358
|
fail ArgumentError, 'metrics cannot be nil'
|
|
354
359
|
end
|
|
355
360
|
|
|
361
|
+
if metrics.length > 8
|
|
362
|
+
fail ArgumentError, 'invalid value for "metrics", number of items must be less than or equal to 8.'
|
|
363
|
+
end
|
|
364
|
+
|
|
356
365
|
if metrics.length < 1
|
|
357
366
|
fail ArgumentError, 'invalid value for "metrics", number of items must be greater than or equal to 1.'
|
|
358
367
|
end
|
|
@@ -18,6 +18,7 @@ require 'activitysmith_openapi/configuration'
|
|
|
18
18
|
|
|
19
19
|
# Models
|
|
20
20
|
require 'activitysmith_openapi/models/activity_metric'
|
|
21
|
+
require 'activitysmith_openapi/models/activity_metric_value'
|
|
21
22
|
require 'activitysmith_openapi/models/alert_payload'
|
|
22
23
|
require 'activitysmith_openapi/models/bad_request_error'
|
|
23
24
|
require 'activitysmith_openapi/models/channel_target'
|
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.
|
|
4
|
+
version: 1.3.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-05-
|
|
11
|
+
date: 2026-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -83,6 +83,7 @@ files:
|
|
|
83
83
|
- generated/activitysmith_openapi/api_error.rb
|
|
84
84
|
- generated/activitysmith_openapi/configuration.rb
|
|
85
85
|
- generated/activitysmith_openapi/models/activity_metric.rb
|
|
86
|
+
- generated/activitysmith_openapi/models/activity_metric_value.rb
|
|
86
87
|
- generated/activitysmith_openapi/models/alert_payload.rb
|
|
87
88
|
- generated/activitysmith_openapi/models/bad_request_error.rb
|
|
88
89
|
- generated/activitysmith_openapi/models/channel_target.rb
|