Debian Codegraph @

stripe/identity/_verification_session_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.identity._verification_session import VerificationSession
12 from stripe.params.identity._verification_session_cancel_params import (
13 VerificationSessionCancelParams,
14 )
15 from stripe.params.identity._verification_session_create_params import (
16 VerificationSessionCreateParams,
17 )
18 from stripe.params.identity._verification_session_list_params import (
19 VerificationSessionListParams,
20 )
21 from stripe.params.identity._verification_session_redact_params import (
22 VerificationSessionRedactParams,
23 )
24 from stripe.params.identity._verification_session_retrieve_params import (
25 VerificationSessionRetrieveParams,
26 )
27 from stripe.params.identity._verification_session_update_params import (
28 VerificationSessionUpdateParams,
29 )
30
31
32 class VerificationSessionService(StripeService):
33 def list(
34 self,
35 params: Optional["VerificationSessionListParams"] = None,
36 options: Optional["RequestOptions"] = None,
37 ) -> "ListObject[VerificationSession]":
38 """
39 Returns a list of VerificationSessions
40 """
41 return cast(
42 "ListObject[VerificationSession]",
43 self._request(
44 "get",
45 "/v1/identity/verification_sessions",
46 base_address="api",
47 params=params,
48 options=options,
49 ),
50 )
51
52 async def list_async(
53 self,
54 params: Optional["VerificationSessionListParams"] = None,
55 options: Optional["RequestOptions"] = None,
56 ) -> "ListObject[VerificationSession]":
57 """
58 Returns a list of VerificationSessions
59 """
60 return cast(
61 "ListObject[VerificationSession]",
62 await self._request_async(
63 "get",
64 "/v1/identity/verification_sessions",
65 base_address="api",
66 params=params,
67 options=options,
68 ),
69 )
70
71 def create(
72 self,
73 params: Optional["VerificationSessionCreateParams"] = None,
74 options: Optional["RequestOptions"] = None,
75 ) -> "VerificationSession":
76 """
77 Creates a VerificationSession object.
78
79 After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session's url.
80
81 If your API key is in test mode, verification checks won't actually process, though everything else will occur as if in live mode.
82
83 Related guide: [Verify your users' identity documents](https://docs.stripe.com/docs/identity/verify-identity-documents)
84 """
85 return cast(
86 "VerificationSession",
87 self._request(
88 "post",
89 "/v1/identity/verification_sessions",
90 base_address="api",
91 params=params,
92 options=options,
93 ),
94 )
95
96 async def create_async(
97 self,
98 params: Optional["VerificationSessionCreateParams"] = None,
99 options: Optional["RequestOptions"] = None,
100 ) -> "VerificationSession":
101 """
102 Creates a VerificationSession object.
103
104 After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session's url.
105
106 If your API key is in test mode, verification checks won't actually process, though everything else will occur as if in live mode.
107
108 Related guide: [Verify your users' identity documents](https://docs.stripe.com/docs/identity/verify-identity-documents)
109 """
110 return cast(
111 "VerificationSession",
112 await self._request_async(
113 "post",
114 "/v1/identity/verification_sessions",
115 base_address="api",
116 params=params,
117 options=options,
118 ),
119 )
120
121 def retrieve(
122 self,
123 session: str,
124 params: Optional["VerificationSessionRetrieveParams"] = None,
125 options: Optional["RequestOptions"] = None,
126 ) -> "VerificationSession":
127 """
128 Retrieves the details of a VerificationSession that was previously created.
129
130 When the session status is requires_input, you can use this method to retrieve a valid
131 client_secret or url to allow re-submission.
132 """
133 return cast(
134 "VerificationSession",
135 self._request(
136 "get",
137 "/v1/identity/verification_sessions/{session}".format(
138 session=sanitize_id(session),
139 ),
140 base_address="api",
141 params=params,
142 options=options,
143 ),
144 )
145
146 async def retrieve_async(
147 self,
148 session: str,
149 params: Optional["VerificationSessionRetrieveParams"] = None,
150 options: Optional["RequestOptions"] = None,
151 ) -> "VerificationSession":
152 """
153 Retrieves the details of a VerificationSession that was previously created.
154
155 When the session status is requires_input, you can use this method to retrieve a valid
156 client_secret or url to allow re-submission.
157 """
158 return cast(
159 "VerificationSession",
160 await self._request_async(
161 "get",
162 "/v1/identity/verification_sessions/{session}".format(
163 session=sanitize_id(session),
164 ),
165 base_address="api",
166 params=params,
167 options=options,
168 ),
169 )
170
171 def update(
172 self,
173 session: str,
174 params: Optional["VerificationSessionUpdateParams"] = None,
175 options: Optional["RequestOptions"] = None,
176 ) -> "VerificationSession":
177 """
178 Updates a VerificationSession object.
179
180 When the session status is requires_input, you can use this method to update the
181 verification check and options.
182 """
183 return cast(
184 "VerificationSession",
185 self._request(
186 "post",
187 "/v1/identity/verification_sessions/{session}".format(
188 session=sanitize_id(session),
189 ),
190 base_address="api",
191 params=params,
192 options=options,
193 ),
194 )
195
196 async def update_async(
197 self,
198 session: str,
199 params: Optional["VerificationSessionUpdateParams"] = None,
200 options: Optional["RequestOptions"] = None,
201 ) -> "VerificationSession":
202 """
203 Updates a VerificationSession object.
204
205 When the session status is requires_input, you can use this method to update the
206 verification check and options.
207 """
208 return cast(
209 "VerificationSession",
210 await self._request_async(
211 "post",
212 "/v1/identity/verification_sessions/{session}".format(
213 session=sanitize_id(session),
214 ),
215 base_address="api",
216 params=params,
217 options=options,
218 ),
219 )
220
221 def cancel(
222 self,
223 session: str,
224 params: Optional["VerificationSessionCancelParams"] = None,
225 options: Optional["RequestOptions"] = None,
226 ) -> "VerificationSession":
227 """
228 A VerificationSession object can be canceled when it is in requires_input [status](https://docs.stripe.com/docs/identity/how-sessions-work).
229
230 Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://docs.stripe.com/docs/identity/verification-sessions#cancel).
231 """
232 return cast(
233 "VerificationSession",
234 self._request(
235 "post",
236 "/v1/identity/verification_sessions/{session}/cancel".format(
237 session=sanitize_id(session),
238 ),
239 base_address="api",
240 params=params,
241 options=options,
242 ),
243 )
244
245 async def cancel_async(
246 self,
247 session: str,
248 params: Optional["VerificationSessionCancelParams"] = None,
249 options: Optional["RequestOptions"] = None,
250 ) -> "VerificationSession":
251 """
252 A VerificationSession object can be canceled when it is in requires_input [status](https://docs.stripe.com/docs/identity/how-sessions-work).
253
254 Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://docs.stripe.com/docs/identity/verification-sessions#cancel).
255 """
256 return cast(
257 "VerificationSession",
258 await self._request_async(
259 "post",
260 "/v1/identity/verification_sessions/{session}/cancel".format(
261 session=sanitize_id(session),
262 ),
263 base_address="api",
264 params=params,
265 options=options,
266 ),
267 )
268
269 def redact(
270 self,
271 session: str,
272 params: Optional["VerificationSessionRedactParams"] = None,
273 options: Optional["RequestOptions"] = None,
274 ) -> "VerificationSession":
275 """
276 Redact a VerificationSession to remove all collected information from Stripe. This will redact
277 the VerificationSession and all objects related to it, including VerificationReports, Events,
278 request logs, etc.
279
280 A VerificationSession object can be redacted when it is in requires_input or verified
281 [status](https://docs.stripe.com/docs/identity/how-sessions-work). Redacting a VerificationSession in requires_action
282 state will automatically cancel it.
283
284 The redaction process may take up to four days. When the redaction process is in progress, the
285 VerificationSession's redaction.status field will be set to processing; when the process is
286 finished, it will change to redacted and an identity.verification_session.redacted event
287 will be emitted.
288
289 Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the
290 fields that contain personal data will be replaced by the string [redacted] or a similar
291 placeholder. The metadata field will also be erased. Redacted objects cannot be updated or
292 used for any purpose.
293
294 [Learn more](https://docs.stripe.com/docs/identity/verification-sessions#redact).
295 """
296 return cast(
297 "VerificationSession",
298 self._request(
299 "post",
300 "/v1/identity/verification_sessions/{session}/redact".format(
301 session=sanitize_id(session),
302 ),
303 base_address="api",
304 params=params,
305 options=options,
306 ),
307 )
308
309 async def redact_async(
310 self,
311 session: str,
312 params: Optional["VerificationSessionRedactParams"] = None,
313 options: Optional["RequestOptions"] = None,
314 ) -> "VerificationSession":
315 """
316 Redact a VerificationSession to remove all collected information from Stripe. This will redact
317 the VerificationSession and all objects related to it, including VerificationReports, Events,
318 request logs, etc.
319
320 A VerificationSession object can be redacted when it is in requires_input or verified
321 [status](https://docs.stripe.com/docs/identity/how-sessions-work). Redacting a VerificationSession in requires_action
322 state will automatically cancel it.
323
324 The redaction process may take up to four days. When the redaction process is in progress, the
325 VerificationSession's redaction.status field will be set to processing; when the process is
326 finished, it will change to redacted and an identity.verification_session.redacted event
327 will be emitted.
328
329 Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the
330 fields that contain personal data will be replaced by the string [redacted] or a similar
331 placeholder. The metadata field will also be erased. Redacted objects cannot be updated or
332 used for any purpose.
333
334 [Learn more](https://docs.stripe.com/docs/identity/verification-sessions#redact).
335 """
336 return cast(
337 "VerificationSession",
338 await self._request_async(
339 "post",
340 "/v1/identity/verification_sessions/{session}/redact".format(
341 session=sanitize_id(session),
342 ),
343 base_address="api",
344 params=params,
345 options=options,
346 ),
347 )