Debian Codegraph @

stripe/treasury/_debit_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._debit_reversal_create_params import (
13 DebitReversalCreateParams,
14 )
15 from stripe.params.treasury._debit_reversal_list_params import (
16 DebitReversalListParams,
17 )
18 from stripe.params.treasury._debit_reversal_retrieve_params import (
19 DebitReversalRetrieveParams,
20 )
21 from stripe.treasury._transaction import Transaction
22
23
24 class DebitReversal(
25 CreateableAPIResource["DebitReversal"],
26 ListableAPIResource["DebitReversal"],
27 ):
28 """
29 You can reverse some [ReceivedDebits](https://api.stripe.com#received_debits) depending on their network and source flow. Reversing a ReceivedDebit leads to the creation of a new object known as a DebitReversal.
30 """
31
32 OBJECT_NAME: ClassVar[Literal["treasury.debit_reversal"]] = (
33 "treasury.debit_reversal"
34 )
35
36 class LinkedFlows(StripeObject):
37 issuing_dispute: Optional[str]
38 """
39 Set if there is an Issuing dispute associated with the DebitReversal.
40 """
41
42 class StatusTransitions(StripeObject):
43 completed_at: Optional[int]
44 """
45 Timestamp describing when the DebitReversal changed status to `completed`.
46 """
47
48 amount: int
49 """
50 Amount (in cents) transferred.
51 """
52 created: int
53 """
54 Time at which the object was created. Measured in seconds since the Unix epoch.
55 """
56 currency: str
57 """
58 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).
59 """
60 financial_account: Optional[str]
61 """
62 The FinancialAccount to reverse funds from.
63 """
64 hosted_regulatory_receipt_url: Optional[str]
65 """
66 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.
67 """
68 id: str
69 """
70 Unique identifier for the object.
71 """
72 linked_flows: Optional[LinkedFlows]
73 """
74 Other flows linked to a DebitReversal.
75 """
76 livemode: bool
77 """
78 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
79 """
80 metadata: Dict[str, str]
81 """
82 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.
83 """
84 network: Literal["ach", "card"]
85 """
86 The rails used to reverse the funds.
87 """
88 object: Literal["treasury.debit_reversal"]
89 """
90 String representing the object's type. Objects of the same type share the same value.
91 """
92 received_debit: str
93 """
94 The ReceivedDebit being reversed.
95 """
96 status: Literal["failed", "processing", "succeeded"]
97 """
98 Status of the DebitReversal
99 """
100 status_transitions: StatusTransitions
101 transaction: Optional[ExpandableField["Transaction"]]
102 """
103 The Transaction associated with this object.
104 """
105
106 @classmethod
107 def create(
108 cls, **params: Unpack["DebitReversalCreateParams"]
109 ) -> "DebitReversal":
110 """
111 Reverses a ReceivedDebit and creates a DebitReversal object.
112 """
113 return cast(
114 "DebitReversal",
115 cls._static_request(
116 "post",
117 cls.class_url(),
118 params=params,
119 ),
120 )
121
122 @classmethod
123 async def create_async(
124 cls, **params: Unpack["DebitReversalCreateParams"]
125 ) -> "DebitReversal":
126 """
127 Reverses a ReceivedDebit and creates a DebitReversal object.
128 """
129 return cast(
130 "DebitReversal",
131 await cls._static_request_async(
132 "post",
133 cls.class_url(),
134 params=params,
135 ),
136 )
137
138 @classmethod
139 def list(
140 cls, **params: Unpack["DebitReversalListParams"]
141 ) -> ListObject["DebitReversal"]:
142 """
143 Returns a list of DebitReversals.
144 """
145 result = cls._static_request(
146 "get",
147 cls.class_url(),
148 params=params,
149 )
150 if not isinstance(result, ListObject):
151 raise TypeError(
152 "Expected list object from API, got %s"
153 % (type(result).__name__)
154 )
155
156 return result
157
158 @classmethod
159 async def list_async(
160 cls, **params: Unpack["DebitReversalListParams"]
161 ) -> ListObject["DebitReversal"]:
162 """
163 Returns a list of DebitReversals.
164 """
165 result = await cls._static_request_async(
166 "get",
167 cls.class_url(),
168 params=params,
169 )
170 if not isinstance(result, ListObject):
171 raise TypeError(
172 "Expected list object from API, got %s"
173 % (type(result).__name__)
174 )
175
176 return result
177
178 @classmethod
179 def retrieve(
180 cls, id: str, **params: Unpack["DebitReversalRetrieveParams"]
181 ) -> "DebitReversal":
182 """
183 Retrieves a DebitReversal object.
184 """
185 instance = cls(id, **params)
186 instance.refresh()
187 return instance
188
189 @classmethod
190 async def retrieve_async(
191 cls, id: str, **params: Unpack["DebitReversalRetrieveParams"]
192 ) -> "DebitReversal":
193 """
194 Retrieves a DebitReversal object.
195 """
196 instance = cls(id, **params)
197 await instance.refresh_async()
198 return instance
199
200 _inner_class_types = {
201 "linked_flows": LinkedFlows,
202 "status_transitions": StatusTransitions,
203 }