Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion activitysmith_openapi/docs/LiveActivityAction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**title** | **str** | Button title displayed in the Live Activity UI. |
**type** | [**LiveActivityActionType**](LiveActivityActionType.md) | |
**url** | **str** | Action URL. For open_url, use an HTTPS or shortcuts:// URL. For webhook, use an HTTPS URL called by the ActivitySmith backend. |
**url** | **str** | 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. |
**method** | [**LiveActivityWebhookMethod**](LiveActivityWebhookMethod.md) | Webhook HTTP method. Used only when type=webhook. | [optional] [default to LiveActivityWebhookMethod.POST]
**body** | **Dict[str, object]** | Optional webhook payload body. Used only when type=webhook. | [optional]

Expand Down
2 changes: 1 addition & 1 deletion activitysmith_openapi/docs/PushNotificationAction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**title** | **str** | Button title displayed in iOS expanded notification UI. |
**type** | [**PushNotificationActionType**](PushNotificationActionType.md) | |
**url** | **str** | Action URL. For open_url, use an HTTPS or shortcuts:// URL. For webhook, use an HTTPS URL called by the ActivitySmith backend. |
**url** | **str** | 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. |
**method** | [**PushNotificationWebhookMethod**](PushNotificationWebhookMethod.md) | Webhook HTTP method. Used only when type=webhook. | [optional] [default to PushNotificationWebhookMethod.POST]
**body** | **Dict[str, object]** | Optional webhook payload body. Used only when type=webhook. | [optional]

Expand Down
2 changes: 1 addition & 1 deletion activitysmith_openapi/docs/PushNotificationRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Name | Type | Description | Notes
**message** | **str** | | [optional]
**subtitle** | **str** | | [optional]
**media** | **str** | Optional HTTPS URL for an image, audio file, or video that users can preview or play when they expand the notification. If `redirection` is omitted, tapping the notification opens this URL. Cannot be combined with `actions`. | [optional]
**redirection** | **str** | Optional HTTPS or shortcuts:// URL opened when user taps the notification body. Overrides the default tap target from `media` when both are provided. | [optional]
**redirection** | **str** | 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. | [optional]
**actions** | [**List[PushNotificationAction]**](PushNotificationAction.md) | Optional interactive actions shown when users expand the notification. Cannot be combined with `media`. | [optional]
**payload** | **Dict[str, object]** | | [optional]
**badge** | **int** | | [optional]
Expand Down
13 changes: 3 additions & 10 deletions activitysmith_openapi/models/live_activity_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import re # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr, model_validator
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from activitysmith_openapi.models.live_activity_action_type import LiveActivityActionType
from activitysmith_openapi.models.live_activity_webhook_method import LiveActivityWebhookMethod
Expand All @@ -30,7 +30,7 @@ class LiveActivityAction(BaseModel):
""" # noqa: E501
title: StrictStr = Field(description="Button title displayed in the Live Activity UI.")
type: LiveActivityActionType
url: StrictStr = Field(description="Action URL. For open_url, use an HTTPS or shortcuts:// URL. For webhook, use an HTTPS URL called by the ActivitySmith backend.")
url: StrictStr = Field(description="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.")
method: Optional[LiveActivityWebhookMethod] = Field(default=LiveActivityWebhookMethod.POST, description="Webhook HTTP method. Used only when type=webhook.")
body: Optional[Dict[str, Any]] = Field(default=None, description="Optional webhook payload body. Used only when type=webhook.")
additional_properties: Dict[str, Any] = {}
Expand All @@ -42,14 +42,6 @@ class LiveActivityAction(BaseModel):
protected_namespaces=(),
)

@model_validator(mode="after")
def validate_url_for_type(self) -> Self:
if self.type == LiveActivityActionType.OPEN_URL and not (self.url.startswith("https://") or self.url.startswith("shortcuts://")):
raise ValueError("open_url action url must use https or shortcuts")
if self.type == LiveActivityActionType.WEBHOOK and not self.url.startswith("https://"):
raise ValueError("webhook action url must use https")
return self


def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
Expand Down Expand Up @@ -110,3 +102,4 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:

return _obj


13 changes: 3 additions & 10 deletions activitysmith_openapi/models/push_notification_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import re # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr, model_validator
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from activitysmith_openapi.models.push_notification_action_type import PushNotificationActionType
from activitysmith_openapi.models.push_notification_webhook_method import PushNotificationWebhookMethod
Expand All @@ -30,7 +30,7 @@ class PushNotificationAction(BaseModel):
""" # noqa: E501
title: StrictStr = Field(description="Button title displayed in iOS expanded notification UI.")
type: PushNotificationActionType
url: StrictStr = Field(description="Action URL. For open_url, use an HTTPS or shortcuts:// URL. For webhook, use an HTTPS URL called by the ActivitySmith backend.")
url: StrictStr = Field(description="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.")
method: Optional[PushNotificationWebhookMethod] = Field(default=PushNotificationWebhookMethod.POST, description="Webhook HTTP method. Used only when type=webhook.")
body: Optional[Dict[str, Any]] = Field(default=None, description="Optional webhook payload body. Used only when type=webhook.")
additional_properties: Dict[str, Any] = {}
Expand All @@ -42,14 +42,6 @@ class PushNotificationAction(BaseModel):
protected_namespaces=(),
)

