inttegro.resources.refunds

Generated public typing surface. Do not edit by hand.

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

Create, cancel, look up, and page through refunds.

Access this service as InttegroClient.refunds. Methods use the client's shared transport and return the typed resource shapes documented below.

Refunds(http: inttegro.http_client.HttpClient)
19    def __init__(self, http: HttpClient):
20        self.http = http
http
def create( self, payload: inttegro.refund.CreateRequest, idempotency_key: str | None = None) -> inttegro.refund.Refund:
22    def create(self, payload: CreateRequest, idempotency_key: str | None = None) -> Refund:
23        """Create a refund for paid order line items.
24
25        API endpoint: ``/refunds/create``.
26
27        Args:
28            payload (CreateRequest): Typed request object or equivalent request mapping for this operation.
29            idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write.
30
31        Returns:
32            ``Refund`` decoded from the documented response shape.
33
34        Raises:
35            APIError: The API rejected the request or could not complete it.
36            NetworkError: The request could not reach the Inttegro API.
37            TimeoutError: The configured request deadline elapsed.
38        """
39        return self.http.post_with_headers(
40            "/refunds/create",
41            payload,
42            self._idempotency_headers(idempotency_key),
43        )

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:

Refund decoded 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.
def cancel( self, refund_id: str, idempotency_key: str | None = None) -> inttegro.refund.Refund:
45    def cancel(
46        self,
47        refund_id: str,
48        idempotency_key: str | None = None,
49        *,
50        reason: str | None = None,
51    ) -> Refund:
52        """Cancel a pending refund.
53
54        API endpoint: ``/refunds/cancel``.
55
56        Args:
57            refund_id (str): Unique identifier of the refund.
58            idempotency_key (str | None): Optional stable key to reuse when retrying the same logical write.
59            reason (str | None): Optional explanation for canceling the refund.
60
61        Returns:
62            ``Refund`` decoded from the documented response shape.
63
64        Raises:
65            APIError: The API rejected the request or could not complete it.
66            NetworkError: The request could not reach the Inttegro API.
67            TimeoutError: The configured request deadline elapsed.
68        """
69        payload = {"refund_id": refund_id}
70        if reason is not None:
71            payload["reason"] = reason
72        return self.http.post_with_headers(
73            "/refunds/cancel",
74            payload,
75            self._idempotency_headers(idempotency_key),
76        )

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:

Refund decoded 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.
def lookup(self, refund_id: str) -> inttegro.refund.Refund:
78    def lookup(self, refund_id: str) -> Refund:
79        """Look up a refund by ID.
80
81        API endpoint: ``/refunds/lookup``.
82
83        Args:
84            refund_id (str): Unique identifier of the refund.
85
86        Returns:
87            ``Refund`` decoded from the documented response shape.
88
89        Raises:
90            APIError: The API rejected the request or could not complete it.
91            NetworkError: The request could not reach the Inttegro API.
92            TimeoutError: The configured request deadline elapsed.
93        """
94        return 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:

Refund decoded 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.
def page( self, payload: inttegro.refund.PageRequest) -> inttegro.refund.Page:
 96    def page(self, payload: PageRequest) -> Page:
 97        """Page through refunds.
 98
 99        API endpoint: ``/refunds/page``.
100
101        Args:
102            payload (PageRequest): Typed request object or equivalent request mapping for this operation.
103
104        Returns:
105            ``Page`` decoded from the documented response shape.
106
107        Raises:
108            APIError: The API rejected the request or could not complete it.
109            NetworkError: The request could not reach the Inttegro API.
110            TimeoutError: The configured request deadline elapsed.
111        """
112        return 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:

Page decoded 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.