Debian Codegraph @

stripe/billing/_credit_grant_service.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._stripe_service import StripeService
4 from stripe._util import sanitize_id
5 from typing import Optional, cast
6 from typing_extensions import TYPE_CHECKING
7
8 if TYPE_CHECKING:
9 from stripe._list_object import ListObject
10 from stripe._request_options import RequestOptions
11 from stripe.billing._credit_grant import CreditGrant
12 from stripe.params.billing._credit_grant_create_params import (
13 CreditGrantCreateParams,
14 )
15 from stripe.params.billing._credit_grant_expire_params import (
16 CreditGrantExpireParams,
17 )
18 from stripe.params.billing._credit_grant_list_params import (
19 CreditGrantListParams,
20 )
21 from stripe.params.billing._credit_grant_retrieve_params import (
22 CreditGrantRetrieveParams,
23 )
24 from stripe.params.billing._credit_grant_update_params import (
25 CreditGrantUpdateParams,
26 )
27 from stripe.params.billing._credit_grant_void_grant_params import (
28 CreditGrantVoidGrantParams,
29 )
30
31
32 class CreditGrantService(StripeService):
33 def list(
34 self,
35 params: Optional["CreditGrantListParams"] = None,
36 options: Optional["RequestOptions"] = None,
37 ) -> "ListObject[CreditGrant]":
38 """
39 Retrieve a list of credit grants.
40 """
41 return cast(
42 "ListObject[CreditGrant]",
43 self._request(
44 "get",
45 "/v1/billing/credit_grants",
46 base_address="api",
47 params=params,
48 options=options,
49 ),
50 )
51
52 async def list_async(
53 self,
54 params: Optional["CreditGrantListParams"] = None,
55 options: Optional["RequestOptions"] = None,
56 ) -> "ListObject[CreditGrant]":
57 """
58 Retrieve a list of credit grants.
59 """
60 return cast(
61 "ListObject[CreditGrant]",
62 await self._request_async(
63 "get",
64 "/v1/billing/credit_grants",
65 base_address="api",
66 params=params,
67 options=options,
68 ),
69 )
70
71 def create(
72 self,
73 params: "CreditGrantCreateParams",
74 options: Optional["RequestOptions"] = None,
75 ) -> "CreditGrant":
76 """
77 Creates a credit grant.
78 """
79 return cast(
80 "CreditGrant",
81 self._request(
82 "post",
83 "/v1/billing/credit_grants",
84 base_address="api",
85 params=params,
86 options=options,
87 ),
88 )
89
90 async def create_async(
91 self,
92 params: "CreditGrantCreateParams",
93 options: Optional["RequestOptions"] = None,
94 ) -> "CreditGrant":
95 """
96 Creates a credit grant.
97 """
98 return cast(
99 "CreditGrant",
100 await self._request_async(
101 "post",
102 "/v1/billing/credit_grants",
103 base_address="api",
104 params=params,
105 options=options,
106 ),
107 )
108
109 def retrieve(
110 self,
111 id: str,
112 params: Optional["CreditGrantRetrieveParams"] = None,
113 options: Optional["RequestOptions"] = None,
114 ) -> "CreditGrant":
115 """
116 Retrieves a credit grant.
117 """
118 return cast(
119 "CreditGrant",
120 self._request(
121 "get",
122 "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)),
123 base_address="api",
124 params=params,
125 options=options,
126 ),
127 )
128
129 async def retrieve_async(
130 self,
131 id: str,
132 params: Optional["CreditGrantRetrieveParams"] = None,
133 options: Optional["RequestOptions"] = None,
134 ) -> "CreditGrant":
135 """
136 Retrieves a credit grant.
137 """
138 return cast(
139 "CreditGrant",
140 await self._request_async(
141 "get",
142 "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)),
143 base_address="api",
144 params=params,
145 options=options,
146 ),
147 )
148
149 def update(
150 self,
151 id: str,
152 params: Optional["CreditGrantUpdateParams"] = None,
153 options: Optional["RequestOptions"] = None,
154 ) -> "CreditGrant":
155 """
156 Updates a credit grant.
157 """
158 return cast(
159 "CreditGrant",
160 self._request(
161 "post",
162 "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)),
163 base_address="api",
164 params=params,
165 options=options,
166 ),
167 )
168
169 async def update_async(
170 self,
171 id: str,
172 params: Optional["CreditGrantUpdateParams"] = None,
173 options: Optional["RequestOptions"] = None,
174 ) -> "CreditGrant":
175 """
176 Updates a credit grant.
177 """
178 return cast(
179 "CreditGrant",
180 await self._request_async(
181 "post",
182 "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)),
183 base_address="api",
184 params=params,
185 options=options,
186 ),
187 )
188
189 def expire(
190 self,
191 id: str,
192 params: Optional["CreditGrantExpireParams"] = None,
193 options: Optional["RequestOptions"] = None,
194 ) -> "CreditGrant":
195 """
196 Expires a credit grant.
197 """
198 return cast(
199 "CreditGrant",
200 self._request(
201 "post",
202 "/v1/billing/credit_grants/{id}/expire".format(
203 id=sanitize_id(id),
204 ),
205 base_address="api",
206 params=params,
207 options=options,
208 ),
209 )
210
211 async def expire_async(
212 self,
213 id: str,
214 params: Optional["CreditGrantExpireParams"] = None,
215 options: Optional["RequestOptions"] = None,
216 ) -> "CreditGrant":
217 """
218 Expires a credit grant.
219 """
220 return cast(
221 "CreditGrant",
222 await self._request_async(
223 "post",
224 "/v1/billing/credit_grants/{id}/expire".format(
225 id=sanitize_id(id),
226 ),
227 base_address="api",
228 params=params,
229 options=options,
230 ),
231 )
232
233 def void_grant(
234 self,
235 id: str,
236 params: Optional["CreditGrantVoidGrantParams"] = None,
237 options: Optional["RequestOptions"] = None,
238 ) -> "CreditGrant":
239 """
240 Voids a credit grant.
241 """
242 return cast(
243 "CreditGrant",
244 self._request(
245 "post",
246 "/v1/billing/credit_grants/{id}/void".format(
247 id=sanitize_id(id),
248 ),
249 base_address="api",
250 params=params,
251 options=options,
252 ),
253 )
254
255 async def void_grant_async(
256 self,
257 id: str,
258 params: Optional["CreditGrantVoidGrantParams"] = None,
259 options: Optional["RequestOptions"] = None,
260 ) -> "CreditGrant":
261 """
262 Voids a credit grant.
263 """
264 return cast(
265 "CreditGrant",
266 await self._request_async(
267 "post",
268 "/v1/billing/credit_grants/{id}/void".format(
269 id=sanitize_id(id),
270 ),
271 base_address="api",
272 params=params,
273 options=options,
274 ),
275 )