@model_validator(mode="after")
def validate_url_for_type(self) -> Self:
if self.type == PushNotificationActionType.OPEN_URL and not (self.url.startswith("https://") or self.url.startswith("shortcuts://")):
raise ValueError("open_url action url must use https or shortcuts")
if self.type == PushNotificationActionType.WEBHOOK and not self.url.startswith("https://"):
raise ValueError("webhook action url must use https")
return self


def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
Expand Down Expand Up @@ -110,3 +102,4 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:

return _obj


2 changes: 1 addition & 1 deletion activitysmith_openapi/models/push_notification_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PushNotificationRequest(BaseModel):
message: Optional[StrictStr] = None
subtitle: Optional[StrictStr] = None
media: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Optional HTTPS URL for an image, audio file, or video that users can preview or play when they expand the notification. If `redirection` is omitted, tapping the notification opens this URL. Cannot be combined with `actions`.")
redirection: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Optional HTTPS or shortcuts:// URL opened when user taps the notification body. Overrides the default tap target from `media` when both are provided.")
redirection: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="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.")
actions: Optional[Annotated[List[PushNotificationAction], Field(max_length=4)]] = Field(default=None, description="Optional interactive actions shown when users expand the notification. Cannot be combined with `media`.")
payload: Optional[Dict[str, Any]] = None
badge: Optional[StrictInt] = None
Expand Down
18 changes: 0 additions & 18 deletions activitysmith_openapi/test/test_live_activity_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import unittest

from activitysmith_openapi.models.live_activity_action import LiveActivityAction
from activitysmith_openapi.models.live_activity_action_type import LiveActivityActionType

class TestLiveActivityAction(unittest.TestCase):
"""LiveActivityAction unit test stubs"""
Expand Down Expand Up @@ -55,22 +54,5 @@ def testLiveActivityAction(self):
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)

def test_open_url_allows_shortcuts_url(self):
action = LiveActivityAction(
title="Chat",
type=LiveActivityActionType.OPEN_URL,
url="shortcuts://run-shortcut?name=JARVIS",
)

self.assertEqual("shortcuts://run-shortcut?name=JARVIS", action.url)

def test_webhook_rejects_shortcuts_url(self):
with self.assertRaises(ValueError):
LiveActivityAction(
title="Chat",
type=LiveActivityActionType.WEBHOOK,
url="shortcuts://run-shortcut?name=JARVIS",
)

if __name__ == '__main__':
unittest.main()
18 changes: 0 additions & 18 deletions activitysmith_openapi/test/test_push_notification_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import unittest

from activitysmith_openapi.models.push_notification_action import PushNotificationAction
from activitysmith_openapi.models.push_notification_action_type import PushNotificationActionType

class TestPushNotificationAction(unittest.TestCase):
"""PushNotificationAction unit test stubs"""
Expand Down Expand Up @@ -55,22 +54,5 @@ def testPushNotificationAction(self):
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)

def test_open_url_allows_shortcuts_url(self):
action = PushNotificationAction(
title="Chat",
type=PushNotificationActionType.OPEN_URL,
url="shortcuts://run-shortcut?name=JARVIS",
)

self.assertEqual("shortcuts://run-shortcut?name=JARVIS", action.url)

def test_webhook_rejects_shortcuts_url(self):
with self.assertRaises(ValueError):
PushNotificationAction(
title="Chat",
type=PushNotificationActionType.WEBHOOK,
url="shortcuts://run-shortcut?name=JARVIS",
)

if __name__ == '__main__':
unittest.main()