diff --git a/.stats.yml b/.stats.yml index 100a47a..e8ac4eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 168 +configured_endpoints: 169 diff --git a/api.md b/api.md index 576494d..64dae77 100644 --- a/api.md +++ b/api.md @@ -437,6 +437,18 @@ Methods: - client.digests.schedules.list_instances(schedule_id, \*\*params) -> DigestInstanceListResponse - client.digests.schedules.release(schedule_id) -> None +# Feedback + +Types: + +```python +from courier.types import FeedbackCreateResponse +``` + +Methods: + +- client.feedback.create(\*\*params) -> FeedbackCreateResponse + # Inbound Types: diff --git a/src/courier/_client.py b/src/courier/_client.py index 5dc303c..cf0c3b4 100644 --- a/src/courier/_client.py +++ b/src/courier/_client.py @@ -45,6 +45,7 @@ digests, inbound, tenants, + feedback, journeys, messages, previews, @@ -65,6 +66,7 @@ from .resources.send import SendResource, AsyncSendResource from .resources.brands import BrandsResource, AsyncBrandsResource from .resources.inbound import InboundResource, AsyncInboundResource + from .resources.feedback import FeedbackResource, AsyncFeedbackResource from .resources.messages import MessagesResource, AsyncMessagesResource from .resources.previews import PreviewsResource, AsyncPreviewsResource from .resources.requests import RequestsResource, AsyncRequestsResource @@ -254,6 +256,15 @@ def digests(self) -> DigestsResource: return digests.DigestsResource(self) + @cached_property + def feedback(self) -> FeedbackResource: + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + from .resources import feedback + + return feedback.FeedbackResource(self) + @cached_property def inbound(self) -> InboundResource: """ @@ -627,6 +638,15 @@ def digests(self) -> AsyncDigestsResource: return digests.AsyncDigestsResource(self) + @cached_property + def feedback(self) -> AsyncFeedbackResource: + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + from .resources import feedback + + return feedback.AsyncFeedbackResource(self) + @cached_property def inbound(self) -> AsyncInboundResource: """ @@ -942,6 +962,15 @@ def digests(self) -> digests.DigestsResourceWithRawResponse: return digests.DigestsResourceWithRawResponse(self._client.digests) + @cached_property + def feedback(self) -> feedback.FeedbackResourceWithRawResponse: + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + from .resources import feedback + + return feedback.FeedbackResourceWithRawResponse(self._client.feedback) + @cached_property def inbound(self) -> inbound.InboundResourceWithRawResponse: """ @@ -1145,6 +1174,15 @@ def digests(self) -> digests.AsyncDigestsResourceWithRawResponse: return digests.AsyncDigestsResourceWithRawResponse(self._client.digests) + @cached_property + def feedback(self) -> feedback.AsyncFeedbackResourceWithRawResponse: + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + from .resources import feedback + + return feedback.AsyncFeedbackResourceWithRawResponse(self._client.feedback) + @cached_property def inbound(self) -> inbound.AsyncInboundResourceWithRawResponse: """ @@ -1350,6 +1388,15 @@ def digests(self) -> digests.DigestsResourceWithStreamingResponse: return digests.DigestsResourceWithStreamingResponse(self._client.digests) + @cached_property + def feedback(self) -> feedback.FeedbackResourceWithStreamingResponse: + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + from .resources import feedback + + return feedback.FeedbackResourceWithStreamingResponse(self._client.feedback) + @cached_property def inbound(self) -> inbound.InboundResourceWithStreamingResponse: """ @@ -1555,6 +1602,15 @@ def digests(self) -> digests.AsyncDigestsResourceWithStreamingResponse: return digests.AsyncDigestsResourceWithStreamingResponse(self._client.digests) + @cached_property + def feedback(self) -> feedback.AsyncFeedbackResourceWithStreamingResponse: + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + from .resources import feedback + + return feedback.AsyncFeedbackResourceWithStreamingResponse(self._client.feedback) + @cached_property def inbound(self) -> inbound.AsyncInboundResourceWithStreamingResponse: """ diff --git a/src/courier/resources/__init__.py b/src/courier/resources/__init__.py index fbed97c..491cbab 100644 --- a/src/courier/resources/__init__.py +++ b/src/courier/resources/__init__.py @@ -72,6 +72,14 @@ TenantsResourceWithStreamingResponse, AsyncTenantsResourceWithStreamingResponse, ) +from .feedback import ( + FeedbackResource, + AsyncFeedbackResource, + FeedbackResourceWithRawResponse, + AsyncFeedbackResourceWithRawResponse, + FeedbackResourceWithStreamingResponse, + AsyncFeedbackResourceWithStreamingResponse, +) from .journeys import ( JourneysResource, AsyncJourneysResource, @@ -258,6 +266,12 @@ "AsyncDigestsResourceWithRawResponse", "DigestsResourceWithStreamingResponse", "AsyncDigestsResourceWithStreamingResponse", + "FeedbackResource", + "AsyncFeedbackResource", + "FeedbackResourceWithRawResponse", + "AsyncFeedbackResourceWithRawResponse", + "FeedbackResourceWithStreamingResponse", + "AsyncFeedbackResourceWithStreamingResponse", "InboundResource", "AsyncInboundResource", "InboundResourceWithRawResponse", diff --git a/src/courier/resources/feedback.py b/src/courier/resources/feedback.py new file mode 100644 index 0000000..acfe241 --- /dev/null +++ b/src/courier/resources/feedback.py @@ -0,0 +1,287 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ..types import feedback_create_params +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.feedback_create_response import FeedbackCreateResponse + +__all__ = ["FeedbackResource", "AsyncFeedbackResource"] + + +class FeedbackResource(SyncAPIResource): + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + + @cached_property + def with_raw_response(self) -> FeedbackResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/trycourier/courier-python#accessing-raw-response-data-eg-headers + """ + return FeedbackResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FeedbackResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/trycourier/courier-python#with_streaming_response + """ + return FeedbackResourceWithStreamingResponse(self) + + def create( + self, + *, + category: Literal["possible_bug", "confusing_behavior", "feature_request", "other"], + description: str, + surface: Literal["api", "sdk", "mcp", "ui", "docs", "other"], + title: str, + expected_behavior: str | Omit = omit, + harness: str | Omit = omit, + location: str | Omit = omit, + model: str | Omit = omit, + request_id: 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, + ) -> FeedbackCreateResponse: + """Reports a suspected bug, confusing behavior or a missing feature in Courier. + + It + is built for AI agents and developer tools to call when Courier does something + unexpected, and people can call it too. + + A report is not a support ticket. A `201` means Courier stored the report; it + does not promise a reply or a fix. For help with your account, contact Courier + support. + + Never include secrets, API keys or customer data such as recipient names, email + addresses or message content. + + Requires an API key with no scope restrictions; a JWT or a scoped API key is + refused. Each workspace can submit 200 reports per UTC day, and requests that + fail validation count toward that limit. + + Args: + category: What kind of report this is: `possible_bug` for behavior that looks wrong, + `confusing_behavior` for behavior that works but was hard to understand, + `feature_request` for something Courier does not do yet, and `other`. + + description: What happened, in enough detail for someone at Courier to follow it. + + surface: Where you met the problem: the REST `api`, an `sdk`, the Courier `mcp` server, + the Courier app `ui`, the `docs`, or `other`. + + title: A one-line summary of the report. + + expected_behavior: What you expected to happen instead. + + harness: The agent or tool that submitted the report, such as `Claude Code`. + + location: Where it happened, such as an endpoint (`POST /send`), an SDK method, an MCP + tool name or a docs URL. + + model: The AI model that submitted the report, such as `claude-opus-5-5`. + + request_id: The request ID of an API call that shows the problem, if there is one. + + 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 + """ + return self._post( + "/feedback", + body=maybe_transform( + { + "category": category, + "description": description, + "surface": surface, + "title": title, + "expected_behavior": expected_behavior, + "harness": harness, + "location": location, + "model": model, + "request_id": request_id, + }, + feedback_create_params.FeedbackCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=FeedbackCreateResponse, + ) + + +class AsyncFeedbackResource(AsyncAPIResource): + """ + Report suspected bugs, confusing behavior and missing features in Courier, from an AI agent, a developer tool or by hand. + """ + + @cached_property + def with_raw_response(self) -> AsyncFeedbackResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/trycourier/courier-python#accessing-raw-response-data-eg-headers + """ + return AsyncFeedbackResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFeedbackResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/trycourier/courier-python#with_streaming_response + """ + return AsyncFeedbackResourceWithStreamingResponse(self) + + async def create( + self, + *, + category: Literal["possible_bug", "confusing_behavior", "feature_request", "other"], + description: str, + surface: Literal["api", "sdk", "mcp", "ui", "docs", "other"], + title: str, + expected_behavior: str | Omit = omit, + harness: str | Omit = omit, + location: str | Omit = omit, + model: str | Omit = omit, + request_id: 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, + ) -> FeedbackCreateResponse: + """Reports a suspected bug, confusing behavior or a missing feature in Courier. + + It + is built for AI agents and developer tools to call when Courier does something + unexpected, and people can call it too. + + A report is not a support ticket. A `201` means Courier stored the report; it + does not promise a reply or a fix. For help with your account, contact Courier + support. + + Never include secrets, API keys or customer data such as recipient names, email + addresses or message content. + + Requires an API key with no scope restrictions; a JWT or a scoped API key is + refused. Each workspace can submit 200 reports per UTC day, and requests that + fail validation count toward that limit. + + Args: + category: What kind of report this is: `possible_bug` for behavior that looks wrong, + `confusing_behavior` for behavior that works but was hard to understand, + `feature_request` for something Courier does not do yet, and `other`. + + description: What happened, in enough detail for someone at Courier to follow it. + + surface: Where you met the problem: the REST `api`, an `sdk`, the Courier `mcp` server, + the Courier app `ui`, the `docs`, or `other`. + + title: A one-line summary of the report. + + expected_behavior: What you expected to happen instead. + + harness: The agent or tool that submitted the report, such as `Claude Code`. + + location: Where it happened, such as an endpoint (`POST /send`), an SDK method, an MCP + tool name or a docs URL. + + model: The AI model that submitted the report, such as `claude-opus-5-5`. + + request_id: The request ID of an API call that shows the problem, if there is one. + + 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 + """ + return await self._post( + "/feedback", + body=await async_maybe_transform( + { + "category": category, + "description": description, + "surface": surface, + "title": title, + "expected_behavior": expected_behavior, + "harness": harness, + "location": location, + "model": model, + "request_id": request_id, + }, + feedback_create_params.FeedbackCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=FeedbackCreateResponse, + ) + + +class FeedbackResourceWithRawResponse: + def __init__(self, feedback: FeedbackResource) -> None: + self._feedback = feedback + + self.create = to_raw_response_wrapper( + feedback.create, + ) + + +class AsyncFeedbackResourceWithRawResponse: + def __init__(self, feedback: AsyncFeedbackResource) -> None: + self._feedback = feedback + + self.create = async_to_raw_response_wrapper( + feedback.create, + ) + + +class FeedbackResourceWithStreamingResponse: + def __init__(self, feedback: FeedbackResource) -> None: + self._feedback = feedback + + self.create = to_streamed_response_wrapper( + feedback.create, + ) + + +class AsyncFeedbackResourceWithStreamingResponse: + def __init__(self, feedback: AsyncFeedbackResource) -> None: + self._feedback = feedback + + self.create = async_to_streamed_response_wrapper( + feedback.create, + ) diff --git a/src/courier/types/__init__.py b/src/courier/types/__init__.py index ee1ba81..d6160c7 100644 --- a/src/courier/types/__init__.py +++ b/src/courier/types/__init__.py @@ -201,6 +201,7 @@ from .bulk_create_job_params import BulkCreateJobParams as BulkCreateJobParams from .bulk_list_users_params import BulkListUsersParams as BulkListUsersParams from .element_with_checksums import ElementWithChecksums as ElementWithChecksums +from .feedback_create_params import FeedbackCreateParams as FeedbackCreateParams from .journey_condition_atom import JourneyConditionAtom as JourneyConditionAtom from .journey_merge_strategy import JourneyMergeStrategy as JourneyMergeStrategy from .journey_publish_params import JourneyPublishParams as JourneyPublishParams @@ -231,6 +232,7 @@ from .bulk_create_job_response import BulkCreateJobResponse as BulkCreateJobResponse from .bulk_list_users_response import BulkListUsersResponse as BulkListUsersResponse from .device_set_list_response import DeviceSetListResponse as DeviceSetListResponse +from .feedback_create_response import FeedbackCreateResponse as FeedbackCreateResponse from .journey_conditions_field import JourneyConditionsField as JourneyConditionsField from .journey_delay_until_node import JourneyDelayUntilNode as JourneyDelayUntilNode from .journey_experiment_param import JourneyExperimentParam as JourneyExperimentParam diff --git a/src/courier/types/feedback_create_params.py b/src/courier/types/feedback_create_params.py new file mode 100644 index 0000000..d12ec94 --- /dev/null +++ b/src/courier/types/feedback_create_params.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["FeedbackCreateParams"] + + +class FeedbackCreateParams(TypedDict, total=False): + category: Required[Literal["possible_bug", "confusing_behavior", "feature_request", "other"]] + """ + What kind of report this is: `possible_bug` for behavior that looks wrong, + `confusing_behavior` for behavior that works but was hard to understand, + `feature_request` for something Courier does not do yet, and `other`. + """ + + description: Required[str] + """What happened, in enough detail for someone at Courier to follow it.""" + + surface: Required[Literal["api", "sdk", "mcp", "ui", "docs", "other"]] + """ + Where you met the problem: the REST `api`, an `sdk`, the Courier `mcp` server, + the Courier app `ui`, the `docs`, or `other`. + """ + + title: Required[str] + """A one-line summary of the report.""" + + expected_behavior: str + """What you expected to happen instead.""" + + harness: str + """The agent or tool that submitted the report, such as `Claude Code`.""" + + location: str + """ + Where it happened, such as an endpoint (`POST /send`), an SDK method, an MCP + tool name or a docs URL. + """ + + model: str + """The AI model that submitted the report, such as `claude-opus-5-5`.""" + + request_id: str + """The request ID of an API call that shows the problem, if there is one.""" diff --git a/src/courier/types/feedback_create_response.py b/src/courier/types/feedback_create_response.py new file mode 100644 index 0000000..da7e157 --- /dev/null +++ b/src/courier/types/feedback_create_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .._models import BaseModel + +__all__ = ["FeedbackCreateResponse"] + + +class FeedbackCreateResponse(BaseModel): + feedback_id: str + """The ID of the stored report, `fbk_` followed by a ULID.""" diff --git a/tests/api_resources/test_feedback.py b/tests/api_resources/test_feedback.py new file mode 100644 index 0000000..0b1ee94 --- /dev/null +++ b/tests/api_resources/test_feedback.py @@ -0,0 +1,142 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from courier import Courier, AsyncCourier +from tests.utils import assert_matches_type +from courier.types import FeedbackCreateResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestFeedback: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: Courier) -> None: + feedback = client.feedback.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + ) + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: Courier) -> None: + feedback = client.feedback.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + expected_behavior="Every page before the last one contains at least one item.", + harness="Claude Code", + location="GET /lists/{list_id}/subscriptions", + model="claude-opus-5-5", + request_id="1-67f340b1-58b7b231d9485ef0cda0a38b", + ) + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: Courier) -> None: + response = client.feedback.with_raw_response.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + feedback = response.parse() + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: Courier) -> None: + with client.feedback.with_streaming_response.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + feedback = response.parse() + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncFeedback: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncCourier) -> None: + feedback = await async_client.feedback.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + ) + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCourier) -> None: + feedback = await async_client.feedback.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + expected_behavior="Every page before the last one contains at least one item.", + harness="Claude Code", + location="GET /lists/{list_id}/subscriptions", + model="claude-opus-5-5", + request_id="1-67f340b1-58b7b231d9485ef0cda0a38b", + ) + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncCourier) -> None: + response = await async_client.feedback.with_raw_response.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + feedback = await response.parse() + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCourier) -> None: + async with async_client.feedback.with_streaming_response.create( + category="possible_bug", + description="GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.", + surface="api", + title="List subscriptions returns an empty page with a next cursor", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + feedback = await response.parse() + assert_matches_type(FeedbackCreateResponse, feedback, path=["response"]) + + assert cast(Any, response.is_closed) is True