diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6c17b97..811e184 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.15.0" + ".": "7.16.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 55e2ce6..0dd4709 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 120 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-cf10f3428ad9b9f636939a9305e80dd49118fea2c3f86cf61bf2b95367469e0f.yml -openapi_spec_hash: a61356bb015cec773770d2b61cabaa58 -config_hash: 86b472590f1c27b5a74499744b30c2ee +configured_endpoints: 123 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-f54bd32a07b6d85cfda75812728f86aa295b0f3fb662ead7670179f809195896.yml +openapi_spec_hash: 0a283754d97445ef84d50720ba47081a +config_hash: 3536872b17998fc451577505e15afb3d diff --git a/CHANGELOG.md b/CHANGELOG.md index 75e0625..0877604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 7.16.0 (2026-06-23) + +Full Changelog: [v7.15.0...v7.16.0](https://github.com/trycourier/courier-python/compare/v7.15.0...v7.16.0) + +### Features + +* **journeys:** add content + locale endpoints to journey-scoped templates ([dea52d4](https://github.com/trycourier/courier-python/commit/dea52d47c6dc1cc708f3bbe675903948ebbc9a3c)) + + +### Documentation + +* **journeys:** clarify checksum usage + re-trigger docs sync for journey content endpoints ([0d36476](https://github.com/trycourier/courier-python/commit/0d364764936d55679839613c82d26f59d1cd9580)) + ## 7.15.0 (2026-06-17) Full Changelog: [v7.14.0...v7.15.0](https://github.com/trycourier/courier-python/compare/v7.14.0...v7.15.0) diff --git a/api.md b/api.md index bbf7c0c..eee01fa 100644 --- a/api.md +++ b/api.md @@ -254,7 +254,10 @@ Methods: - client.journeys.templates.archive(notification_id, \*, template_id) -> None - client.journeys.templates.list_versions(notification_id, \*, template_id) -> NotificationTemplateVersionListResponse - client.journeys.templates.publish(notification_id, \*, template_id, \*\*params) -> None +- client.journeys.templates.put_content(notification_id, \*, template_id, \*\*params) -> NotificationContentMutationResponse +- client.journeys.templates.put_locale(locale_id, \*, template_id, notification_id, \*\*params) -> NotificationContentMutationResponse - client.journeys.templates.replace(notification_id, \*, template_id, \*\*params) -> JourneyTemplateGetResponse +- client.journeys.templates.retrieve_content(notification_id, \*, template_id, \*\*params) -> NotificationContentGetResponse # Brands diff --git a/pyproject.toml b/pyproject.toml index fa4586e..64dfbee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "trycourier" -version = "7.15.0" +version = "7.16.0" description = "The official Python library for the Courier API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/courier/_version.py b/src/courier/_version.py index 8dcab68..6fb1f77 100644 --- a/src/courier/_version.py +++ b/src/courier/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "courier" -__version__ = "7.15.0" # x-release-please-version +__version__ = "7.16.0" # x-release-please-version diff --git a/src/courier/resources/journeys/templates.py b/src/courier/resources/journeys/templates.py index ce6f5ab..cb716dc 100644 --- a/src/courier/resources/journeys/templates.py +++ b/src/courier/resources/journeys/templates.py @@ -2,8 +2,11 @@ from __future__ import annotations +from typing import Iterable + import httpx +from ...types import NotificationTemplateState from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from ..._utils import path_template, maybe_transform, async_maybe_transform from ..._compat import cached_property @@ -20,9 +23,15 @@ template_create_params, template_publish_params, template_replace_params, + template_put_locale_params, + template_put_content_params, + template_retrieve_content_params, ) +from ...types.notification_template_state import NotificationTemplateState from ...types.journey_template_get_response import JourneyTemplateGetResponse from ...types.journey_template_list_response import JourneyTemplateListResponse +from ...types.notification_content_get_response import NotificationContentGetResponse +from ...types.notification_content_mutation_response import NotificationContentMutationResponse from ...types.notification_template_version_list_response import NotificationTemplateVersionListResponse __all__ = ["TemplatesResource", "AsyncTemplatesResource"] @@ -319,6 +328,119 @@ def publish( cast_to=NoneType, ) + def put_content( + self, + notification_id: str, + *, + template_id: str, + content: template_put_content_params.Content, + state: NotificationTemplateState | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NotificationContentMutationResponse: + """ + Replace the elemental content of a journey-scoped notification template. + Overwrites all elements in the template draft with the provided content. + + Args: + content: Elemental content payload. The server defaults `version` when omitted. + + state: Template state. Defaults to `DRAFT`. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + if not notification_id: + raise ValueError(f"Expected a non-empty value for `notification_id` but received {notification_id!r}") + return self._put( + path_template( + "/journeys/{template_id}/templates/{notification_id}/content", + template_id=template_id, + notification_id=notification_id, + ), + body=maybe_transform( + { + "content": content, + "state": state, + }, + template_put_content_params.TemplatePutContentParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NotificationContentMutationResponse, + ) + + def put_locale( + self, + locale_id: str, + *, + template_id: str, + notification_id: str, + elements: Iterable[template_put_locale_params.Element], + state: NotificationTemplateState | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NotificationContentMutationResponse: + """Set locale-specific content overrides for a journey-scoped notification + template. + + Each element override must reference an existing element by ID. + + Args: + elements: Elements with locale-specific content overrides. + + state: Template state. Defaults to `DRAFT`. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + if not notification_id: + raise ValueError(f"Expected a non-empty value for `notification_id` but received {notification_id!r}") + if not locale_id: + raise ValueError(f"Expected a non-empty value for `locale_id` but received {locale_id!r}") + return self._put( + path_template( + "/journeys/{template_id}/templates/{notification_id}/locales/{locale_id}", + template_id=template_id, + notification_id=notification_id, + locale_id=locale_id, + ), + body=maybe_transform( + { + "elements": elements, + "state": state, + }, + template_put_locale_params.TemplatePutLocaleParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NotificationContentMutationResponse, + ) + def replace( self, notification_id: str, @@ -368,6 +490,61 @@ def replace( cast_to=JourneyTemplateGetResponse, ) + def retrieve_content( + self, + notification_id: str, + *, + template_id: str, + version: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NotificationContentGetResponse: + """Retrieve the elemental content of a journey-scoped notification template. + + The + response contains the versioned elements along with their content checksums, + which can be used to detect changes between versions. Pass `?version=draft` + (default `published`) to retrieve the working draft, or `?version=vN` for a + historical version. + + Args: + version: Accepts `draft`, `published`, or a version string (e.g., `v001`). Defaults to + `published`. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + if not notification_id: + raise ValueError(f"Expected a non-empty value for `notification_id` but received {notification_id!r}") + return self._get( + path_template( + "/journeys/{template_id}/templates/{notification_id}/content", + template_id=template_id, + notification_id=notification_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + {"version": version}, template_retrieve_content_params.TemplateRetrieveContentParams + ), + ), + cast_to=NotificationContentGetResponse, + ) + class AsyncTemplatesResource(AsyncAPIResource): @cached_property @@ -660,6 +837,119 @@ async def publish( cast_to=NoneType, ) + async def put_content( + self, + notification_id: str, + *, + template_id: str, + content: template_put_content_params.Content, + state: NotificationTemplateState | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NotificationContentMutationResponse: + """ + Replace the elemental content of a journey-scoped notification template. + Overwrites all elements in the template draft with the provided content. + + Args: + content: Elemental content payload. The server defaults `version` when omitted. + + state: Template state. Defaults to `DRAFT`. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + if not notification_id: + raise ValueError(f"Expected a non-empty value for `notification_id` but received {notification_id!r}") + return await self._put( + path_template( + "/journeys/{template_id}/templates/{notification_id}/content", + template_id=template_id, + notification_id=notification_id, + ), + body=await async_maybe_transform( + { + "content": content, + "state": state, + }, + template_put_content_params.TemplatePutContentParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NotificationContentMutationResponse, + ) + + async def put_locale( + self, + locale_id: str, + *, + template_id: str, + notification_id: str, + elements: Iterable[template_put_locale_params.Element], + state: NotificationTemplateState | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NotificationContentMutationResponse: + """Set locale-specific content overrides for a journey-scoped notification + template. + + Each element override must reference an existing element by ID. + + Args: + elements: Elements with locale-specific content overrides. + + state: Template state. Defaults to `DRAFT`. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + if not notification_id: + raise ValueError(f"Expected a non-empty value for `notification_id` but received {notification_id!r}") + if not locale_id: + raise ValueError(f"Expected a non-empty value for `locale_id` but received {locale_id!r}") + return await self._put( + path_template( + "/journeys/{template_id}/templates/{notification_id}/locales/{locale_id}", + template_id=template_id, + notification_id=notification_id, + locale_id=locale_id, + ), + body=await async_maybe_transform( + { + "elements": elements, + "state": state, + }, + template_put_locale_params.TemplatePutLocaleParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NotificationContentMutationResponse, + ) + async def replace( self, notification_id: str, @@ -709,6 +999,61 @@ async def replace( cast_to=JourneyTemplateGetResponse, ) + async def retrieve_content( + self, + notification_id: str, + *, + template_id: str, + version: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> NotificationContentGetResponse: + """Retrieve the elemental content of a journey-scoped notification template. + + The + response contains the versioned elements along with their content checksums, + which can be used to detect changes between versions. Pass `?version=draft` + (default `published`) to retrieve the working draft, or `?version=vN` for a + historical version. + + Args: + version: Accepts `draft`, `published`, or a version string (e.g., `v001`). Defaults to + `published`. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not template_id: + raise ValueError(f"Expected a non-empty value for `template_id` but received {template_id!r}") + if not notification_id: + raise ValueError(f"Expected a non-empty value for `notification_id` but received {notification_id!r}") + return await self._get( + path_template( + "/journeys/{template_id}/templates/{notification_id}/content", + template_id=template_id, + notification_id=notification_id, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"version": version}, template_retrieve_content_params.TemplateRetrieveContentParams + ), + ), + cast_to=NotificationContentGetResponse, + ) + class TemplatesResourceWithRawResponse: def __init__(self, templates: TemplatesResource) -> None: @@ -732,9 +1077,18 @@ def __init__(self, templates: TemplatesResource) -> None: self.publish = to_raw_response_wrapper( templates.publish, ) + self.put_content = to_raw_response_wrapper( + templates.put_content, + ) + self.put_locale = to_raw_response_wrapper( + templates.put_locale, + ) self.replace = to_raw_response_wrapper( templates.replace, ) + self.retrieve_content = to_raw_response_wrapper( + templates.retrieve_content, + ) class AsyncTemplatesResourceWithRawResponse: @@ -759,9 +1113,18 @@ def __init__(self, templates: AsyncTemplatesResource) -> None: self.publish = async_to_raw_response_wrapper( templates.publish, ) + self.put_content = async_to_raw_response_wrapper( + templates.put_content, + ) + self.put_locale = async_to_raw_response_wrapper( + templates.put_locale, + ) self.replace = async_to_raw_response_wrapper( templates.replace, ) + self.retrieve_content = async_to_raw_response_wrapper( + templates.retrieve_content, + ) class TemplatesResourceWithStreamingResponse: @@ -786,9 +1149,18 @@ def __init__(self, templates: TemplatesResource) -> None: self.publish = to_streamed_response_wrapper( templates.publish, ) + self.put_content = to_streamed_response_wrapper( + templates.put_content, + ) + self.put_locale = to_streamed_response_wrapper( + templates.put_locale, + ) self.replace = to_streamed_response_wrapper( templates.replace, ) + self.retrieve_content = to_streamed_response_wrapper( + templates.retrieve_content, + ) class AsyncTemplatesResourceWithStreamingResponse: @@ -813,6 +1185,15 @@ def __init__(self, templates: AsyncTemplatesResource) -> None: self.publish = async_to_streamed_response_wrapper( templates.publish, ) + self.put_content = async_to_streamed_response_wrapper( + templates.put_content, + ) + self.put_locale = async_to_streamed_response_wrapper( + templates.put_locale, + ) self.replace = async_to_streamed_response_wrapper( templates.replace, ) + self.retrieve_content = async_to_streamed_response_wrapper( + templates.retrieve_content, + ) diff --git a/src/courier/types/journeys/__init__.py b/src/courier/types/journeys/__init__.py index 42cd253..969be02 100644 --- a/src/courier/types/journeys/__init__.py +++ b/src/courier/types/journeys/__init__.py @@ -6,3 +6,6 @@ from .template_create_params import TemplateCreateParams as TemplateCreateParams from .template_publish_params import TemplatePublishParams as TemplatePublishParams from .template_replace_params import TemplateReplaceParams as TemplateReplaceParams +from .template_put_locale_params import TemplatePutLocaleParams as TemplatePutLocaleParams +from .template_put_content_params import TemplatePutContentParams as TemplatePutContentParams +from .template_retrieve_content_params import TemplateRetrieveContentParams as TemplateRetrieveContentParams diff --git a/src/courier/types/journeys/template_put_content_params.py b/src/courier/types/journeys/template_put_content_params.py new file mode 100644 index 0000000..b222c50 --- /dev/null +++ b/src/courier/types/journeys/template_put_content_params.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo +from ..notification_template_state import NotificationTemplateState +from ..shared_params.elemental_node import ElementalNode + +__all__ = ["TemplatePutContentParams", "Content"] + + +class TemplatePutContentParams(TypedDict, total=False): + template_id: Required[Annotated[str, PropertyInfo(alias="templateId")]] + + content: Required[Content] + """Elemental content payload. The server defaults `version` when omitted.""" + + state: NotificationTemplateState + """Template state. Defaults to `DRAFT`.""" + + +class Content(TypedDict, total=False): + """Elemental content payload. The server defaults `version` when omitted.""" + + elements: Required[Iterable[ElementalNode]] + + version: str + """Content version identifier (e.g., `2022-01-01`). + + Optional; server defaults when omitted. + """ diff --git a/src/courier/types/journeys/template_put_locale_params.py b/src/courier/types/journeys/template_put_locale_params.py new file mode 100644 index 0000000..a8f9e43 --- /dev/null +++ b/src/courier/types/journeys/template_put_locale_params.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo +from ..notification_template_state import NotificationTemplateState + +__all__ = ["TemplatePutLocaleParams", "Element"] + + +class TemplatePutLocaleParams(TypedDict, total=False): + template_id: Required[Annotated[str, PropertyInfo(alias="templateId")]] + + notification_id: Required[Annotated[str, PropertyInfo(alias="notificationId")]] + + elements: Required[Iterable[Element]] + """Elements with locale-specific content overrides.""" + + state: NotificationTemplateState + """Template state. Defaults to `DRAFT`.""" + + +class Element(TypedDict, total=False, extra_items=object): # type: ignore[call-arg] + id: Required[str] + """Target element ID.""" diff --git a/src/courier/types/journeys/template_retrieve_content_params.py b/src/courier/types/journeys/template_retrieve_content_params.py new file mode 100644 index 0000000..1264739 --- /dev/null +++ b/src/courier/types/journeys/template_retrieve_content_params.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["TemplateRetrieveContentParams"] + + +class TemplateRetrieveContentParams(TypedDict, total=False): + template_id: Required[Annotated[str, PropertyInfo(alias="templateId")]] + + version: str + """Accepts `draft`, `published`, or a version string (e.g., `v001`). + + Defaults to `published`. + """ diff --git a/tests/api_resources/journeys/test_templates.py b/tests/api_resources/journeys/test_templates.py index 57ec626..80149a4 100644 --- a/tests/api_resources/journeys/test_templates.py +++ b/tests/api_resources/journeys/test_templates.py @@ -12,6 +12,8 @@ from courier.types import ( JourneyTemplateGetResponse, JourneyTemplateListResponse, + NotificationContentGetResponse, + NotificationContentMutationResponse, NotificationTemplateVersionListResponse, ) @@ -407,6 +409,159 @@ def test_path_params_publish(self, client: Courier) -> None: template_id="x", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_put_content(self, client: Courier) -> None: + template = client.journeys.templates.put_content( + notification_id="x", + template_id="x", + content={"elements": [{}]}, + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_put_content_with_all_params(self, client: Courier) -> None: + template = client.journeys.templates.put_content( + notification_id="x", + template_id="x", + content={ + "elements": [{"type": "channel"}], + "version": "2022-01-01", + }, + state="DRAFT", + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_put_content(self, client: Courier) -> None: + response = client.journeys.templates.with_raw_response.put_content( + notification_id="x", + template_id="x", + content={"elements": [{}]}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_put_content(self, client: Courier) -> None: + with client.journeys.templates.with_streaming_response.put_content( + notification_id="x", + template_id="x", + content={"elements": [{}]}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_put_content(self, client: Courier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + client.journeys.templates.with_raw_response.put_content( + notification_id="x", + template_id="", + content={"elements": [{}]}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `notification_id` but received ''"): + client.journeys.templates.with_raw_response.put_content( + notification_id="", + template_id="x", + content={"elements": [{}]}, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_put_locale(self, client: Courier) -> None: + template = client.journeys.templates.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_put_locale_with_all_params(self, client: Courier) -> None: + template = client.journeys.templates.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + state="DRAFT", + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_put_locale(self, client: Courier) -> None: + response = client.journeys.templates.with_raw_response.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_put_locale(self, client: Courier) -> None: + with client.journeys.templates.with_streaming_response.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_put_locale(self, client: Courier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + client.journeys.templates.with_raw_response.put_locale( + locale_id="x", + template_id="", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `notification_id` but received ''"): + client.journeys.templates.with_raw_response.put_locale( + locale_id="x", + template_id="x", + notification_id="", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `locale_id` but received ''"): + client.journeys.templates.with_raw_response.put_locale( + locale_id="", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_replace(self, client: Courier) -> None: @@ -538,6 +693,68 @@ def test_path_params_replace(self, client: Courier) -> None: }, ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_content(self, client: Courier) -> None: + template = client.journeys.templates.retrieve_content( + notification_id="x", + template_id="x", + ) + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_content_with_all_params(self, client: Courier) -> None: + template = client.journeys.templates.retrieve_content( + notification_id="x", + template_id="x", + version="version", + ) + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve_content(self, client: Courier) -> None: + response = client.journeys.templates.with_raw_response.retrieve_content( + notification_id="x", + template_id="x", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = response.parse() + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve_content(self, client: Courier) -> None: + with client.journeys.templates.with_streaming_response.retrieve_content( + notification_id="x", + template_id="x", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = response.parse() + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve_content(self, client: Courier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + client.journeys.templates.with_raw_response.retrieve_content( + notification_id="x", + template_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `notification_id` but received ''"): + client.journeys.templates.with_raw_response.retrieve_content( + notification_id="", + template_id="x", + ) + class TestAsyncTemplates: parametrize = pytest.mark.parametrize( @@ -930,6 +1147,159 @@ async def test_path_params_publish(self, async_client: AsyncCourier) -> None: template_id="x", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_put_content(self, async_client: AsyncCourier) -> None: + template = await async_client.journeys.templates.put_content( + notification_id="x", + template_id="x", + content={"elements": [{}]}, + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_put_content_with_all_params(self, async_client: AsyncCourier) -> None: + template = await async_client.journeys.templates.put_content( + notification_id="x", + template_id="x", + content={ + "elements": [{"type": "channel"}], + "version": "2022-01-01", + }, + state="DRAFT", + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_put_content(self, async_client: AsyncCourier) -> None: + response = await async_client.journeys.templates.with_raw_response.put_content( + notification_id="x", + template_id="x", + content={"elements": [{}]}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_put_content(self, async_client: AsyncCourier) -> None: + async with async_client.journeys.templates.with_streaming_response.put_content( + notification_id="x", + template_id="x", + content={"elements": [{}]}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_put_content(self, async_client: AsyncCourier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + await async_client.journeys.templates.with_raw_response.put_content( + notification_id="x", + template_id="", + content={"elements": [{}]}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `notification_id` but received ''"): + await async_client.journeys.templates.with_raw_response.put_content( + notification_id="", + template_id="x", + content={"elements": [{}]}, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_put_locale(self, async_client: AsyncCourier) -> None: + template = await async_client.journeys.templates.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_put_locale_with_all_params(self, async_client: AsyncCourier) -> None: + template = await async_client.journeys.templates.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + state="DRAFT", + ) + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_put_locale(self, async_client: AsyncCourier) -> None: + response = await async_client.journeys.templates.with_raw_response.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_put_locale(self, async_client: AsyncCourier) -> None: + async with async_client.journeys.templates.with_streaming_response.put_locale( + locale_id="x", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(NotificationContentMutationResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_put_locale(self, async_client: AsyncCourier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + await async_client.journeys.templates.with_raw_response.put_locale( + locale_id="x", + template_id="", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `notification_id` but received ''"): + await async_client.journeys.templates.with_raw_response.put_locale( + locale_id="x", + template_id="x", + notification_id="", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `locale_id` but received ''"): + await async_client.journeys.templates.with_raw_response.put_locale( + locale_id="", + template_id="x", + notification_id="x", + elements=[{"id": "elem_1"}, {"id": "elem_2"}], + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_replace(self, async_client: AsyncCourier) -> None: @@ -1060,3 +1430,65 @@ async def test_path_params_replace(self, async_client: AsyncCourier) -> None: "tags": ["string"], }, ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_content(self, async_client: AsyncCourier) -> None: + template = await async_client.journeys.templates.retrieve_content( + notification_id="x", + template_id="x", + ) + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_content_with_all_params(self, async_client: AsyncCourier) -> None: + template = await async_client.journeys.templates.retrieve_content( + notification_id="x", + template_id="x", + version="version", + ) + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve_content(self, async_client: AsyncCourier) -> None: + response = await async_client.journeys.templates.with_raw_response.retrieve_content( + notification_id="x", + template_id="x", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template = await response.parse() + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve_content(self, async_client: AsyncCourier) -> None: + async with async_client.journeys.templates.with_streaming_response.retrieve_content( + notification_id="x", + template_id="x", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template = await response.parse() + assert_matches_type(NotificationContentGetResponse, template, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve_content(self, async_client: AsyncCourier) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `template_id` but received ''"): + await async_client.journeys.templates.with_raw_response.retrieve_content( + notification_id="x", + template_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `notification_id` but received ''"): + await async_client.journeys.templates.with_raw_response.retrieve_content( + notification_id="", + template_id="x", + )