Debian Codegraph @

stripe/treasury/_credit_reversal.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._createable_api_resource import CreateableAPIResource
4 from stripe._expandable_field import ExpandableField
5 from stripe._list_object import ListObject
6 from stripe._listable_api_resource import ListableAPIResource
7 from stripe._stripe_object import StripeObject
8 from typing import ClassVar, Dict, Optional, cast
9 from typing_extensions import Literal, Unpack, TYPE_CHECKING
10
11 if TYPE_CHECKING:
12 from stripe.params.treasury._credit_reversal_create_params import (
13 CreditReversalCreateParams,
14 )
15 from stripe.params.treasury._credit_reversal_list_params import (
16 CreditReversalListParams,
17 )
18 from stripe.params.treasury._credit_reversal_retrieve_params import (
19 CreditReversalRetrieveParams,
20 )
21 from stripe.treasury._transaction import Transaction
22
23
24 class CreditReversal(
25 CreateableAPIResource["CreditReversal"],
26 ListableAPIResource["CreditReversal"],
27 ):
28 """
29 You can reverse some [ReceivedCredits](https://api.stripe.com#received_credits) depending on their network and source flow. Reversing a ReceivedCredit leads to the creation of a new object known as a CreditReversal.
30 """
31
32 OBJECT_NAME: ClassVar[Literal["treasury.credit_reversal"]] = (
33 "treasury.credit_reversal"
34 )
35
36 class StatusTransitions(StripeObject):
37 posted_at: Optional[int]
38 """
39 Timestamp describing when the CreditReversal changed status to `posted`
40 """
41
42 amount: int
43 """
44 Amount (in cents) transferred.
45 """
46 created: int
47 """
48 Time at which the object was created. Measured in seconds since the Unix epoch.
49 """
50 currency: str
51 """
52 Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
53 """
54 financial_account: str
55 """
56 The FinancialAccount to reverse funds from.
57 """
58 hosted_regulatory_receipt_url: Optional[str]
59 """
60 A [hosted transaction receipt](https://docs.stripe.com/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.
61 """
62 id: str
63 """
64 Unique identifier for the object.
65 """
66 livemode: bool
67 """
68 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
69 """
70 metadata: Dict[str, str]
71 """
72 Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
73 """
74 network: Literal["ach", "stripe"]
75 """
76 The rails used to reverse the funds.
77 """
78 object: Literal["treasury.credit_reversal"]
79 """
80 String representing the object's type. Objects of the same type share the same value.
81 """
82 received_credit: str
83 """
84 The ReceivedCredit being reversed.
85 """
86 status: Literal["canceled", "posted", "processing"]
87 """
88 Status of the CreditReversal
89 """
90 status_transitions: StatusTransitions
91 transaction: Optional[ExpandableField["Transaction"]]
92 """
93 The Transaction associated with this object.
94 """
95
96 @classmethod
97 def create(
98 cls, **params: Unpack["CreditReversalCreateParams"]
99 ) -> "CreditReversal":
100 """
101 Reverses a ReceivedCredit and creates a CreditReversal object.
102 """
103 return cast(
104 "CreditReversal",
105 cls._static_request(
106 "post",
107 cls.class_url(),
108 params=params,
109 ),
110 )
111
112 @classmethod
113 async def create_async(
114 cls, **params: Unpack["CreditReversalCreateParams"]
115 ) -> "CreditReversal":
116 """
117 Reverses a ReceivedCredit and creates a CreditReversal object.
118 """
119 return cast(
120 "CreditReversal",
121 await cls._static_request_async(
122 "post",
123 cls.class_url(),
124 params=params,
125 ),
126 )
127
128 @classmethod
129 def list(
130 cls, **params: Unpack["CreditReversalListParams"]
131 ) -> ListObject["CreditReversal"]:
132 """
133 Returns a list of CreditReversals.
134 """
135 result = cls._static_request(
136 "get",
137 cls.class_url(),
138 params=params,
139 )
140 if not isinstance(result, ListObject):
141 raise TypeError(
142 "Expected list object from API, got %s"
143 % (type(result).__name__)
144 )
145
146 return result
147
148 @classmethod
149 async def list_async(
150 cls, **params: Unpack["CreditReversalListParams"]
151 ) -> ListObject["CreditReversal"]:
152 """
153 Returns a list of CreditReversals.
154 """
155 result = await cls._static_request_async(
156 "get",
157 cls.class_url(),
158 params=params,
159 )
160 if not isinstance(result, ListObject):
161 raise TypeError(
162 "Expected list object from API, got %s"
163 % (type(result).__name__)
164 )
165
166 return result
167
168 @classmethod
169 def retrieve(
170 cls, id: str, **params: Unpack["CreditReversalRetrieveParams"]
171 ) -> "CreditReversal":
172 """
173 Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID from either the CreditReversal creation request or CreditReversal list
174 """
175 instance = cls(id, **params)
176 instance.refresh()
177 return instance
178
179 @classmethod
180 async def retrieve_async(
181 cls, id: str, **params: Unpack["CreditReversalRetrieveParams"]
182 ) -> "CreditReversal":
183 """
184 Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID from either the CreditReversal creation request or CreditReversal list
185 """
186 instance = cls(id, **params)
187 await instance.refresh_async()
188 return instance
189
190 _inner_class_types = {"status_transitions": StatusTransitions}