inttegro.async_resources.refunds
Generated public typing surface. Do not edit by hand.
1# Generated by scripts/generate_async_resources.py; do not edit by hand. 2"""Refunds resource for managing order refunds.""" 3from __future__ import annotations 4from inttegro.refund.refund import Refund 5from inttegro.refund.page import Page 6from ..async_http_client import AsyncHttpClient 7from inttegro.refund.create_request import CreateRequest 8from inttegro.refund.page_request import PageRequest 9 10class AsyncRefunds: 11 """Create, cancel, look up, and page through refunds. 12 13 Access this service as ``AsyncInttegroClient.refunds``. Methods use the client's shared transport and return the typed resource shapes documented below. 14 """ 15 16 def __init__(self, http: AsyncHttpClient): 17 self.http = http 18 19 async def create(self, payload: CreateRequest, idempotency_key: str | None=None) -> Refund: 20 """Create a refund for paid order line items. 21 22 API endpoint: ``/refunds/create``. 23 24 Args: 25 payload (CreateRequest): Typed request object or equivalent request mapping for this operation. 26 idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write. 27 28 Returns: 29 ``Refund`` decoded from the documented response shape. 30 31 Raises: 32 APIError: The API rejected the request or could not complete it. 33 NetworkError: The request could not reach the Inttegro API. 34 TimeoutError: The configured request deadline elapsed. 35 """ 36 return await self.http.post_with_headers('/refunds/create', payload, self._idempotency_headers(idempotency_key)) 37 38 async def cancel(self, refund_id: str, idempotency_key: str | None=None, *, reason: str | None=None) -> Refund: 39 """Cancel a pending refund. 40 41 API endpoint: ``/refunds/cancel``. 42 43 Args: 44 refund_id (str): Unique identifier of the refund. 45 idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write. 46 reason (str | None): Optional explanation for canceling the refund. 47 48 Returns: 49 ``Refund`` decoded from the documented response shape. 50 51 Raises: 52 APIError: The API rejected the request or could not complete it. 53 NetworkError: The request could not reach the Inttegro API. 54 TimeoutError: The configured request deadline elapsed. 55 """ 56 payload = {'refund_id': refund_id} 57 if reason is not None: 58 payload['reason'] = reason 59 return await self.http.post_with_headers('/refunds/cancel', payload, self._idempotency_headers(idempotency_key)) 60 61 async def lookup(self, refund_id: str) -> Refund: 62 """Look up a refund by ID. 63 64 API endpoint: ``/refunds/lookup``. 65 66 Args: 67 refund_id (str): Unique identifier of the refund. 68 69 Returns: 70 ``Refund`` decoded from the documented response shape. 71 72 Raises: 73 APIError: The API rejected the request or could not complete it. 74 NetworkError: The request could not reach the Inttegro API. 75 TimeoutError: The configured request deadline elapsed. 76 """ 77 return await self.http.post('/refunds/lookup', {'refund_id': refund_id}) 78 79 async def page(self, payload: PageRequest) -> Page: 80 """Page through refunds. 81 82 API endpoint: ``/refunds/page``. 83 84 Args: 85 payload (PageRequest): Typed request object or equivalent request mapping for this operation. 86 87 Returns: 88 ``Page`` decoded from the documented response shape. 89 90 Raises: 91 APIError: The API rejected the request or could not complete it. 92 NetworkError: The request could not reach the Inttegro API. 93 TimeoutError: The configured request deadline elapsed. 94 """ 95 return await self.http.post('/refunds/page', payload) 96 97 def _idempotency_headers(self, idempotency_key: str | None) -> dict[str, str]: 98 return {'Idempotency-Key': idempotency_key} if idempotency_key else {}
class
AsyncRefunds:
11class AsyncRefunds: 12 """Create, cancel, look up, and page through refunds. 13 14 Access this service as ``AsyncInttegroClient.refunds``. Methods use the client's shared transport and return the typed resource shapes documented below. 15 """ 16 17 def __init__(self, http: AsyncHttpClient): 18 self.http = http 19 20 async def create(self, payload: CreateRequest, idempotency_key: str | None=None) -> Refund: 21 """Create a refund for paid order line items. 22 23 API endpoint: ``/refunds/create``. 24 25 Args: 26 payload (CreateRequest): Typed request object or equivalent request mapping for this operation. 27 idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write. 28 29 Returns: 30 ``Refund`` decoded from the documented response shape. 31 32 Raises: 33 APIError: The API rejected the request or could not complete it. 34 NetworkError: The request could not reach the Inttegro API. 35 TimeoutError: The configured request deadline elapsed. 36 """ 37 return await self.http.post_with_headers('/refunds/create', payload, self._idempotency_headers(idempotency_key)) 38 39 async def cancel(self, refund_id: str, idempotency_key: str | None=None, *, reason: str | None=None) -> Refund: 40 """Cancel a pending refund. 41 42 API endpoint: ``/refunds/cancel``. 43 44 Args: 45 refund_id (str): Unique identifier of the refund. 46 idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write. 47 reason (str | None): Optional explanation for canceling the refund. 48 49 Returns: 50 ``Refund`` decoded from the documented response shape. 51 52 Raises: 53 APIError: The API rejected the request or could not complete it. 54 NetworkError: The request could not reach the Inttegro API. 55 TimeoutError: The configured request deadline elapsed. 56 """ 57 payload = {'refund_id': refund_id} 58 if reason is not None: 59 payload['reason'] = reason 60 return await self.http.post_with_headers('/refunds/cancel', payload, self._idempotency_headers(idempotency_key)) 61 62 async def lookup(self, refund_id: str) -> Refund: 63 """Look up a refund by ID. 64 65 API endpoint: ``/refunds/lookup``. 66 67 Args: 68 refund_id (str): Unique identifier of the refund. 69 70 Returns: 71 ``Refund`` decoded from the documented response shape. 72 73 Raises: 74 APIError: The API rejected the request or could not complete it. 75 NetworkError: The request could not reach the Inttegro API. 76 TimeoutError: The configured request deadline elapsed. 77 """ 78 return await self.http.post('/refunds/lookup', {'refund_id': refund_id}) 79 80 async def page(self, payload: PageRequest) -> Page: 81 """Page through refunds. 82 83 API endpoint: ``/refunds/page``. 84 85 Args: 86 payload (PageRequest): Typed request object or equivalent request mapping for this operation. 87 88 Returns: 89 ``Page`` decoded from the documented response shape. 90 91 Raises: 92 APIError: The API rejected the request or could not complete it. 93 NetworkError: The request could not reach the Inttegro API. 94 TimeoutError: The configured request deadline elapsed. 95 """ 96 return await self.http.post('/refunds/page', payload) 97 98 def _idempotency_headers(self, idempotency_key: str | None) -> dict[str, str]: 99 return {'Idempotency-Key': idempotency_key} if idempotency_key else {}
Create, cancel, look up, and page through refunds.
Access this service as AsyncInttegroClient.refunds. Methods use the client's shared transport and return the typed resource shapes documented below.
async def
create( self, payload: inttegro.refund.CreateRequest, idempotency_key: str | None = None) -> inttegro.refund.Refund:
20 async def create(self, payload: CreateRequest, idempotency_key: str | None=None) -> Refund: 21 """Create a refund for paid order line items. 22 23 API endpoint: ``/refunds/create``. 24 25 Args: 26 payload (CreateRequest): Typed request object or equivalent request mapping for this operation. 27 idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write. 28 29 Returns: 30 ``Refund`` decoded from the documented response shape. 31 32 Raises: 33 APIError: The API rejected the request or could not complete it. 34 NetworkError: The request could not reach the Inttegro API. 35 TimeoutError: The configured request deadline elapsed. 36 """ 37 return await self.http.post_with_headers('/refunds/create', payload, self._idempotency_headers(idempotency_key))
Create a refund for paid order line items.
API endpoint: /refunds/create.
Arguments:
- payload (CreateRequest): Typed request object or equivalent request mapping for this operation.
- idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write.
Returns:
Refunddecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.
async def
cancel( self, refund_id: str, idempotency_key: str | None = None) -> inttegro.refund.Refund:
39 async def cancel(self, refund_id: str, idempotency_key: str | None=None, *, reason: str | None=None) -> Refund: 40 """Cancel a pending refund. 41 42 API endpoint: ``/refunds/cancel``. 43 44 Args: 45 refund_id (str): Unique identifier of the refund. 46 idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write. 47 reason (str | None): Optional explanation for canceling the refund. 48 49 Returns: 50 ``Refund`` decoded from the documented response shape. 51 52 Raises: 53 APIError: The API rejected the request or could not complete it. 54 NetworkError: The request could not reach the Inttegro API. 55 TimeoutError: The configured request deadline elapsed. 56 """ 57 payload = {'refund_id': refund_id} 58 if reason is not None: 59 payload['reason'] = reason 60 return await self.http.post_with_headers('/refunds/cancel', payload, self._idempotency_headers(idempotency_key))
Cancel a pending refund.
API endpoint: /refunds/cancel.
Arguments:
- refund_id (str): Unique identifier of the refund.
- idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write.
- reason (str | None): Optional explanation for canceling the refund.
Returns:
Refunddecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.
62 async def lookup(self, refund_id: str) -> Refund: 63 """Look up a refund by ID. 64 65 API endpoint: ``/refunds/lookup``. 66 67 Args: 68 refund_id (str): Unique identifier of the refund. 69 70 Returns: 71 ``Refund`` decoded from the documented response shape. 72 73 Raises: 74 APIError: The API rejected the request or could not complete it. 75 NetworkError: The request could not reach the Inttegro API. 76 TimeoutError: The configured request deadline elapsed. 77 """ 78 return await self.http.post('/refunds/lookup', {'refund_id': refund_id})
Look up a refund by ID.
API endpoint: /refunds/lookup.
Arguments:
- refund_id (str): Unique identifier of the refund.
Returns:
Refunddecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.
80 async def page(self, payload: PageRequest) -> Page: 81 """Page through refunds. 82 83 API endpoint: ``/refunds/page``. 84 85 Args: 86 payload (PageRequest): Typed request object or equivalent request mapping for this operation. 87 88 Returns: 89 ``Page`` decoded from the documented response shape. 90 91 Raises: 92 APIError: The API rejected the request or could not complete it. 93 NetworkError: The request could not reach the Inttegro API. 94 TimeoutError: The configured request deadline elapsed. 95 """ 96 return await self.http.post('/refunds/page', payload)
Page through refunds.
API endpoint: /refunds/page.
Arguments:
- payload (PageRequest): Typed request object or equivalent request mapping for this operation.
Returns:
Pagedecoded from the documented response shape.
Raises:
- APIError: The API rejected the request or could not complete it.
- NetworkError: The request could not reach the Inttegro API.
- TimeoutError: The configured request deadline elapsed.