22
33from __future__ import annotations
44
5+ from typing import Iterable
6+
57import httpx
68
7- from ..types import inbound_mail_item_list_params
9+ from ..types import inbound_mail_item_list_params , inbound_mail_item_action_params
810from .._types import Body , Omit , Query , Headers , NotGiven , omit , not_given
9- from .._utils import maybe_transform
11+ from .._utils import maybe_transform , async_maybe_transform
1012from .._compat import cached_property
1113from .._resource import SyncAPIResource , AsyncAPIResource
1214from .._response import (
@@ -133,6 +135,54 @@ def list(
133135 model = InboundMailItem ,
134136 )
135137
138+ def action (
139+ self ,
140+ inbound_mail_item_id : str ,
141+ * ,
142+ checks : Iterable [inbound_mail_item_action_params .Check ],
143+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
144+ # The extra values given here take precedence over values defined on the client or passed to this method.
145+ extra_headers : Headers | None = None ,
146+ extra_query : Query | None = None ,
147+ extra_body : Body | None = None ,
148+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
149+ idempotency_key : str | None = None ,
150+ ) -> InboundMailItem :
151+ """
152+ Action a Inbound Mail Item
153+
154+ Args:
155+ inbound_mail_item_id: The identifier of the Inbound Mail Item to action.
156+
157+ checks: The actions to perform on the Inbound Mail Item.
158+
159+ extra_headers: Send extra headers
160+
161+ extra_query: Add additional query parameters to the request
162+
163+ extra_body: Add additional JSON properties to the request
164+
165+ timeout: Override the client-level default timeout for this request, in seconds
166+
167+ idempotency_key: Specify a custom idempotency key for this request
168+ """
169+ if not inbound_mail_item_id :
170+ raise ValueError (
171+ f"Expected a non-empty value for `inbound_mail_item_id` but received { inbound_mail_item_id !r} "
172+ )
173+ return self ._post (
174+ f"/inbound_mail_items/{ inbound_mail_item_id } /action" ,
175+ body = maybe_transform ({"checks" : checks }, inbound_mail_item_action_params .InboundMailItemActionParams ),
176+ options = make_request_options (
177+ extra_headers = extra_headers ,
178+ extra_query = extra_query ,
179+ extra_body = extra_body ,
180+ timeout = timeout ,
181+ idempotency_key = idempotency_key ,
182+ ),
183+ cast_to = InboundMailItem ,
184+ )
185+
136186
137187class AsyncInboundMailItemsResource (AsyncAPIResource ):
138188 @cached_property
@@ -245,6 +295,56 @@ def list(
245295 model = InboundMailItem ,
246296 )
247297
298+ async def action (
299+ self ,
300+ inbound_mail_item_id : str ,
301+ * ,
302+ checks : Iterable [inbound_mail_item_action_params .Check ],
303+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
304+ # The extra values given here take precedence over values defined on the client or passed to this method.
305+ extra_headers : Headers | None = None ,
306+ extra_query : Query | None = None ,
307+ extra_body : Body | None = None ,
308+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
309+ idempotency_key : str | None = None ,
310+ ) -> InboundMailItem :
311+ """
312+ Action a Inbound Mail Item
313+
314+ Args:
315+ inbound_mail_item_id: The identifier of the Inbound Mail Item to action.
316+
317+ checks: The actions to perform on the Inbound Mail Item.
318+
319+ extra_headers: Send extra headers
320+
321+ extra_query: Add additional query parameters to the request
322+
323+ extra_body: Add additional JSON properties to the request
324+
325+ timeout: Override the client-level default timeout for this request, in seconds
326+
327+ idempotency_key: Specify a custom idempotency key for this request
328+ """
329+ if not inbound_mail_item_id :
330+ raise ValueError (
331+ f"Expected a non-empty value for `inbound_mail_item_id` but received { inbound_mail_item_id !r} "
332+ )
333+ return await self ._post (
334+ f"/inbound_mail_items/{ inbound_mail_item_id } /action" ,
335+ body = await async_maybe_transform (
336+ {"checks" : checks }, inbound_mail_item_action_params .InboundMailItemActionParams
337+ ),
338+ options = make_request_options (
339+ extra_headers = extra_headers ,
340+ extra_query = extra_query ,
341+ extra_body = extra_body ,
342+ timeout = timeout ,
343+ idempotency_key = idempotency_key ,
344+ ),
345+ cast_to = InboundMailItem ,
346+ )
347+
248348
249349class InboundMailItemsResourceWithRawResponse :
250350 def __init__ (self , inbound_mail_items : InboundMailItemsResource ) -> None :
@@ -256,6 +356,9 @@ def __init__(self, inbound_mail_items: InboundMailItemsResource) -> None:
256356 self .list = to_raw_response_wrapper (
257357 inbound_mail_items .list ,
258358 )
359+ self .action = to_raw_response_wrapper (
360+ inbound_mail_items .action ,
361+ )
259362
260363
261364class AsyncInboundMailItemsResourceWithRawResponse :
@@ -268,6 +371,9 @@ def __init__(self, inbound_mail_items: AsyncInboundMailItemsResource) -> None:
268371 self .list = async_to_raw_response_wrapper (
269372 inbound_mail_items .list ,
270373 )
374+ self .action = async_to_raw_response_wrapper (
375+ inbound_mail_items .action ,
376+ )
271377
272378
273379class InboundMailItemsResourceWithStreamingResponse :
@@ -280,6 +386,9 @@ def __init__(self, inbound_mail_items: InboundMailItemsResource) -> None:
280386 self .list = to_streamed_response_wrapper (
281387 inbound_mail_items .list ,
282388 )
389+ self .action = to_streamed_response_wrapper (
390+ inbound_mail_items .action ,
391+ )
283392
284393
285394class AsyncInboundMailItemsResourceWithStreamingResponse :
@@ -292,3 +401,6 @@ def __init__(self, inbound_mail_items: AsyncInboundMailItemsResource) -> None:
292401 self .list = async_to_streamed_response_wrapper (
293402 inbound_mail_items .list ,
294403 )
404+ self .action = async_to_streamed_response_wrapper (
405+ inbound_mail_items .action ,
406+ )
0 commit comments