From c3359c82cae2f3242f09d630cc95bc8c8c913db9 Mon Sep 17 00:00:00 2001 From: bardonadam Date: Tue, 26 May 2026 18:43:42 +0700 Subject: [PATCH 1/4] Add alert live activity helpers --- src/LiveActivities.php | 46 +++++++++++++++++++++++++++ src/LiveActivityAlertBadge.php | 24 ++++++++++++++ src/LiveActivityAlertIcon.php | 24 ++++++++++++++ src/LiveActivityContentState.php | 38 +++++++++++++--------- tests/ResourcesTest.php | 54 ++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+), 15 deletions(-) create mode 100644 src/LiveActivityAlertBadge.php create mode 100644 src/LiveActivityAlertIcon.php diff --git a/src/LiveActivities.php b/src/LiveActivities.php index 4963b19..9a817f6 100644 --- a/src/LiveActivities.php +++ b/src/LiveActivities.php @@ -12,6 +12,7 @@ final class LiveActivities public const TYPE_PROGRESS = 'progress'; public const TYPE_METRICS = 'metrics'; public const TYPE_STATS = 'stats'; + public const TYPE_ALERT = 'alert'; public function __construct(private LiveActivitiesApi $api) { @@ -23,6 +24,9 @@ public function start( mixed $title = null, mixed $subtitle = null, mixed $type = null, + mixed $message = null, + mixed $icon = null, + mixed $badge = null, mixed $metrics = null, mixed $numberOfSteps = null, mixed $currentStep = null, @@ -41,6 +45,9 @@ public function start( 'title' => $title, 'subtitle' => $subtitle, 'type' => $type, + 'message' => $message, + 'icon' => $icon, + 'badge' => $badge, 'metrics' => $metrics, 'number_of_steps' => $numberOfSteps, 'current_step' => $currentStep, @@ -66,6 +73,9 @@ public function update( mixed $title = null, mixed $subtitle = null, mixed $type = null, + mixed $message = null, + mixed $icon = null, + mixed $badge = null, mixed $metrics = null, mixed $numberOfSteps = null, mixed $currentStep = null, @@ -81,6 +91,9 @@ public function update( 'title' => $title, 'subtitle' => $subtitle, 'type' => $type, + 'message' => $message, + 'icon' => $icon, + 'badge' => $badge, 'metrics' => $metrics, 'number_of_steps' => $numberOfSteps, 'current_step' => $currentStep, @@ -104,6 +117,9 @@ public function end( mixed $title = null, mixed $subtitle = null, mixed $type = null, + mixed $message = null, + mixed $icon = null, + mixed $badge = null, mixed $metrics = null, mixed $numberOfSteps = null, mixed $currentStep = null, @@ -120,6 +136,9 @@ public function end( 'title' => $title, 'subtitle' => $subtitle, 'type' => $type, + 'message' => $message, + 'icon' => $icon, + 'badge' => $badge, 'metrics' => $metrics, 'number_of_steps' => $numberOfSteps, 'current_step' => $currentStep, @@ -144,6 +163,9 @@ public function stream( mixed $title = null, mixed $subtitle = null, mixed $type = null, + mixed $message = null, + mixed $icon = null, + mixed $badge = null, mixed $metrics = null, mixed $numberOfSteps = null, mixed $currentStep = null, @@ -162,6 +184,9 @@ public function stream( 'title' => $title, 'subtitle' => $subtitle, 'type' => $type, + 'message' => $message, + 'icon' => $icon, + 'badge' => $badge, 'metrics' => $metrics, 'number_of_steps' => $numberOfSteps, 'current_step' => $currentStep, @@ -190,6 +215,9 @@ public function endStream( mixed $title = null, mixed $subtitle = null, mixed $type = null, + mixed $message = null, + mixed $icon = null, + mixed $badge = null, mixed $metrics = null, mixed $numberOfSteps = null, mixed $currentStep = null, @@ -207,6 +235,9 @@ public function endStream( 'title' => $title, 'subtitle' => $subtitle, 'type' => $type, + 'message' => $message, + 'icon' => $icon, + 'badge' => $badge, 'metrics' => $metrics, 'number_of_steps' => $numberOfSteps, 'current_step' => $currentStep, @@ -333,6 +364,7 @@ private function buildRequest(mixed $request, mixed $contentState, array $conten } if ($contentState !== null) { + $contentState = $this->normalizeContentState($contentState); $existingContentState = $request['content_state'] ?? []; if (!is_array($existingContentState) || !is_array($contentState)) { throw new \InvalidArgumentException('ActivitySmith: content_state must be an array'); @@ -346,6 +378,7 @@ private function buildRequest(mixed $request, mixed $contentState, array $conten throw new \InvalidArgumentException('ActivitySmith: content_state must be an array'); } $request['content_state'] = array_merge($existingContentState, $contentStateFields); + $request['content_state'] = $this->normalizeContentState($request['content_state']); } if (array_key_exists('activity_id', $requestFields)) { @@ -357,4 +390,17 @@ private function buildRequest(mixed $request, mixed $contentState, array $conten return array_merge($request, $requestFields); } + + /** + * @param array $contentState + * @return array + */ + private function normalizeContentState(array $contentState): array + { + if (($contentState['type'] ?? null) === self::TYPE_ALERT) { + unset($contentState['color']); + } + + return $contentState; + } } diff --git a/src/LiveActivityAlertBadge.php b/src/LiveActivityAlertBadge.php new file mode 100644 index 0000000..442f220 --- /dev/null +++ b/src/LiveActivityAlertBadge.php @@ -0,0 +1,24 @@ + $title, + 'color' => $color, + ], + static fn (mixed $value): bool => $value !== null + ); + } +} diff --git a/src/LiveActivityAlertIcon.php b/src/LiveActivityAlertIcon.php new file mode 100644 index 0000000..02db34e --- /dev/null +++ b/src/LiveActivityAlertIcon.php @@ -0,0 +1,24 @@ + $symbol, + 'color' => $color, + ], + static fn (mixed $value): bool => $value !== null + ); + } +} diff --git a/src/LiveActivityContentState.php b/src/LiveActivityContentState.php index a2a8f4b..413870e 100644 --- a/src/LiveActivityContentState.php +++ b/src/LiveActivityContentState.php @@ -14,6 +14,9 @@ public static function make( string $title, ?string $type = null, ?string $subtitle = null, + ?string $message = null, + ?array $icon = null, + ?array $badge = null, ?array $metrics = null, ?int $numberOfSteps = null, ?int $currentStep = null, @@ -25,22 +28,27 @@ public static function make( ?int $autoDismissSeconds = null, ?int $autoDismissMinutes = null ): array { + $state = [ + 'title' => $title, + 'subtitle' => $subtitle, + 'type' => $type, + 'message' => $message, + 'icon' => $icon, + 'badge' => $badge, + 'metrics' => $metrics, + 'number_of_steps' => $numberOfSteps, + 'current_step' => $currentStep, + 'percentage' => $percentage, + 'value' => $value, + 'upper_limit' => $upperLimit, + 'color' => $type === LiveActivities::TYPE_ALERT ? null : $color, + 'step_color' => $stepColor, + 'auto_dismiss_seconds' => $autoDismissSeconds, + 'auto_dismiss_minutes' => $autoDismissMinutes, + ]; + return array_filter( - [ - 'title' => $title, - 'subtitle' => $subtitle, - 'type' => $type, - 'metrics' => $metrics, - 'number_of_steps' => $numberOfSteps, - 'current_step' => $currentStep, - 'percentage' => $percentage, - 'value' => $value, - 'upper_limit' => $upperLimit, - 'color' => $color, - 'step_color' => $stepColor, - 'auto_dismiss_seconds' => $autoDismissSeconds, - 'auto_dismiss_minutes' => $autoDismissMinutes, - ], + $state, static fn (mixed $value): bool => $value !== null ); } diff --git a/tests/ResourcesTest.php b/tests/ResourcesTest.php index 52d4574..598fa93 100644 --- a/tests/ResourcesTest.php +++ b/tests/ResourcesTest.php @@ -6,6 +6,8 @@ use ActivitySmith\LiveActivities; use ActivitySmith\LiveActivityAction; +use ActivitySmith\LiveActivityAlertBadge; +use ActivitySmith\LiveActivityAlertIcon; use ActivitySmith\LiveActivityContentState; use ActivitySmith\LiveActivityMetric; use ActivitySmith\Metrics; @@ -533,6 +535,58 @@ public function testLiveActivitiesSupportStatsPayloads(): void ); } + public function testLiveActivitiesSupportAlertHelpers(): void + { + $captured = []; + $response = (object) ['success' => true]; + + $api = $this->getMockBuilder(LiveActivitiesApi::class) + ->disableOriginalConstructor() + ->onlyMethods(['reconcileLiveActivityStream']) + ->getMock(); + + $api->expects($this->once()) + ->method('reconcileLiveActivityStream') + ->willReturnCallback(function (...$args) use (&$captured, $response) { + $captured[] = $args; + return $response; + }); + + $resource = new LiveActivities($api); + $state = LiveActivityContentState::make( + title: 'Reactivation', + type: LiveActivities::TYPE_ALERT, + message: 'Lumen came back after 2 weeks', + icon: LiveActivityAlertIcon::make(symbol: 'sparkles', color: 'yellow'), + badge: LiveActivityAlertBadge::make(title: 'Customer', color: 'magenta'), + color: 'red' + ); + + $this->assertArrayNotHasKey('color', $state); + $this->assertSame( + $response, + $resource->stream('customer-ops', contentState: $state) + ); + $this->assertSame( + [ + [ + 'customer-ops', + [ + 'content_state' => [ + 'title' => 'Reactivation', + 'type' => LiveActivities::TYPE_ALERT, + 'message' => 'Lumen came back after 2 weeks', + 'icon' => ['symbol' => 'sparkles', 'color' => 'yellow'], + 'badge' => ['title' => 'Customer', 'color' => 'magenta'], + ], + ], + LiveActivitiesApi::contentTypes['reconcileLiveActivityStream'][0], + ], + ], + $captured + ); + } + public function testLiveActivitiesBuildRequestsFromNamedFields(): void { $response = (object) ['success' => true]; From 9ba1b88e6986a7574c730c678ef1ab1c171bd347 Mon Sep 17 00:00:00 2001 From: bardonadam Date: Wed, 27 May 2026 20:53:47 +0700 Subject: [PATCH 2/4] Prepare alert live activity helpers --- README.md | 37 +++++++++++++++++++++++++++++++- src/LiveActivities.php | 15 ------------- src/LiveActivityContentState.php | 2 +- src/Version.php | 2 +- tests/ResourcesTest.php | 6 +++--- tests/SmokeTest.php | 2 +- 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index fd06f0b..a33a1b9 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ declare(strict_types=1); use ActivitySmith\ActivitySmith; use ActivitySmith\LiveActivityAction; +use ActivitySmith\LiveActivityAlertBadge; +use ActivitySmith\LiveActivityAlertIcon; use ActivitySmith\LiveActivityContentState; use ActivitySmith\LiveActivityMetric; use ActivitySmith\PushAction; @@ -122,12 +124,13 @@ $activitysmith->notifications->send( ## Live Activities -There are four types of Live Activities: +There are five types of Live Activities: - `stats`: best for showing business numbers side by side, such as revenue, sales, new users, conversion, refunds, or any other value you want visible at a glance - `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate - `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs - `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads +- `alert`: best for status updates, such as feature adoption, reactivation, onboarding blockers, incidents, escalations, and other operational states ### Start & Update Live Activity @@ -232,6 +235,37 @@ $activitysmith->liveActivities->stream( ); ``` +#### Alert + +

+ Alert Live Activity stream example +

+ +```php +$activitysmith->liveActivities->stream( + 'customer-ops', + contentState: LiveActivityContentState::make( + title: 'Reactivation', + message: 'Lumen came back after 2 weeks', + type: 'alert', + icon: LiveActivityAlertIcon::make(symbol: 'cloud.sun', color: 'yellow'), + badge: LiveActivityAlertBadge::make(title: 'Customer', color: 'magenta'), + ), +); +``` + +The `icon` symbol value is an Apple SF Symbol name. Browse the catalog with one of these tools: + +- [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use +- [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app +- [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography + +`icon` and `badge` are optional. If you omit either one, that element is not shown in the Live Activity. + ### End Live Activity Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. By default, iOS removes the Live Activity after two minutes. Set `autoDismissMinutes` to choose a different dismissal time, including `0` for immediate dismissal. @@ -255,6 +289,7 @@ $activitysmith->liveActivities->endStream( ### Live Activity Action Live Activities can include one optional action button. Use it to open a URL from the Live Activity or trigger a backend webhook. +For alert Live Activities, set `color` on `LiveActivityContentState::make(...)` to tint the action button. Icon and badge colors only affect the icon and badge.

normalizeContentState($contentState); $existingContentState = $request['content_state'] ?? []; if (!is_array($existingContentState) || !is_array($contentState)) { throw new \InvalidArgumentException('ActivitySmith: content_state must be an array'); @@ -378,7 +377,6 @@ private function buildRequest(mixed $request, mixed $contentState, array $conten throw new \InvalidArgumentException('ActivitySmith: content_state must be an array'); } $request['content_state'] = array_merge($existingContentState, $contentStateFields); - $request['content_state'] = $this->normalizeContentState($request['content_state']); } if (array_key_exists('activity_id', $requestFields)) { @@ -390,17 +388,4 @@ private function buildRequest(mixed $request, mixed $contentState, array $conten return array_merge($request, $requestFields); } - - /** - * @param array $contentState - * @return array - */ - private function normalizeContentState(array $contentState): array - { - if (($contentState['type'] ?? null) === self::TYPE_ALERT) { - unset($contentState['color']); - } - - return $contentState; - } } diff --git a/src/LiveActivityContentState.php b/src/LiveActivityContentState.php index 413870e..1deafcf 100644 --- a/src/LiveActivityContentState.php +++ b/src/LiveActivityContentState.php @@ -41,7 +41,7 @@ public static function make( 'percentage' => $percentage, 'value' => $value, 'upper_limit' => $upperLimit, - 'color' => $type === LiveActivities::TYPE_ALERT ? null : $color, + 'color' => $color, 'step_color' => $stepColor, 'auto_dismiss_seconds' => $autoDismissSeconds, 'auto_dismiss_minutes' => $autoDismissMinutes, diff --git a/src/Version.php b/src/Version.php index 9e69166..b9dd0e3 100644 --- a/src/Version.php +++ b/src/Version.php @@ -6,7 +6,7 @@ final class Version { - public const VERSION = '1.4.1'; + public const VERSION = '1.5.0'; private function __construct() { diff --git a/tests/ResourcesTest.php b/tests/ResourcesTest.php index 598fa93..bb12200 100644 --- a/tests/ResourcesTest.php +++ b/tests/ResourcesTest.php @@ -557,12 +557,11 @@ public function testLiveActivitiesSupportAlertHelpers(): void title: 'Reactivation', type: LiveActivities::TYPE_ALERT, message: 'Lumen came back after 2 weeks', - icon: LiveActivityAlertIcon::make(symbol: 'sparkles', color: 'yellow'), + icon: LiveActivityAlertIcon::make(symbol: 'cloud.sun', color: 'yellow'), badge: LiveActivityAlertBadge::make(title: 'Customer', color: 'magenta'), color: 'red' ); - $this->assertArrayNotHasKey('color', $state); $this->assertSame( $response, $resource->stream('customer-ops', contentState: $state) @@ -576,8 +575,9 @@ public function testLiveActivitiesSupportAlertHelpers(): void 'title' => 'Reactivation', 'type' => LiveActivities::TYPE_ALERT, 'message' => 'Lumen came back after 2 weeks', - 'icon' => ['symbol' => 'sparkles', 'color' => 'yellow'], + 'icon' => ['symbol' => 'cloud.sun', 'color' => 'yellow'], 'badge' => ['title' => 'Customer', 'color' => 'magenta'], + 'color' => 'red', ], ], LiveActivitiesApi::contentTypes['reconcileLiveActivityStream'][0], diff --git a/tests/SmokeTest.php b/tests/SmokeTest.php index b00aa7a..5a2f77c 100644 --- a/tests/SmokeTest.php +++ b/tests/SmokeTest.php @@ -28,6 +28,6 @@ public function testClientConstructsWhenGeneratedCodeIsPresent(): void $this->assertTrue(method_exists($client->liveActivities, 'endStream')); $this->assertNotNull($client->metrics); $this->assertTrue(method_exists($client->metrics, 'update')); - $this->assertSame('1.4.1', Version::VERSION); + $this->assertSame('1.5.0', Version::VERSION); } } From 2790edc1d7ee1da5406dfb9b55b2149a9a721c3b Mon Sep 17 00:00:00 2001 From: activitysmith-bot Date: Wed, 27 May 2026 11:15:28 +0000 Subject: [PATCH 3/4] chore: regenerate SDK --- generated/Configuration.php | 4 +- generated/Model/ActivityMetric.php | 2 + generated/Model/ContentStateEnd.php | 125 +++++- generated/Model/ContentStateStart.php | 125 +++++- generated/Model/ContentStateUpdate.php | 125 +++++- generated/Model/LiveActivityAlertBadge.php | 456 +++++++++++++++++++++ generated/Model/LiveActivityAlertIcon.php | 456 +++++++++++++++++++++ generated/Model/LiveActivityColor.php | 86 ++++ generated/Model/StreamContentState.php | 125 +++++- 9 files changed, 1490 insertions(+), 14 deletions(-) create mode 100644 generated/Model/LiveActivityAlertBadge.php create mode 100644 generated/Model/LiveActivityAlertIcon.php create mode 100644 generated/Model/LiveActivityColor.php diff --git a/generated/Configuration.php b/generated/Configuration.php index ff17c89..86519c1 100644 --- a/generated/Configuration.php +++ b/generated/Configuration.php @@ -100,7 +100,7 @@ class Configuration * * @var string */ - protected $userAgent = 'OpenAPI-Generator/1.3.0/PHP'; + protected $userAgent = 'OpenAPI-Generator/1.4.1/PHP'; /** * Debug switch (default set to false) @@ -433,7 +433,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 1.3.0' . PHP_EOL; + $report .= ' SDK Package Version: 1.4.1' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; diff --git a/generated/Model/ActivityMetric.php b/generated/Model/ActivityMetric.php index 1d8c1c6..abae08c 100644 --- a/generated/Model/ActivityMetric.php +++ b/generated/Model/ActivityMetric.php @@ -255,6 +255,7 @@ public function getModelName() public const COLOR_RED = 'red'; public const COLOR_ORANGE = 'orange'; public const COLOR_YELLOW = 'yellow'; + public const COLOR_GRAY = 'gray'; /** * Gets allowable values of the enum @@ -273,6 +274,7 @@ public function getColorAllowableValues() self::COLOR_RED, self::COLOR_ORANGE, self::COLOR_YELLOW, + self::COLOR_GRAY, ]; } diff --git a/generated/Model/ContentStateEnd.php b/generated/Model/ContentStateEnd.php index e16eae8..d67b060 100644 --- a/generated/Model/ContentStateEnd.php +++ b/generated/Model/ContentStateEnd.php @@ -35,7 +35,7 @@ * ContentStateEnd Class Doc Comment * * @category Class - * @description 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. + * @description 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. For alert include message, with optional icon and badge. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start. * @package ActivitySmith\Generated * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -66,6 +66,9 @@ class ContentStateEnd implements ModelInterface, ArrayAccess, \JsonSerializable 'value' => 'float', 'upperLimit' => 'float', 'metrics' => '\ActivitySmith\Generated\Model\ActivityMetric[]', + 'message' => 'string', + 'icon' => '\ActivitySmith\Generated\Model\LiveActivityAlertIcon', + 'badge' => '\ActivitySmith\Generated\Model\LiveActivityAlertBadge', 'type' => 'string', 'color' => 'string', 'stepColor' => 'string', @@ -89,6 +92,9 @@ class ContentStateEnd implements ModelInterface, ArrayAccess, \JsonSerializable 'value' => null, 'upperLimit' => null, 'metrics' => null, + 'message' => null, + 'icon' => null, + 'badge' => null, 'type' => null, 'color' => null, 'stepColor' => null, @@ -110,6 +116,9 @@ class ContentStateEnd implements ModelInterface, ArrayAccess, \JsonSerializable 'value' => false, 'upperLimit' => false, 'metrics' => false, + 'message' => false, + 'icon' => false, + 'badge' => false, 'type' => false, 'color' => false, 'stepColor' => false, @@ -211,6 +220,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'value', 'upperLimit' => 'upper_limit', 'metrics' => 'metrics', + 'message' => 'message', + 'icon' => 'icon', + 'badge' => 'badge', 'type' => 'type', 'color' => 'color', 'stepColor' => 'step_color', @@ -232,6 +244,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'setValue', 'upperLimit' => 'setUpperLimit', 'metrics' => 'setMetrics', + 'message' => 'setMessage', + 'icon' => 'setIcon', + 'badge' => 'setBadge', 'type' => 'setType', 'color' => 'setColor', 'stepColor' => 'setStepColor', @@ -253,6 +268,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'getValue', 'upperLimit' => 'getUpperLimit', 'metrics' => 'getMetrics', + 'message' => 'getMessage', + 'icon' => 'getIcon', + 'badge' => 'getBadge', 'type' => 'getType', 'color' => 'getColor', 'stepColor' => 'getStepColor', @@ -305,6 +323,7 @@ public function getModelName() public const TYPE_PROGRESS = 'progress'; public const TYPE_METRICS = 'metrics'; public const TYPE_STATS = 'stats'; + public const TYPE_ALERT = 'alert'; public const COLOR_LIME = 'lime'; public const COLOR_GREEN = 'green'; public const COLOR_CYAN = 'cyan'; @@ -314,6 +333,7 @@ public function getModelName() public const COLOR_RED = 'red'; public const COLOR_ORANGE = 'orange'; public const COLOR_YELLOW = 'yellow'; + public const COLOR_GRAY = 'gray'; public const STEP_COLOR_LIME = 'lime'; public const STEP_COLOR_GREEN = 'green'; public const STEP_COLOR_CYAN = 'cyan'; @@ -323,6 +343,7 @@ public function getModelName() public const STEP_COLOR_RED = 'red'; public const STEP_COLOR_ORANGE = 'orange'; public const STEP_COLOR_YELLOW = 'yellow'; + public const STEP_COLOR_GRAY = 'gray'; public const STEP_COLORS_LIME = 'lime'; public const STEP_COLORS_GREEN = 'green'; public const STEP_COLORS_CYAN = 'cyan'; @@ -332,6 +353,7 @@ public function getModelName() public const STEP_COLORS_RED = 'red'; public const STEP_COLORS_ORANGE = 'orange'; public const STEP_COLORS_YELLOW = 'yellow'; + public const STEP_COLORS_GRAY = 'gray'; /** * Gets allowable values of the enum @@ -345,6 +367,7 @@ public function getTypeAllowableValues() self::TYPE_PROGRESS, self::TYPE_METRICS, self::TYPE_STATS, + self::TYPE_ALERT, ]; } @@ -365,6 +388,7 @@ public function getColorAllowableValues() self::COLOR_RED, self::COLOR_ORANGE, self::COLOR_YELLOW, + self::COLOR_GRAY, ]; } @@ -385,6 +409,7 @@ public function getStepColorAllowableValues() self::STEP_COLOR_RED, self::STEP_COLOR_ORANGE, self::STEP_COLOR_YELLOW, + self::STEP_COLOR_GRAY, ]; } @@ -405,6 +430,7 @@ public function getStepColorsAllowableValues() self::STEP_COLORS_RED, self::STEP_COLORS_ORANGE, self::STEP_COLORS_YELLOW, + self::STEP_COLORS_GRAY, ]; } @@ -431,8 +457,11 @@ public function __construct(array $data = null) $this->setIfExists('value', $data ?? [], null); $this->setIfExists('upperLimit', $data ?? [], null); $this->setIfExists('metrics', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('icon', $data ?? [], null); + $this->setIfExists('badge', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('color', $data ?? [], 'blue'); + $this->setIfExists('color', $data ?? [], null); $this->setIfExists('stepColor', $data ?? [], null); $this->setIfExists('stepColors', $data ?? [], null); $this->setIfExists('autoDismissMinutes', $data ?? [], 3); @@ -492,6 +521,10 @@ public function listInvalidProperties() $invalidProperties[] = "invalid value for 'metrics', number of items must be greater than or equal to 1."; } + if (!is_null($this->container['message']) && (mb_strlen($this->container['message']) < 1)) { + $invalidProperties[] = "invalid value for 'message', the character length must be bigger than or equal to 1."; + } + $allowedValues = $this->getTypeAllowableValues(); if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { $invalidProperties[] = sprintf( @@ -779,6 +812,92 @@ public function setMetrics($metrics) return $this; } + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Alert message. Use for type=alert. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + + if ((mb_strlen($message) < 1)) { + throw new \InvalidArgumentException('invalid length for $message when calling ContentStateEnd., must be bigger than or equal to 1.'); + } + + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets icon + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null + */ + public function getIcon() + { + return $this->container['icon']; + } + + /** + * Sets icon + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null $icon Optional SF Symbol icon for type=alert. + * + * @return self + */ + public function setIcon($icon) + { + if (is_null($icon)) { + throw new \InvalidArgumentException('non-nullable icon cannot be null'); + } + $this->container['icon'] = $icon; + + return $this; + } + + /** + * Gets badge + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null + */ + public function getBadge() + { + return $this->container['badge']; + } + + /** + * Sets badge + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null $badge Optional badge for type=alert. + * + * @return self + */ + public function setBadge($badge) + { + if (is_null($badge)) { + throw new \InvalidArgumentException('non-nullable badge cannot be null'); + } + $this->container['badge'] = $badge; + + return $this; + } + /** * Gets type * @@ -829,7 +948,7 @@ public function getColor() /** * Sets color * - * @param string|null $color Optional. Accent color for the Live Activity. Defaults to blue. + * @param string|null $color Optional. Accent color for progress, segmented_progress, and metrics Live Activities. For alert Live Activities, this tints the action button when action is included. * * @return self */ diff --git a/generated/Model/ContentStateStart.php b/generated/Model/ContentStateStart.php index efbe68a..9c04be3 100644 --- a/generated/Model/ContentStateStart.php +++ b/generated/Model/ContentStateStart.php @@ -35,7 +35,7 @@ * ContentStateStart Class Doc Comment * * @category Class - * @description 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. + * @description 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 alert include message, with optional icon and badge. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls. * @package ActivitySmith\Generated * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -66,6 +66,9 @@ class ContentStateStart implements ModelInterface, ArrayAccess, \JsonSerializabl 'value' => 'float', 'upperLimit' => 'float', 'metrics' => '\ActivitySmith\Generated\Model\ActivityMetric[]', + 'message' => 'string', + 'icon' => '\ActivitySmith\Generated\Model\LiveActivityAlertIcon', + 'badge' => '\ActivitySmith\Generated\Model\LiveActivityAlertBadge', 'type' => 'string', 'color' => 'string', 'stepColor' => 'string', @@ -88,6 +91,9 @@ class ContentStateStart implements ModelInterface, ArrayAccess, \JsonSerializabl 'value' => null, 'upperLimit' => null, 'metrics' => null, + 'message' => null, + 'icon' => null, + 'badge' => null, 'type' => null, 'color' => null, 'stepColor' => null, @@ -108,6 +114,9 @@ class ContentStateStart implements ModelInterface, ArrayAccess, \JsonSerializabl 'value' => false, 'upperLimit' => false, 'metrics' => false, + 'message' => false, + 'icon' => false, + 'badge' => false, 'type' => false, 'color' => false, 'stepColor' => false, @@ -208,6 +217,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'value', 'upperLimit' => 'upper_limit', 'metrics' => 'metrics', + 'message' => 'message', + 'icon' => 'icon', + 'badge' => 'badge', 'type' => 'type', 'color' => 'color', 'stepColor' => 'step_color', @@ -228,6 +240,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'setValue', 'upperLimit' => 'setUpperLimit', 'metrics' => 'setMetrics', + 'message' => 'setMessage', + 'icon' => 'setIcon', + 'badge' => 'setBadge', 'type' => 'setType', 'color' => 'setColor', 'stepColor' => 'setStepColor', @@ -248,6 +263,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'getValue', 'upperLimit' => 'getUpperLimit', 'metrics' => 'getMetrics', + 'message' => 'getMessage', + 'icon' => 'getIcon', + 'badge' => 'getBadge', 'type' => 'getType', 'color' => 'getColor', 'stepColor' => 'getStepColor', @@ -299,6 +317,7 @@ public function getModelName() public const TYPE_PROGRESS = 'progress'; public const TYPE_METRICS = 'metrics'; public const TYPE_STATS = 'stats'; + public const TYPE_ALERT = 'alert'; public const COLOR_LIME = 'lime'; public const COLOR_GREEN = 'green'; public const COLOR_CYAN = 'cyan'; @@ -308,6 +327,7 @@ public function getModelName() public const COLOR_RED = 'red'; public const COLOR_ORANGE = 'orange'; public const COLOR_YELLOW = 'yellow'; + public const COLOR_GRAY = 'gray'; public const STEP_COLOR_LIME = 'lime'; public const STEP_COLOR_GREEN = 'green'; public const STEP_COLOR_CYAN = 'cyan'; @@ -317,6 +337,7 @@ public function getModelName() public const STEP_COLOR_RED = 'red'; public const STEP_COLOR_ORANGE = 'orange'; public const STEP_COLOR_YELLOW = 'yellow'; + public const STEP_COLOR_GRAY = 'gray'; public const STEP_COLORS_LIME = 'lime'; public const STEP_COLORS_GREEN = 'green'; public const STEP_COLORS_CYAN = 'cyan'; @@ -326,6 +347,7 @@ public function getModelName() public const STEP_COLORS_RED = 'red'; public const STEP_COLORS_ORANGE = 'orange'; public const STEP_COLORS_YELLOW = 'yellow'; + public const STEP_COLORS_GRAY = 'gray'; /** * Gets allowable values of the enum @@ -339,6 +361,7 @@ public function getTypeAllowableValues() self::TYPE_PROGRESS, self::TYPE_METRICS, self::TYPE_STATS, + self::TYPE_ALERT, ]; } @@ -359,6 +382,7 @@ public function getColorAllowableValues() self::COLOR_RED, self::COLOR_ORANGE, self::COLOR_YELLOW, + self::COLOR_GRAY, ]; } @@ -379,6 +403,7 @@ public function getStepColorAllowableValues() self::STEP_COLOR_RED, self::STEP_COLOR_ORANGE, self::STEP_COLOR_YELLOW, + self::STEP_COLOR_GRAY, ]; } @@ -399,6 +424,7 @@ public function getStepColorsAllowableValues() self::STEP_COLORS_RED, self::STEP_COLORS_ORANGE, self::STEP_COLORS_YELLOW, + self::STEP_COLORS_GRAY, ]; } @@ -425,8 +451,11 @@ public function __construct(array $data = null) $this->setIfExists('value', $data ?? [], null); $this->setIfExists('upperLimit', $data ?? [], null); $this->setIfExists('metrics', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('icon', $data ?? [], null); + $this->setIfExists('badge', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('color', $data ?? [], 'blue'); + $this->setIfExists('color', $data ?? [], null); $this->setIfExists('stepColor', $data ?? [], null); $this->setIfExists('stepColors', $data ?? [], null); } @@ -485,6 +514,10 @@ public function listInvalidProperties() $invalidProperties[] = "invalid value for 'metrics', number of items must be greater than or equal to 1."; } + if (!is_null($this->container['message']) && (mb_strlen($this->container['message']) < 1)) { + $invalidProperties[] = "invalid value for 'message', the character length must be bigger than or equal to 1."; + } + if ($this->container['type'] === null) { $invalidProperties[] = "'type' can't be null"; } @@ -771,6 +804,92 @@ public function setMetrics($metrics) return $this; } + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Required for type=alert. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + + if ((mb_strlen($message) < 1)) { + throw new \InvalidArgumentException('invalid length for $message when calling ContentStateStart., must be bigger than or equal to 1.'); + } + + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets icon + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null + */ + public function getIcon() + { + return $this->container['icon']; + } + + /** + * Sets icon + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null $icon Optional SF Symbol icon for type=alert. + * + * @return self + */ + public function setIcon($icon) + { + if (is_null($icon)) { + throw new \InvalidArgumentException('non-nullable icon cannot be null'); + } + $this->container['icon'] = $icon; + + return $this; + } + + /** + * Gets badge + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null + */ + public function getBadge() + { + return $this->container['badge']; + } + + /** + * Sets badge + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null $badge Optional badge for type=alert. + * + * @return self + */ + public function setBadge($badge) + { + if (is_null($badge)) { + throw new \InvalidArgumentException('non-nullable badge cannot be null'); + } + $this->container['badge'] = $badge; + + return $this; + } + /** * Gets type * @@ -821,7 +940,7 @@ public function getColor() /** * Sets color * - * @param string|null $color Optional. Accent color for the Live Activity. Defaults to blue. + * @param string|null $color Optional. Accent color for progress, segmented_progress, and metrics Live Activities. For alert Live Activities, this tints the action button when action is included. * * @return self */ diff --git a/generated/Model/ContentStateUpdate.php b/generated/Model/ContentStateUpdate.php index d64088e..766816d 100644 --- a/generated/Model/ContentStateUpdate.php +++ b/generated/Model/ContentStateUpdate.php @@ -35,7 +35,7 @@ * ContentStateUpdate Class Doc Comment * * @category Class - * @description 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. + * @description 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. For alert include message, with optional icon and badge. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates. * @package ActivitySmith\Generated * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -66,6 +66,9 @@ class ContentStateUpdate implements ModelInterface, ArrayAccess, \JsonSerializab 'value' => 'float', 'upperLimit' => 'float', 'metrics' => '\ActivitySmith\Generated\Model\ActivityMetric[]', + 'message' => 'string', + 'icon' => '\ActivitySmith\Generated\Model\LiveActivityAlertIcon', + 'badge' => '\ActivitySmith\Generated\Model\LiveActivityAlertBadge', 'type' => 'string', 'color' => 'string', 'stepColor' => 'string', @@ -88,6 +91,9 @@ class ContentStateUpdate implements ModelInterface, ArrayAccess, \JsonSerializab 'value' => null, 'upperLimit' => null, 'metrics' => null, + 'message' => null, + 'icon' => null, + 'badge' => null, 'type' => null, 'color' => null, 'stepColor' => null, @@ -108,6 +114,9 @@ class ContentStateUpdate implements ModelInterface, ArrayAccess, \JsonSerializab 'value' => false, 'upperLimit' => false, 'metrics' => false, + 'message' => false, + 'icon' => false, + 'badge' => false, 'type' => false, 'color' => false, 'stepColor' => false, @@ -208,6 +217,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'value', 'upperLimit' => 'upper_limit', 'metrics' => 'metrics', + 'message' => 'message', + 'icon' => 'icon', + 'badge' => 'badge', 'type' => 'type', 'color' => 'color', 'stepColor' => 'step_color', @@ -228,6 +240,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'setValue', 'upperLimit' => 'setUpperLimit', 'metrics' => 'setMetrics', + 'message' => 'setMessage', + 'icon' => 'setIcon', + 'badge' => 'setBadge', 'type' => 'setType', 'color' => 'setColor', 'stepColor' => 'setStepColor', @@ -248,6 +263,9 @@ public function isNullableSetToNull(string $property): bool 'value' => 'getValue', 'upperLimit' => 'getUpperLimit', 'metrics' => 'getMetrics', + 'message' => 'getMessage', + 'icon' => 'getIcon', + 'badge' => 'getBadge', 'type' => 'getType', 'color' => 'getColor', 'stepColor' => 'getStepColor', @@ -299,6 +317,7 @@ public function getModelName() public const TYPE_PROGRESS = 'progress'; public const TYPE_METRICS = 'metrics'; public const TYPE_STATS = 'stats'; + public const TYPE_ALERT = 'alert'; public const COLOR_LIME = 'lime'; public const COLOR_GREEN = 'green'; public const COLOR_CYAN = 'cyan'; @@ -308,6 +327,7 @@ public function getModelName() public const COLOR_RED = 'red'; public const COLOR_ORANGE = 'orange'; public const COLOR_YELLOW = 'yellow'; + public const COLOR_GRAY = 'gray'; public const STEP_COLOR_LIME = 'lime'; public const STEP_COLOR_GREEN = 'green'; public const STEP_COLOR_CYAN = 'cyan'; @@ -317,6 +337,7 @@ public function getModelName() public const STEP_COLOR_RED = 'red'; public const STEP_COLOR_ORANGE = 'orange'; public const STEP_COLOR_YELLOW = 'yellow'; + public const STEP_COLOR_GRAY = 'gray'; public const STEP_COLORS_LIME = 'lime'; public const STEP_COLORS_GREEN = 'green'; public const STEP_COLORS_CYAN = 'cyan'; @@ -326,6 +347,7 @@ public function getModelName() public const STEP_COLORS_RED = 'red'; public const STEP_COLORS_ORANGE = 'orange'; public const STEP_COLORS_YELLOW = 'yellow'; + public const STEP_COLORS_GRAY = 'gray'; /** * Gets allowable values of the enum @@ -339,6 +361,7 @@ public function getTypeAllowableValues() self::TYPE_PROGRESS, self::TYPE_METRICS, self::TYPE_STATS, + self::TYPE_ALERT, ]; } @@ -359,6 +382,7 @@ public function getColorAllowableValues() self::COLOR_RED, self::COLOR_ORANGE, self::COLOR_YELLOW, + self::COLOR_GRAY, ]; } @@ -379,6 +403,7 @@ public function getStepColorAllowableValues() self::STEP_COLOR_RED, self::STEP_COLOR_ORANGE, self::STEP_COLOR_YELLOW, + self::STEP_COLOR_GRAY, ]; } @@ -399,6 +424,7 @@ public function getStepColorsAllowableValues() self::STEP_COLORS_RED, self::STEP_COLORS_ORANGE, self::STEP_COLORS_YELLOW, + self::STEP_COLORS_GRAY, ]; } @@ -425,8 +451,11 @@ public function __construct(array $data = null) $this->setIfExists('value', $data ?? [], null); $this->setIfExists('upperLimit', $data ?? [], null); $this->setIfExists('metrics', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('icon', $data ?? [], null); + $this->setIfExists('badge', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('color', $data ?? [], 'blue'); + $this->setIfExists('color', $data ?? [], null); $this->setIfExists('stepColor', $data ?? [], null); $this->setIfExists('stepColors', $data ?? [], null); } @@ -485,6 +514,10 @@ public function listInvalidProperties() $invalidProperties[] = "invalid value for 'metrics', number of items must be greater than or equal to 1."; } + if (!is_null($this->container['message']) && (mb_strlen($this->container['message']) < 1)) { + $invalidProperties[] = "invalid value for 'message', the character length must be bigger than or equal to 1."; + } + $allowedValues = $this->getTypeAllowableValues(); if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { $invalidProperties[] = sprintf( @@ -768,6 +801,92 @@ public function setMetrics($metrics) return $this; } + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Alert message. Use for type=alert. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + + if ((mb_strlen($message) < 1)) { + throw new \InvalidArgumentException('invalid length for $message when calling ContentStateUpdate., must be bigger than or equal to 1.'); + } + + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets icon + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null + */ + public function getIcon() + { + return $this->container['icon']; + } + + /** + * Sets icon + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null $icon Optional SF Symbol icon for type=alert. + * + * @return self + */ + public function setIcon($icon) + { + if (is_null($icon)) { + throw new \InvalidArgumentException('non-nullable icon cannot be null'); + } + $this->container['icon'] = $icon; + + return $this; + } + + /** + * Gets badge + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null + */ + public function getBadge() + { + return $this->container['badge']; + } + + /** + * Sets badge + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null $badge Optional badge for type=alert. + * + * @return self + */ + public function setBadge($badge) + { + if (is_null($badge)) { + throw new \InvalidArgumentException('non-nullable badge cannot be null'); + } + $this->container['badge'] = $badge; + + return $this; + } + /** * Gets type * @@ -818,7 +937,7 @@ public function getColor() /** * Sets color * - * @param string|null $color Optional. Accent color for the Live Activity. Defaults to blue. + * @param string|null $color Optional. Accent color for progress, segmented_progress, and metrics Live Activities. For alert Live Activities, this tints the action button when action is included. * * @return self */ diff --git a/generated/Model/LiveActivityAlertBadge.php b/generated/Model/LiveActivityAlertBadge.php new file mode 100644 index 0000000..63c0737 --- /dev/null +++ b/generated/Model/LiveActivityAlertBadge.php @@ -0,0 +1,456 @@ + + */ +class LiveActivityAlertBadge implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'LiveActivityAlertBadge'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'title' => 'string', + 'color' => '\ActivitySmith\Generated\Model\LiveActivityColor' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'title' => null, + 'color' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'title' => false, + 'color' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'title' => 'title', + 'color' => 'color' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'title' => 'setTitle', + 'color' => 'setColor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'title' => 'getTitle', + 'color' => 'getColor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('color', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['title'] === null) { + $invalidProperties[] = "'title' can't be null"; + } + if ((mb_strlen($this->container['title']) < 1)) { + $invalidProperties[] = "invalid value for 'title', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets title + * + * @return string + */ + public function getTitle() + { + return $this->container['title']; + } + + /** + * Sets title + * + * @param string $title title + * + * @return self + */ + public function setTitle($title) + { + if (is_null($title)) { + throw new \InvalidArgumentException('non-nullable title cannot be null'); + } + + if ((mb_strlen($title) < 1)) { + throw new \InvalidArgumentException('invalid length for $title when calling LiveActivityAlertBadge., must be bigger than or equal to 1.'); + } + + $this->container['title'] = $title; + + return $this; + } + + /** + * Gets color + * + * @return \ActivitySmith\Generated\Model\LiveActivityColor|null + */ + public function getColor() + { + return $this->container['color']; + } + + /** + * Sets color + * + * @param \ActivitySmith\Generated\Model\LiveActivityColor|null $color Optional badge color. + * + * @return self + */ + public function setColor($color) + { + if (is_null($color)) { + throw new \InvalidArgumentException('non-nullable color cannot be null'); + } + $this->container['color'] = $color; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/generated/Model/LiveActivityAlertIcon.php b/generated/Model/LiveActivityAlertIcon.php new file mode 100644 index 0000000..0e8acfe --- /dev/null +++ b/generated/Model/LiveActivityAlertIcon.php @@ -0,0 +1,456 @@ + + */ +class LiveActivityAlertIcon implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'LiveActivityAlertIcon'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'symbol' => 'string', + 'color' => '\ActivitySmith\Generated\Model\LiveActivityColor' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'symbol' => null, + 'color' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'symbol' => false, + 'color' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'symbol' => 'symbol', + 'color' => 'color' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'symbol' => 'setSymbol', + 'color' => 'setColor' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'symbol' => 'getSymbol', + 'color' => 'getColor' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('symbol', $data ?? [], null); + $this->setIfExists('color', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['symbol'] === null) { + $invalidProperties[] = "'symbol' can't be null"; + } + if ((mb_strlen($this->container['symbol']) < 1)) { + $invalidProperties[] = "invalid value for 'symbol', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets symbol + * + * @return string + */ + public function getSymbol() + { + return $this->container['symbol']; + } + + /** + * Sets symbol + * + * @param string $symbol Apple SF Symbol name. + * + * @return self + */ + public function setSymbol($symbol) + { + if (is_null($symbol)) { + throw new \InvalidArgumentException('non-nullable symbol cannot be null'); + } + + if ((mb_strlen($symbol) < 1)) { + throw new \InvalidArgumentException('invalid length for $symbol when calling LiveActivityAlertIcon., must be bigger than or equal to 1.'); + } + + $this->container['symbol'] = $symbol; + + return $this; + } + + /** + * Gets color + * + * @return \ActivitySmith\Generated\Model\LiveActivityColor|null + */ + public function getColor() + { + return $this->container['color']; + } + + /** + * Sets color + * + * @param \ActivitySmith\Generated\Model\LiveActivityColor|null $color Optional icon color. + * + * @return self + */ + public function setColor($color) + { + if (is_null($color)) { + throw new \InvalidArgumentException('non-nullable color cannot be null'); + } + $this->container['color'] = $color; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/generated/Model/LiveActivityColor.php b/generated/Model/LiveActivityColor.php new file mode 100644 index 0000000..3610f50 --- /dev/null +++ b/generated/Model/LiveActivityColor.php @@ -0,0 +1,86 @@ + 'string', 'stepColors' => 'string[]', 'metrics' => '\ActivitySmith\Generated\Model\ActivityMetric[]', + 'message' => 'string', + 'icon' => '\ActivitySmith\Generated\Model\LiveActivityAlertIcon', + 'badge' => '\ActivitySmith\Generated\Model\LiveActivityAlertBadge', 'autoDismissSeconds' => 'int', 'autoDismissMinutes' => 'int' ]; @@ -94,6 +97,9 @@ class StreamContentState implements ModelInterface, ArrayAccess, \JsonSerializab 'stepColor' => null, 'stepColors' => null, 'metrics' => null, + 'message' => null, + 'icon' => null, + 'badge' => null, 'autoDismissSeconds' => null, 'autoDismissMinutes' => null ]; @@ -116,6 +122,9 @@ class StreamContentState implements ModelInterface, ArrayAccess, \JsonSerializab 'stepColor' => false, 'stepColors' => false, 'metrics' => false, + 'message' => false, + 'icon' => false, + 'badge' => false, 'autoDismissSeconds' => false, 'autoDismissMinutes' => false ]; @@ -218,6 +227,9 @@ public function isNullableSetToNull(string $property): bool 'stepColor' => 'step_color', 'stepColors' => 'step_colors', 'metrics' => 'metrics', + 'message' => 'message', + 'icon' => 'icon', + 'badge' => 'badge', 'autoDismissSeconds' => 'auto_dismiss_seconds', 'autoDismissMinutes' => 'auto_dismiss_minutes' ]; @@ -240,6 +252,9 @@ public function isNullableSetToNull(string $property): bool 'stepColor' => 'setStepColor', 'stepColors' => 'setStepColors', 'metrics' => 'setMetrics', + 'message' => 'setMessage', + 'icon' => 'setIcon', + 'badge' => 'setBadge', 'autoDismissSeconds' => 'setAutoDismissSeconds', 'autoDismissMinutes' => 'setAutoDismissMinutes' ]; @@ -262,6 +277,9 @@ public function isNullableSetToNull(string $property): bool 'stepColor' => 'getStepColor', 'stepColors' => 'getStepColors', 'metrics' => 'getMetrics', + 'message' => 'getMessage', + 'icon' => 'getIcon', + 'badge' => 'getBadge', 'autoDismissSeconds' => 'getAutoDismissSeconds', 'autoDismissMinutes' => 'getAutoDismissMinutes' ]; @@ -311,6 +329,7 @@ public function getModelName() public const TYPE_PROGRESS = 'progress'; public const TYPE_METRICS = 'metrics'; public const TYPE_STATS = 'stats'; + public const TYPE_ALERT = 'alert'; public const COLOR_LIME = 'lime'; public const COLOR_GREEN = 'green'; public const COLOR_CYAN = 'cyan'; @@ -320,6 +339,7 @@ public function getModelName() public const COLOR_RED = 'red'; public const COLOR_ORANGE = 'orange'; public const COLOR_YELLOW = 'yellow'; + public const COLOR_GRAY = 'gray'; public const STEP_COLOR_LIME = 'lime'; public const STEP_COLOR_GREEN = 'green'; public const STEP_COLOR_CYAN = 'cyan'; @@ -329,6 +349,7 @@ public function getModelName() public const STEP_COLOR_RED = 'red'; public const STEP_COLOR_ORANGE = 'orange'; public const STEP_COLOR_YELLOW = 'yellow'; + public const STEP_COLOR_GRAY = 'gray'; public const STEP_COLORS_LIME = 'lime'; public const STEP_COLORS_GREEN = 'green'; public const STEP_COLORS_CYAN = 'cyan'; @@ -338,6 +359,7 @@ public function getModelName() public const STEP_COLORS_RED = 'red'; public const STEP_COLORS_ORANGE = 'orange'; public const STEP_COLORS_YELLOW = 'yellow'; + public const STEP_COLORS_GRAY = 'gray'; /** * Gets allowable values of the enum @@ -351,6 +373,7 @@ public function getTypeAllowableValues() self::TYPE_PROGRESS, self::TYPE_METRICS, self::TYPE_STATS, + self::TYPE_ALERT, ]; } @@ -371,6 +394,7 @@ public function getColorAllowableValues() self::COLOR_RED, self::COLOR_ORANGE, self::COLOR_YELLOW, + self::COLOR_GRAY, ]; } @@ -391,6 +415,7 @@ public function getStepColorAllowableValues() self::STEP_COLOR_RED, self::STEP_COLOR_ORANGE, self::STEP_COLOR_YELLOW, + self::STEP_COLOR_GRAY, ]; } @@ -411,6 +436,7 @@ public function getStepColorsAllowableValues() self::STEP_COLORS_RED, self::STEP_COLORS_ORANGE, self::STEP_COLORS_YELLOW, + self::STEP_COLORS_GRAY, ]; } @@ -437,10 +463,13 @@ public function __construct(array $data = null) $this->setIfExists('value', $data ?? [], null); $this->setIfExists('upperLimit', $data ?? [], null); $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('color', $data ?? [], 'blue'); + $this->setIfExists('color', $data ?? [], null); $this->setIfExists('stepColor', $data ?? [], null); $this->setIfExists('stepColors', $data ?? [], null); $this->setIfExists('metrics', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('icon', $data ?? [], null); + $this->setIfExists('badge', $data ?? [], null); $this->setIfExists('autoDismissSeconds', $data ?? [], null); $this->setIfExists('autoDismissMinutes', $data ?? [], null); } @@ -526,6 +555,10 @@ public function listInvalidProperties() $invalidProperties[] = "invalid value for 'metrics', number of items must be greater than or equal to 1."; } + if (!is_null($this->container['message']) && (mb_strlen($this->container['message']) < 1)) { + $invalidProperties[] = "invalid value for 'message', the character length must be bigger than or equal to 1."; + } + if (!is_null($this->container['autoDismissSeconds']) && ($this->container['autoDismissSeconds'] < 0)) { $invalidProperties[] = "invalid value for 'autoDismissSeconds', must be bigger than or equal to 0."; } @@ -806,7 +839,7 @@ public function getColor() /** * Sets color * - * @param string|null $color Optional. Accent color for the Live Activity. Defaults to blue. + * @param string|null $color Optional. Accent color for progress, segmented_progress, and metrics Live Activities. For alert Live Activities, this tints the action button when action is included. * * @return self */ @@ -937,6 +970,92 @@ public function setMetrics($metrics) return $this; } + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Required for type=alert. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + + if ((mb_strlen($message) < 1)) { + throw new \InvalidArgumentException('invalid length for $message when calling StreamContentState., must be bigger than or equal to 1.'); + } + + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets icon + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null + */ + public function getIcon() + { + return $this->container['icon']; + } + + /** + * Sets icon + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null $icon Optional SF Symbol icon for type=alert. + * + * @return self + */ + public function setIcon($icon) + { + if (is_null($icon)) { + throw new \InvalidArgumentException('non-nullable icon cannot be null'); + } + $this->container['icon'] = $icon; + + return $this; + } + + /** + * Gets badge + * + * @return \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null + */ + public function getBadge() + { + return $this->container['badge']; + } + + /** + * Sets badge + * + * @param \ActivitySmith\Generated\Model\LiveActivityAlertBadge|null $badge Optional badge for type=alert. + * + * @return self + */ + public function setBadge($badge) + { + if (is_null($badge)) { + throw new \InvalidArgumentException('non-nullable badge cannot be null'); + } + $this->container['badge'] = $badge; + + return $this; + } + /** * Gets autoDismissSeconds * From 74e8c697e179d0e58ee0a0caa5d911ced7590f28 Mon Sep 17 00:00:00 2001 From: bardonadam Date: Thu, 28 May 2026 15:34:40 +0700 Subject: [PATCH 4/4] docs: title-case Alert Live Activity references Why: - Alert Live Activity should use product-style casing in SDK docs and generated API comments. How: - Update README wording and generated OpenAPI-derived descriptions from alert Live Activities to Alert Live Activities. Verification: - git diff --check Initiated-by: user Implemented-by: codex --- README.md | 2 +- generated/Model/ContentStateEnd.php | 2 +- generated/Model/ContentStateStart.php | 2 +- generated/Model/ContentStateUpdate.php | 2 +- generated/Model/LiveActivityAlertBadge.php | 2 +- generated/Model/LiveActivityAlertIcon.php | 2 +- generated/Model/StreamContentState.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a33a1b9..4512559 100644 --- a/README.md +++ b/README.md @@ -289,7 +289,7 @@ $activitysmith->liveActivities->endStream( ### Live Activity Action Live Activities can include one optional action button. Use it to open a URL from the Live Activity or trigger a backend webhook. -For alert Live Activities, set `color` on `LiveActivityContentState::make(...)` to tint the action button. Icon and badge colors only affect the icon and badge. +For Alert Live Activities, set `color` on `LiveActivityContentState::make(...)` to tint the action button. Icon and badge colors only affect the icon and badge.