diff --git a/CHANGELOG.md b/CHANGELOG.md index 9485214..0118f44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.10.0 + +### New Features + +- **New Feature: Tags** — Organize and filter your Push Notification and Live Activity history using one or more tags. + ## 1.9.0 ### New Features diff --git a/README.md b/README.md index d4f8de5..d14098a 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ See [API reference](https://activitysmith.com/docs/api-reference/introduction). - [Widgets](#widgets) - [App Icon Badge Count](#app-icon-badge-count) - [Channels](#channels) +- [Tags](#tags) ## Installation @@ -589,6 +590,18 @@ $activitysmith->liveActivities->start( $activitysmith->badgeCount(3, channels: ['sales', 'customer-success']); ``` +## Tags + +Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them. + +```php +$activitysmith->notifications->send( + title: 'New subscription 💸', + message: 'Customer upgraded to Pro plan', + tags: ['user:382', 'billing'], +); +``` + ## Error Handling ```php diff --git a/generated/Api/AppIconBadgesApi.php b/generated/Api/AppIconBadgesApi.php index 1738c0d..2260dd3 100644 --- a/generated/Api/AppIconBadgesApi.php +++ b/generated/Api/AppIconBadgesApi.php @@ -125,7 +125,7 @@ public function getConfig() /** * Operation updateAppIconBadgeCount * - * Update App Icon Badge Count + * Set App Icon Badge Count * * @param \ActivitySmith\Generated\Model\AppIconBadgeCountUpdateRequest $appIconBadgeCountUpdateRequest appIconBadgeCountUpdateRequest (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateAppIconBadgeCount'] to see the possible values for this operation @@ -143,7 +143,7 @@ public function updateAppIconBadgeCount($appIconBadgeCountUpdateRequest, string /** * Operation updateAppIconBadgeCountWithHttpInfo * - * Update App Icon Badge Count + * Set App Icon Badge Count * * @param \ActivitySmith\Generated\Model\AppIconBadgeCountUpdateRequest $appIconBadgeCountUpdateRequest (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateAppIconBadgeCount'] to see the possible values for this operation @@ -407,7 +407,7 @@ public function updateAppIconBadgeCountWithHttpInfo($appIconBadgeCountUpdateRequ /** * Operation updateAppIconBadgeCountAsync * - * Update App Icon Badge Count + * Set App Icon Badge Count * * @param \ActivitySmith\Generated\Model\AppIconBadgeCountUpdateRequest $appIconBadgeCountUpdateRequest (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateAppIconBadgeCount'] to see the possible values for this operation @@ -428,7 +428,7 @@ function ($response) { /** * Operation updateAppIconBadgeCountAsyncWithHttpInfo * - * Update App Icon Badge Count + * Set App Icon Badge Count * * @param \ActivitySmith\Generated\Model\AppIconBadgeCountUpdateRequest $appIconBadgeCountUpdateRequest (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateAppIconBadgeCount'] to see the possible values for this operation diff --git a/generated/Configuration.php b/generated/Configuration.php index 68781cd..281c43c 100644 --- a/generated/Configuration.php +++ b/generated/Configuration.php @@ -100,7 +100,7 @@ class Configuration * * @var string */ - protected $userAgent = 'OpenAPI-Generator/1.8.0/PHP'; + protected $userAgent = 'OpenAPI-Generator/1.10.0/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.8.0' . PHP_EOL; + $report .= ' SDK Package Version: 1.10.0' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; diff --git a/generated/Model/AppIconBadgeCountUpdateRequest.php b/generated/Model/AppIconBadgeCountUpdateRequest.php index 0d3d835..8b6f702 100644 --- a/generated/Model/AppIconBadgeCountUpdateRequest.php +++ b/generated/Model/AppIconBadgeCountUpdateRequest.php @@ -35,7 +35,6 @@ * AppIconBadgeCountUpdateRequest Class Doc Comment * * @category Class - * @description App Icon Badge Count update. Send badge 0 to clear the count. * @package ActivitySmith\Generated * @author OpenAPI Generator team * @link https://openapi-generator.tech diff --git a/generated/Model/LiveActivityAction.php b/generated/Model/LiveActivityAction.php index cc8b434..f21a210 100644 --- a/generated/Model/LiveActivityAction.php +++ b/generated/Model/LiveActivityAction.php @@ -394,7 +394,7 @@ public function getUrl() /** * Sets url * - * @param string $url Action URL. For open_url, use an HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. + * @param string $url Action URL. For open_url, use an HTTP or HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. * * @return self */ diff --git a/generated/Model/LiveActivityEndRequest.php b/generated/Model/LiveActivityEndRequest.php index c794788..217a9df 100644 --- a/generated/Model/LiveActivityEndRequest.php +++ b/generated/Model/LiveActivityEndRequest.php @@ -411,7 +411,7 @@ public function getSecondaryAction() /** * Sets secondaryAction * - * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * * @return self */ diff --git a/generated/Model/LiveActivityStartRequest.php b/generated/Model/LiveActivityStartRequest.php index affb67e..ee43938 100644 --- a/generated/Model/LiveActivityStartRequest.php +++ b/generated/Model/LiveActivityStartRequest.php @@ -62,7 +62,8 @@ class LiveActivityStartRequest implements ModelInterface, ArrayAccess, \JsonSeri 'action' => '\ActivitySmith\Generated\Model\LiveActivityAction', 'secondaryAction' => '\ActivitySmith\Generated\Model\LiveActivityAction', 'alert' => '\ActivitySmith\Generated\Model\AlertPayload', - 'target' => '\ActivitySmith\Generated\Model\ChannelTarget' + 'target' => '\ActivitySmith\Generated\Model\ChannelTarget', + 'tags' => 'string[]' ]; /** @@ -77,7 +78,8 @@ class LiveActivityStartRequest implements ModelInterface, ArrayAccess, \JsonSeri 'action' => null, 'secondaryAction' => null, 'alert' => null, - 'target' => null + 'target' => null, + 'tags' => null ]; /** @@ -90,7 +92,8 @@ class LiveActivityStartRequest implements ModelInterface, ArrayAccess, \JsonSeri 'action' => false, 'secondaryAction' => false, 'alert' => false, - 'target' => false + 'target' => false, + 'tags' => false ]; /** @@ -183,7 +186,8 @@ public function isNullableSetToNull(string $property): bool 'action' => 'action', 'secondaryAction' => 'secondary_action', 'alert' => 'alert', - 'target' => 'target' + 'target' => 'target', + 'tags' => 'tags' ]; /** @@ -196,7 +200,8 @@ public function isNullableSetToNull(string $property): bool 'action' => 'setAction', 'secondaryAction' => 'setSecondaryAction', 'alert' => 'setAlert', - 'target' => 'setTarget' + 'target' => 'setTarget', + 'tags' => 'setTags' ]; /** @@ -209,7 +214,8 @@ public function isNullableSetToNull(string $property): bool 'action' => 'getAction', 'secondaryAction' => 'getSecondaryAction', 'alert' => 'getAlert', - 'target' => 'getTarget' + 'target' => 'getTarget', + 'tags' => 'getTags' ]; /** @@ -274,6 +280,7 @@ public function __construct(array $data = null) $this->setIfExists('secondaryAction', $data ?? [], null); $this->setIfExists('alert', $data ?? [], null); $this->setIfExists('target', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); } /** @@ -388,7 +395,7 @@ public function getSecondaryAction() /** * Sets secondaryAction * - * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * * @return self */ @@ -455,6 +462,33 @@ public function setTarget($target) return $this; } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Optional tags to organize and filter notification history. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + throw new \InvalidArgumentException('non-nullable tags cannot be null'); + } + $this->container['tags'] = $tags; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/generated/Model/LiveActivityStartResponse.php b/generated/Model/LiveActivityStartResponse.php index c9e7b6c..879dcb1 100644 --- a/generated/Model/LiveActivityStartResponse.php +++ b/generated/Model/LiveActivityStartResponse.php @@ -63,6 +63,7 @@ class LiveActivityStartResponse implements ModelInterface, ArrayAccess, \JsonSer 'usersNotified' => 'int', 'activityId' => 'string', 'effectiveChannelSlugs' => 'string[]', + 'tags' => 'string[]', 'timestamp' => '\DateTime' ]; @@ -79,6 +80,7 @@ class LiveActivityStartResponse implements ModelInterface, ArrayAccess, \JsonSer 'usersNotified' => null, 'activityId' => null, 'effectiveChannelSlugs' => null, + 'tags' => null, 'timestamp' => 'date-time' ]; @@ -93,6 +95,7 @@ class LiveActivityStartResponse implements ModelInterface, ArrayAccess, \JsonSer 'usersNotified' => false, 'activityId' => false, 'effectiveChannelSlugs' => false, + 'tags' => false, 'timestamp' => false ]; @@ -187,6 +190,7 @@ public function isNullableSetToNull(string $property): bool 'usersNotified' => 'users_notified', 'activityId' => 'activity_id', 'effectiveChannelSlugs' => 'effective_channel_slugs', + 'tags' => 'tags', 'timestamp' => 'timestamp' ]; @@ -201,6 +205,7 @@ public function isNullableSetToNull(string $property): bool 'usersNotified' => 'setUsersNotified', 'activityId' => 'setActivityId', 'effectiveChannelSlugs' => 'setEffectiveChannelSlugs', + 'tags' => 'setTags', 'timestamp' => 'setTimestamp' ]; @@ -215,6 +220,7 @@ public function isNullableSetToNull(string $property): bool 'usersNotified' => 'getUsersNotified', 'activityId' => 'getActivityId', 'effectiveChannelSlugs' => 'getEffectiveChannelSlugs', + 'tags' => 'getTags', 'timestamp' => 'getTimestamp' ]; @@ -280,6 +286,7 @@ public function __construct(array $data = null) $this->setIfExists('usersNotified', $data ?? [], null); $this->setIfExists('activityId', $data ?? [], null); $this->setIfExists('effectiveChannelSlugs', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); $this->setIfExists('timestamp', $data ?? [], null); } @@ -469,6 +476,33 @@ public function setEffectiveChannelSlugs($effectiveChannelSlugs) return $this; } + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Optional tags to organize and filter notification history. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + throw new \InvalidArgumentException('non-nullable tags cannot be null'); + } + $this->container['tags'] = $tags; + + return $this; + } + /** * Gets timestamp * diff --git a/generated/Model/LiveActivityStreamDeleteRequest.php b/generated/Model/LiveActivityStreamDeleteRequest.php index b59564c..39b7c85 100644 --- a/generated/Model/LiveActivityStreamDeleteRequest.php +++ b/generated/Model/LiveActivityStreamDeleteRequest.php @@ -378,7 +378,7 @@ public function getSecondaryAction() /** * Sets secondaryAction * - * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * * @return self */ diff --git a/generated/Model/LiveActivityStreamPutResponse.php b/generated/Model/LiveActivityStreamPutResponse.php index 6102c00..e1c0e7e 100644 --- a/generated/Model/LiveActivityStreamPutResponse.php +++ b/generated/Model/LiveActivityStreamPutResponse.php @@ -67,6 +67,7 @@ class LiveActivityStreamPutResponse implements ModelInterface, ArrayAccess, \Jso 'devicesQueued' => 'int', 'usersNotified' => 'int', 'effectiveChannelSlugs' => 'string[]', + 'tags' => 'string[]', 'timestamp' => '\DateTime' ]; @@ -87,6 +88,7 @@ class LiveActivityStreamPutResponse implements ModelInterface, ArrayAccess, \Jso 'devicesQueued' => null, 'usersNotified' => null, 'effectiveChannelSlugs' => null, + 'tags' => null, 'timestamp' => 'date-time' ]; @@ -105,6 +107,7 @@ class LiveActivityStreamPutResponse implements ModelInterface, ArrayAccess, \Jso 'devicesQueued' => false, 'usersNotified' => false, 'effectiveChannelSlugs' => false, + 'tags' => false, 'timestamp' => false ]; @@ -203,6 +206,7 @@ public function isNullableSetToNull(string $property): bool 'devicesQueued' => 'devices_queued', 'usersNotified' => 'users_notified', 'effectiveChannelSlugs' => 'effective_channel_slugs', + 'tags' => 'tags', 'timestamp' => 'timestamp' ]; @@ -221,6 +225,7 @@ public function isNullableSetToNull(string $property): bool 'devicesQueued' => 'setDevicesQueued', 'usersNotified' => 'setUsersNotified', 'effectiveChannelSlugs' => 'setEffectiveChannelSlugs', + 'tags' => 'setTags', 'timestamp' => 'setTimestamp' ]; @@ -239,6 +244,7 @@ public function isNullableSetToNull(string $property): bool 'devicesQueued' => 'getDevicesQueued', 'usersNotified' => 'getUsersNotified', 'effectiveChannelSlugs' => 'getEffectiveChannelSlugs', + 'tags' => 'getTags', 'timestamp' => 'getTimestamp' ]; @@ -329,6 +335,7 @@ public function __construct(array $data = null) $this->setIfExists('devicesQueued', $data ?? [], null); $this->setIfExists('usersNotified', $data ?? [], null); $this->setIfExists('effectiveChannelSlugs', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); $this->setIfExists('timestamp', $data ?? [], null); } @@ -655,6 +662,33 @@ public function setEffectiveChannelSlugs($effectiveChannelSlugs) return $this; } + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Optional tags to organize and filter notification history. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + throw new \InvalidArgumentException('non-nullable tags cannot be null'); + } + $this->container['tags'] = $tags; + + return $this; + } + /** * Gets timestamp * diff --git a/generated/Model/LiveActivityStreamRequest.php b/generated/Model/LiveActivityStreamRequest.php index b4546bb..d31ca9d 100644 --- a/generated/Model/LiveActivityStreamRequest.php +++ b/generated/Model/LiveActivityStreamRequest.php @@ -63,7 +63,8 @@ class LiveActivityStreamRequest implements ModelInterface, ArrayAccess, \JsonSer 'secondaryAction' => '\ActivitySmith\Generated\Model\LiveActivityAction', 'alert' => '\ActivitySmith\Generated\Model\AlertPayload', 'channels' => 'string[]', - 'target' => '\ActivitySmith\Generated\Model\ChannelTarget' + 'target' => '\ActivitySmith\Generated\Model\ChannelTarget', + 'tags' => 'string[]' ]; /** @@ -79,7 +80,8 @@ class LiveActivityStreamRequest implements ModelInterface, ArrayAccess, \JsonSer 'secondaryAction' => null, 'alert' => null, 'channels' => null, - 'target' => null + 'target' => null, + 'tags' => null ]; /** @@ -93,7 +95,8 @@ class LiveActivityStreamRequest implements ModelInterface, ArrayAccess, \JsonSer 'secondaryAction' => false, 'alert' => false, 'channels' => false, - 'target' => false + 'target' => false, + 'tags' => false ]; /** @@ -187,7 +190,8 @@ public function isNullableSetToNull(string $property): bool 'secondaryAction' => 'secondary_action', 'alert' => 'alert', 'channels' => 'channels', - 'target' => 'target' + 'target' => 'target', + 'tags' => 'tags' ]; /** @@ -201,7 +205,8 @@ public function isNullableSetToNull(string $property): bool 'secondaryAction' => 'setSecondaryAction', 'alert' => 'setAlert', 'channels' => 'setChannels', - 'target' => 'setTarget' + 'target' => 'setTarget', + 'tags' => 'setTags' ]; /** @@ -215,7 +220,8 @@ public function isNullableSetToNull(string $property): bool 'secondaryAction' => 'getSecondaryAction', 'alert' => 'getAlert', 'channels' => 'getChannels', - 'target' => 'getTarget' + 'target' => 'getTarget', + 'tags' => 'getTags' ]; /** @@ -281,6 +287,7 @@ public function __construct(array $data = null) $this->setIfExists('alert', $data ?? [], null); $this->setIfExists('channels', $data ?? [], null); $this->setIfExists('target', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); } /** @@ -399,7 +406,7 @@ public function getSecondaryAction() /** * Sets secondaryAction * - * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * * @return self */ @@ -498,6 +505,33 @@ public function setTarget($target) return $this; } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Optional tags to organize and filter notification history. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + throw new \InvalidArgumentException('non-nullable tags cannot be null'); + } + $this->container['tags'] = $tags; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/generated/Model/LiveActivityUpdateRequest.php b/generated/Model/LiveActivityUpdateRequest.php index 3faf158..b3bfc02 100644 --- a/generated/Model/LiveActivityUpdateRequest.php +++ b/generated/Model/LiveActivityUpdateRequest.php @@ -411,7 +411,7 @@ public function getSecondaryAction() /** * Sets secondaryAction * - * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported only for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. + * @param \ActivitySmith\Generated\Model\LiveActivityAction|null $secondaryAction Optional secondary action button. Supported for alert, progress, and segmented_progress Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. * * @return self */ diff --git a/generated/Model/PushNotificationAction.php b/generated/Model/PushNotificationAction.php index 8996e3d..6b00712 100644 --- a/generated/Model/PushNotificationAction.php +++ b/generated/Model/PushNotificationAction.php @@ -393,7 +393,7 @@ public function getUrl() /** * Sets url * - * @param string $url Action URL. For open_url, use an HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. + * @param string $url Action URL. For open_url, use an HTTP or HTTPS URL or a shortcuts://run-shortcut?name=... URL that runs a specific iPhone Shortcut. For webhook, use an HTTPS URL called by the ActivitySmith backend. * * @return self */ diff --git a/generated/Model/PushNotificationRequest.php b/generated/Model/PushNotificationRequest.php index ccf6900..c1b401e 100644 --- a/generated/Model/PushNotificationRequest.php +++ b/generated/Model/PushNotificationRequest.php @@ -66,7 +66,8 @@ class PushNotificationRequest implements ModelInterface, ArrayAccess, \JsonSeria 'payload' => 'object', 'badge' => 'int', 'sound' => 'string', - 'target' => '\ActivitySmith\Generated\Model\ChannelTarget' + 'target' => '\ActivitySmith\Generated\Model\ChannelTarget', + 'tags' => 'string[]' ]; /** @@ -86,7 +87,8 @@ class PushNotificationRequest implements ModelInterface, ArrayAccess, \JsonSeria 'payload' => null, 'badge' => null, 'sound' => null, - 'target' => null + 'target' => null, + 'tags' => null ]; /** @@ -104,7 +106,8 @@ class PushNotificationRequest implements ModelInterface, ArrayAccess, \JsonSeria 'payload' => false, 'badge' => false, 'sound' => false, - 'target' => false + 'target' => false, + 'tags' => false ]; /** @@ -202,7 +205,8 @@ public function isNullableSetToNull(string $property): bool 'payload' => 'payload', 'badge' => 'badge', 'sound' => 'sound', - 'target' => 'target' + 'target' => 'target', + 'tags' => 'tags' ]; /** @@ -220,7 +224,8 @@ public function isNullableSetToNull(string $property): bool 'payload' => 'setPayload', 'badge' => 'setBadge', 'sound' => 'setSound', - 'target' => 'setTarget' + 'target' => 'setTarget', + 'tags' => 'setTags' ]; /** @@ -238,7 +243,8 @@ public function isNullableSetToNull(string $property): bool 'payload' => 'getPayload', 'badge' => 'getBadge', 'sound' => 'getSound', - 'target' => 'getTarget' + 'target' => 'getTarget', + 'tags' => 'getTags' ]; /** @@ -308,6 +314,7 @@ public function __construct(array $data = null) $this->setIfExists('badge', $data ?? [], null); $this->setIfExists('sound', $data ?? [], null); $this->setIfExists('target', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); } /** @@ -344,8 +351,8 @@ public function listInvalidProperties() $invalidProperties[] = "invalid value for 'media', must be conform to the pattern /^https:\/\//."; } - if (!is_null($this->container['redirection']) && !preg_match("/^(https|shortcuts):\/\//", $this->container['redirection'])) { - $invalidProperties[] = "invalid value for 'redirection', must be conform to the pattern /^(https|shortcuts):\/\//."; + if (!is_null($this->container['redirection']) && !preg_match("/^(http|https|shortcuts):\/\//", $this->container['redirection'])) { + $invalidProperties[] = "invalid value for 'redirection', must be conform to the pattern /^(http|https|shortcuts):\/\//."; } if (!is_null($this->container['actions']) && (count($this->container['actions']) > 4)) { @@ -493,7 +500,7 @@ public function getRedirection() /** * Sets redirection * - * @param string|null $redirection Optional HTTPS URL or shortcuts://run-shortcut?name=... URL opened when the user taps the notification body. Use shortcuts://run-shortcut?name=... to run a specific iPhone Shortcut that already exists on the user's device. Overrides the default tap target from `media` when both are provided. + * @param string|null $redirection Optional HTTP URL, HTTPS URL, or shortcuts://run-shortcut?name=... URL opened when the user taps the notification body. Use shortcuts://run-shortcut?name=... to run a specific iPhone Shortcut that already exists on the user's device. Overrides the default tap target from `media` when both are provided. * * @return self */ @@ -503,8 +510,8 @@ public function setRedirection($redirection) throw new \InvalidArgumentException('non-nullable redirection cannot be null'); } - if ((!preg_match("/^(https|shortcuts):\/\//", ObjectSerializer::toString($redirection)))) { - throw new \InvalidArgumentException("invalid value for \$redirection when calling PushNotificationRequest., must conform to the pattern /^(https|shortcuts):\/\//."); + if ((!preg_match("/^(http|https|shortcuts):\/\//", ObjectSerializer::toString($redirection)))) { + throw new \InvalidArgumentException("invalid value for \$redirection when calling PushNotificationRequest., must conform to the pattern /^(http|https|shortcuts):\/\//."); } $this->container['redirection'] = $redirection; @@ -650,6 +657,33 @@ public function setTarget($target) return $this; } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Optional tags to organize and filter notification history. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + throw new \InvalidArgumentException('non-nullable tags cannot be null'); + } + $this->container['tags'] = $tags; + + return $this; + } /** * Returns true if offset exists. False otherwise. * diff --git a/generated/Model/PushNotificationResponse.php b/generated/Model/PushNotificationResponse.php index 3974e85..2943d40 100644 --- a/generated/Model/PushNotificationResponse.php +++ b/generated/Model/PushNotificationResponse.php @@ -61,6 +61,7 @@ class PushNotificationResponse implements ModelInterface, ArrayAccess, \JsonSeri 'devicesNotified' => 'int', 'usersNotified' => 'int', 'effectiveChannelSlugs' => 'string[]', + 'tags' => 'string[]', 'timestamp' => '\DateTime' ]; @@ -76,6 +77,7 @@ class PushNotificationResponse implements ModelInterface, ArrayAccess, \JsonSeri 'devicesNotified' => null, 'usersNotified' => null, 'effectiveChannelSlugs' => null, + 'tags' => null, 'timestamp' => 'date-time' ]; @@ -89,6 +91,7 @@ class PushNotificationResponse implements ModelInterface, ArrayAccess, \JsonSeri 'devicesNotified' => false, 'usersNotified' => false, 'effectiveChannelSlugs' => false, + 'tags' => false, 'timestamp' => false ]; @@ -182,6 +185,7 @@ public function isNullableSetToNull(string $property): bool 'devicesNotified' => 'devices_notified', 'usersNotified' => 'users_notified', 'effectiveChannelSlugs' => 'effective_channel_slugs', + 'tags' => 'tags', 'timestamp' => 'timestamp' ]; @@ -195,6 +199,7 @@ public function isNullableSetToNull(string $property): bool 'devicesNotified' => 'setDevicesNotified', 'usersNotified' => 'setUsersNotified', 'effectiveChannelSlugs' => 'setEffectiveChannelSlugs', + 'tags' => 'setTags', 'timestamp' => 'setTimestamp' ]; @@ -208,6 +213,7 @@ public function isNullableSetToNull(string $property): bool 'devicesNotified' => 'getDevicesNotified', 'usersNotified' => 'getUsersNotified', 'effectiveChannelSlugs' => 'getEffectiveChannelSlugs', + 'tags' => 'getTags', 'timestamp' => 'getTimestamp' ]; @@ -272,6 +278,7 @@ public function __construct(array $data = null) $this->setIfExists('devicesNotified', $data ?? [], null); $this->setIfExists('usersNotified', $data ?? [], null); $this->setIfExists('effectiveChannelSlugs', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); $this->setIfExists('timestamp', $data ?? [], null); } @@ -431,6 +438,33 @@ public function setEffectiveChannelSlugs($effectiveChannelSlugs) return $this; } + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Optional tags to organize and filter notification history. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + throw new \InvalidArgumentException('non-nullable tags cannot be null'); + } + $this->container['tags'] = $tags; + + return $this; + } + /** * Gets timestamp * diff --git a/src/LiveActivities.php b/src/LiveActivities.php index b08cb1e..dde166f 100644 --- a/src/LiveActivities.php +++ b/src/LiveActivities.php @@ -42,7 +42,8 @@ public function start( mixed $channels = null, mixed $durationSeconds = null, mixed $countsDown = null, - mixed $secondaryAction = null + mixed $secondaryAction = null, + mixed $tags = null ): mixed { $request = $this->buildRequest($request, $contentState, [ @@ -68,6 +69,7 @@ public function start( 'alert' => $alert, 'target' => $target, 'channels' => $channels, + 'tags' => $tags, ]); return $this->api->startLiveActivity($this->normalizeTargetChannels($request)); @@ -199,7 +201,8 @@ public function stream( mixed $channels = null, mixed $durationSeconds = null, mixed $countsDown = null, - mixed $secondaryAction = null + mixed $secondaryAction = null, + mixed $tags = null ): mixed { $request = $this->buildRequest($request, $contentState, [ @@ -225,6 +228,7 @@ public function stream( 'alert' => $alert, 'target' => $target, 'channels' => $channels, + 'tags' => $tags, ]); return $this->api->reconcileLiveActivityStream( diff --git a/src/Notifications.php b/src/Notifications.php index b43d1a0..f8f2368 100644 --- a/src/Notifications.php +++ b/src/Notifications.php @@ -17,6 +17,7 @@ public function __construct(private PushNotificationsApi $api) * @param array>|null $actions * @param array|null $target * @param array|string|null $channels + * @param array|null $tags */ public function send( mixed $request = null, @@ -27,7 +28,8 @@ public function send( ?string $redirection = null, ?array $actions = null, ?array $target = null, - array|string|null $channels = null + array|string|null $channels = null, + ?array $tags = null ): mixed { $request = $this->buildRequest( @@ -41,6 +43,7 @@ public function send( 'actions' => $actions, 'target' => $target, 'channels' => $channels, + 'tags' => $tags, ] ); $normalized = $this->normalizeTargetChannels($request); @@ -60,7 +63,8 @@ public function sendPushNotification( ?string $redirection = null, ?array $actions = null, ?array $target = null, - array|string|null $channels = null + array|string|null $channels = null, + ?array $tags = null ): mixed { $pushNotificationRequest = $this->buildRequest( $pushNotificationRequest, @@ -73,6 +77,7 @@ public function sendPushNotification( 'actions' => $actions, 'target' => $target, 'channels' => $channels, + 'tags' => $tags, ] ); $normalized = $this->normalizeTargetChannels($pushNotificationRequest); diff --git a/src/Version.php b/src/Version.php index d0b7daf..d06131d 100644 --- a/src/Version.php +++ b/src/Version.php @@ -6,7 +6,7 @@ final class Version { - public const VERSION = '1.9.0'; + public const VERSION = '1.10.0'; private function __construct() { diff --git a/tests/ResourcesTest.php b/tests/ResourcesTest.php index 0c29860..34a5dad 100644 --- a/tests/ResourcesTest.php +++ b/tests/ResourcesTest.php @@ -118,7 +118,8 @@ public function testNotificationsNamedFields(): void $resource->send( title: 'New subscription 💸', message: 'Customer upgraded to Pro plan', - channels: 'sales,customer-success' + channels: 'sales,customer-success', + tags: ['user:382', 'billing'] ) ); @@ -128,6 +129,7 @@ public function testNotificationsNamedFields(): void [ 'title' => 'New subscription 💸', 'message' => 'Customer upgraded to Pro plan', + 'tags' => ['user:382', 'billing'], 'target' => ['channels' => ['sales', 'customer-success']], ], PushNotificationsApi::contentTypes['sendPushNotification'][0], @@ -896,7 +898,8 @@ public function testLiveActivitiesBuildRequestsFromNamedFields(): void contentState: $state, action: $action, secondaryAction: $secondaryAction, - channels: ['ops'] + channels: ['ops'], + tags: ['user:382', 'environment:production'] ) ); $this->assertSame( @@ -935,6 +938,7 @@ public function testLiveActivitiesBuildRequestsFromNamedFields(): void ], 'action' => $action, 'secondary_action' => $secondaryAction, + 'tags' => ['user:382', 'environment:production'], 'target' => ['channels' => ['ops']], ], LiveActivitiesApi::contentTypes['startLiveActivity'][0], @@ -1033,7 +1037,14 @@ public function testLiveActivitiesStreamShortAndLegacyMethods(): void ], ]; - $this->assertSame($response, $resource->stream('prod-web-1', $streamPayload)); + $this->assertSame( + $response, + $resource->stream( + 'prod-web-1', + $streamPayload, + tags: ['user:382', 'environment:production'] + ) + ); $this->assertSame($response, $resource->reconcileLiveActivityStream('prod-web-1', $streamPayload)); $this->assertSame($response, $resource->endStream('prod-web-1', $endPayload)); $this->assertSame($response, $resource->endLiveActivityStream('prod-web-1', $endPayload)); @@ -1042,10 +1053,15 @@ public function testLiveActivitiesStreamShortAndLegacyMethods(): void 'content_state' => $streamPayload['content_state'], 'target' => ['channels' => ['ops']], ]; + $expectedTaggedStreamPayload = [ + 'content_state' => $streamPayload['content_state'], + 'tags' => ['user:382', 'environment:production'], + 'target' => ['channels' => ['ops']], + ]; $this->assertSame( [ - ['prod-web-1', $expectedStreamPayload, LiveActivitiesApi::contentTypes['reconcileLiveActivityStream'][0]], + ['prod-web-1', $expectedTaggedStreamPayload, LiveActivitiesApi::contentTypes['reconcileLiveActivityStream'][0]], ['prod-web-1', $expectedStreamPayload, LiveActivitiesApi::contentTypes['reconcileLiveActivityStream'][0]], ], $captured['stream'] diff --git a/tests/SmokeTest.php b/tests/SmokeTest.php index 51d9026..f8cf7af 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.9.0', Version::VERSION); + $this->assertSame('1.10.0', Version::VERSION); } }