stripe_misc/identity_verification_session/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListIdentityVerificationSessionBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    client_reference_id: Option<String>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    created: Option<stripe_types::RangeQueryTs>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    ending_before: Option<String>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    expand: Option<Vec<String>>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    limit: Option<i64>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    related_customer: Option<String>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    starting_after: Option<String>,
21    #[serde(skip_serializing_if = "Option::is_none")]
22    status: Option<stripe_misc::IdentityVerificationSessionStatus>,
23}
24impl ListIdentityVerificationSessionBuilder {
25    fn new() -> Self {
26        Self {
27            client_reference_id: None,
28            created: None,
29            ending_before: None,
30            expand: None,
31            limit: None,
32            related_customer: None,
33            starting_after: None,
34            status: None,
35        }
36    }
37}
38/// Returns a list of VerificationSessions
39#[derive(Clone, Debug, serde::Serialize)]
40pub struct ListIdentityVerificationSession {
41    inner: ListIdentityVerificationSessionBuilder,
42}
43impl ListIdentityVerificationSession {
44    /// Construct a new `ListIdentityVerificationSession`.
45    pub fn new() -> Self {
46        Self { inner: ListIdentityVerificationSessionBuilder::new() }
47    }
48    /// A string to reference this user.
49    /// This can be a customer ID, a session ID, or similar, and can be used to reconcile this verification with your internal systems.
50    pub fn client_reference_id(mut self, client_reference_id: impl Into<String>) -> Self {
51        self.inner.client_reference_id = Some(client_reference_id.into());
52        self
53    }
54    /// Only return VerificationSessions that were created during the given date interval.
55    pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
56        self.inner.created = Some(created.into());
57        self
58    }
59    /// A cursor for use in pagination.
60    /// `ending_before` is an object ID that defines your place in the list.
61    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
62    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
63        self.inner.ending_before = Some(ending_before.into());
64        self
65    }
66    /// Specifies which fields in the response should be expanded.
67    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
68        self.inner.expand = Some(expand.into());
69        self
70    }
71    /// A limit on the number of objects to be returned.
72    /// Limit can range between 1 and 100, and the default is 10.
73    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
74        self.inner.limit = Some(limit.into());
75        self
76    }
77    pub fn related_customer(mut self, related_customer: impl Into<String>) -> Self {
78        self.inner.related_customer = Some(related_customer.into());
79        self
80    }
81    /// A cursor for use in pagination.
82    /// `starting_after` is an object ID that defines your place in the list.
83    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
84    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
85        self.inner.starting_after = Some(starting_after.into());
86        self
87    }
88    /// Only return VerificationSessions with this status.
89    /// [Learn more about the lifecycle of sessions](https://stripe.com/docs/identity/how-sessions-work).
90    pub fn status(
91        mut self,
92        status: impl Into<stripe_misc::IdentityVerificationSessionStatus>,
93    ) -> Self {
94        self.inner.status = Some(status.into());
95        self
96    }
97}
98impl Default for ListIdentityVerificationSession {
99    fn default() -> Self {
100        Self::new()
101    }
102}
103impl ListIdentityVerificationSession {
104    /// Send the request and return the deserialized response.
105    pub async fn send<C: StripeClient>(
106        &self,
107        client: &C,
108    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
109        self.customize().send(client).await
110    }
111
112    /// Send the request and return the deserialized response, blocking until completion.
113    pub fn send_blocking<C: StripeBlockingClient>(
114        &self,
115        client: &C,
116    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
117        self.customize().send_blocking(client)
118    }
119
120    pub fn paginate(
121        &self,
122    ) -> stripe_client_core::ListPaginator<
123        stripe_types::List<stripe_misc::IdentityVerificationSession>,
124    > {
125        stripe_client_core::ListPaginator::new_list("/identity/verification_sessions", &self.inner)
126    }
127}
128
129impl StripeRequest for ListIdentityVerificationSession {
130    type Output = stripe_types::List<stripe_misc::IdentityVerificationSession>;
131
132    fn build(&self) -> RequestBuilder {
133        RequestBuilder::new(StripeMethod::Get, "/identity/verification_sessions").query(&self.inner)
134    }
135}
136#[derive(Clone, Debug, serde::Serialize)]
137struct RetrieveIdentityVerificationSessionBuilder {
138    #[serde(skip_serializing_if = "Option::is_none")]
139    expand: Option<Vec<String>>,
140}
141impl RetrieveIdentityVerificationSessionBuilder {
142    fn new() -> Self {
143        Self { expand: None }
144    }
145}
146/// Retrieves the details of a VerificationSession that was previously created.
147///
148/// When the session status is `requires_input`, you can use this method to retrieve a valid
149/// `client_secret` or `url` to allow re-submission.
150#[derive(Clone, Debug, serde::Serialize)]
151pub struct RetrieveIdentityVerificationSession {
152    inner: RetrieveIdentityVerificationSessionBuilder,
153    session: stripe_misc::IdentityVerificationSessionId,
154}
155impl RetrieveIdentityVerificationSession {
156    /// Construct a new `RetrieveIdentityVerificationSession`.
157    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
158        Self { session: session.into(), inner: RetrieveIdentityVerificationSessionBuilder::new() }
159    }
160    /// Specifies which fields in the response should be expanded.
161    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
162        self.inner.expand = Some(expand.into());
163        self
164    }
165}
166impl RetrieveIdentityVerificationSession {
167    /// Send the request and return the deserialized response.
168    pub async fn send<C: StripeClient>(
169        &self,
170        client: &C,
171    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
172        self.customize().send(client).await
173    }
174
175    /// Send the request and return the deserialized response, blocking until completion.
176    pub fn send_blocking<C: StripeBlockingClient>(
177        &self,
178        client: &C,
179    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
180        self.customize().send_blocking(client)
181    }
182}
183
184impl StripeRequest for RetrieveIdentityVerificationSession {
185    type Output = stripe_misc::IdentityVerificationSession;
186
187    fn build(&self) -> RequestBuilder {
188        let session = &self.session;
189        RequestBuilder::new(StripeMethod::Get, format!("/identity/verification_sessions/{session}"))
190            .query(&self.inner)
191    }
192}
193#[derive(Clone, Debug, serde::Serialize)]
194struct CreateIdentityVerificationSessionBuilder {
195    #[serde(skip_serializing_if = "Option::is_none")]
196    client_reference_id: Option<String>,
197    #[serde(skip_serializing_if = "Option::is_none")]
198    expand: Option<Vec<String>>,
199    #[serde(skip_serializing_if = "Option::is_none")]
200    metadata: Option<std::collections::HashMap<String, String>>,
201    #[serde(skip_serializing_if = "Option::is_none")]
202    options: Option<CreateIdentityVerificationSessionOptions>,
203    #[serde(skip_serializing_if = "Option::is_none")]
204    provided_details: Option<ProvidedDetailsParam>,
205    #[serde(skip_serializing_if = "Option::is_none")]
206    related_customer: Option<String>,
207    #[serde(skip_serializing_if = "Option::is_none")]
208    related_person: Option<CreateIdentityVerificationSessionRelatedPerson>,
209    #[serde(skip_serializing_if = "Option::is_none")]
210    return_url: Option<String>,
211    #[serde(rename = "type")]
212    #[serde(skip_serializing_if = "Option::is_none")]
213    type_: Option<CreateIdentityVerificationSessionType>,
214    #[serde(skip_serializing_if = "Option::is_none")]
215    verification_flow: Option<String>,
216}
217impl CreateIdentityVerificationSessionBuilder {
218    fn new() -> Self {
219        Self {
220            client_reference_id: None,
221            expand: None,
222            metadata: None,
223            options: None,
224            provided_details: None,
225            related_customer: None,
226            related_person: None,
227            return_url: None,
228            type_: None,
229            verification_flow: None,
230        }
231    }
232}
233/// A set of options for the session’s verification checks.
234#[derive(Clone, Debug, serde::Serialize)]
235pub struct CreateIdentityVerificationSessionOptions {
236    /// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
237    #[serde(skip_serializing_if = "Option::is_none")]
238    pub document: Option<CreateIdentityVerificationSessionOptionsDocument>,
239}
240impl CreateIdentityVerificationSessionOptions {
241    pub fn new() -> Self {
242        Self { document: None }
243    }
244}
245impl Default for CreateIdentityVerificationSessionOptions {
246    fn default() -> Self {
247        Self::new()
248    }
249}
250/// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
251#[derive(Clone, Debug, serde::Serialize)]
252pub struct CreateIdentityVerificationSessionOptionsDocument {
253    /// Array of strings of allowed identity document types.
254    /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
255    #[serde(skip_serializing_if = "Option::is_none")]
256    pub allowed_types: Option<Vec<CreateIdentityVerificationSessionOptionsDocumentAllowedTypes>>,
257    /// Collect an ID number and perform an [ID number check](https://stripe.com/docs/identity/verification-checks?type=id-number) with the document’s extracted name and date of birth.
258    #[serde(skip_serializing_if = "Option::is_none")]
259    pub require_id_number: Option<bool>,
260    /// Disable image uploads, identity document images have to be captured using the device’s camera.
261    #[serde(skip_serializing_if = "Option::is_none")]
262    pub require_live_capture: Option<bool>,
263    /// Capture a face image and perform a [selfie check](https://stripe.com/docs/identity/verification-checks?type=selfie) comparing a photo ID and a picture of your user’s face.
264    /// [Learn more](https://stripe.com/docs/identity/selfie).
265    #[serde(skip_serializing_if = "Option::is_none")]
266    pub require_matching_selfie: Option<bool>,
267}
268impl CreateIdentityVerificationSessionOptionsDocument {
269    pub fn new() -> Self {
270        Self {
271            allowed_types: None,
272            require_id_number: None,
273            require_live_capture: None,
274            require_matching_selfie: None,
275        }
276    }
277}
278impl Default for CreateIdentityVerificationSessionOptionsDocument {
279    fn default() -> Self {
280        Self::new()
281    }
282}
283/// Array of strings of allowed identity document types.
284/// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
285#[derive(Copy, Clone, Eq, PartialEq)]
286pub enum CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
287    DrivingLicense,
288    IdCard,
289    Passport,
290}
291impl CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
292    pub fn as_str(self) -> &'static str {
293        use CreateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
294        match self {
295            DrivingLicense => "driving_license",
296            IdCard => "id_card",
297            Passport => "passport",
298        }
299    }
300}
301
302impl std::str::FromStr for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
303    type Err = stripe_types::StripeParseError;
304    fn from_str(s: &str) -> Result<Self, Self::Err> {
305        use CreateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
306        match s {
307            "driving_license" => Ok(DrivingLicense),
308            "id_card" => Ok(IdCard),
309            "passport" => Ok(Passport),
310            _ => Err(stripe_types::StripeParseError),
311        }
312    }
313}
314impl std::fmt::Display for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
315    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
316        f.write_str(self.as_str())
317    }
318}
319
320impl std::fmt::Debug for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
321    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
322        f.write_str(self.as_str())
323    }
324}
325impl serde::Serialize for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
326    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
327    where
328        S: serde::Serializer,
329    {
330        serializer.serialize_str(self.as_str())
331    }
332}
333#[cfg(feature = "deserialize")]
334impl<'de> serde::Deserialize<'de> for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
335    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
336        use std::str::FromStr;
337        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
338        Self::from_str(&s).map_err(|_| {
339            serde::de::Error::custom(
340                "Unknown value for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes",
341            )
342        })
343    }
344}
345/// Tokens referencing a Person resource and it's associated account.
346#[derive(Clone, Debug, serde::Serialize)]
347pub struct CreateIdentityVerificationSessionRelatedPerson {
348    /// A token representing a connected account.
349    /// If provided, the person parameter is also required and must be associated with the account.
350    pub account: String,
351    /// A token referencing a Person resource that this verification is being used to verify.
352    pub person: String,
353}
354impl CreateIdentityVerificationSessionRelatedPerson {
355    pub fn new(account: impl Into<String>, person: impl Into<String>) -> Self {
356        Self { account: account.into(), person: person.into() }
357    }
358}
359/// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
360/// You must provide a `type` if not passing `verification_flow`.
361#[derive(Copy, Clone, Eq, PartialEq)]
362pub enum CreateIdentityVerificationSessionType {
363    Document,
364    IdNumber,
365}
366impl CreateIdentityVerificationSessionType {
367    pub fn as_str(self) -> &'static str {
368        use CreateIdentityVerificationSessionType::*;
369        match self {
370            Document => "document",
371            IdNumber => "id_number",
372        }
373    }
374}
375
376impl std::str::FromStr for CreateIdentityVerificationSessionType {
377    type Err = stripe_types::StripeParseError;
378    fn from_str(s: &str) -> Result<Self, Self::Err> {
379        use CreateIdentityVerificationSessionType::*;
380        match s {
381            "document" => Ok(Document),
382            "id_number" => Ok(IdNumber),
383            _ => Err(stripe_types::StripeParseError),
384        }
385    }
386}
387impl std::fmt::Display for CreateIdentityVerificationSessionType {
388    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
389        f.write_str(self.as_str())
390    }
391}
392
393impl std::fmt::Debug for CreateIdentityVerificationSessionType {
394    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
395        f.write_str(self.as_str())
396    }
397}
398impl serde::Serialize for CreateIdentityVerificationSessionType {
399    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
400    where
401        S: serde::Serializer,
402    {
403        serializer.serialize_str(self.as_str())
404    }
405}
406#[cfg(feature = "deserialize")]
407impl<'de> serde::Deserialize<'de> for CreateIdentityVerificationSessionType {
408    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
409        use std::str::FromStr;
410        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
411        Self::from_str(&s).map_err(|_| {
412            serde::de::Error::custom("Unknown value for CreateIdentityVerificationSessionType")
413        })
414    }
415}
416/// Creates a VerificationSession object.
417///
418/// After the VerificationSession is created, display a verification modal using the session `client_secret` or send your users to the session’s `url`.
419///
420/// If your API key is in test mode, verification checks won’t actually process, though everything else will occur as if in live mode.
421///
422/// Related guide: [Verify your users’ identity documents](https://stripe.com/docs/identity/verify-identity-documents).
423#[derive(Clone, Debug, serde::Serialize)]
424pub struct CreateIdentityVerificationSession {
425    inner: CreateIdentityVerificationSessionBuilder,
426}
427impl CreateIdentityVerificationSession {
428    /// Construct a new `CreateIdentityVerificationSession`.
429    pub fn new() -> Self {
430        Self { inner: CreateIdentityVerificationSessionBuilder::new() }
431    }
432    /// A string to reference this user.
433    /// This can be a customer ID, a session ID, or similar, and can be used to reconcile this verification with your internal systems.
434    pub fn client_reference_id(mut self, client_reference_id: impl Into<String>) -> Self {
435        self.inner.client_reference_id = Some(client_reference_id.into());
436        self
437    }
438    /// Specifies which fields in the response should be expanded.
439    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
440        self.inner.expand = Some(expand.into());
441        self
442    }
443    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
444    /// This can be useful for storing additional information about the object in a structured format.
445    /// Individual keys can be unset by posting an empty value to them.
446    /// All keys can be unset by posting an empty value to `metadata`.
447    pub fn metadata(
448        mut self,
449        metadata: impl Into<std::collections::HashMap<String, String>>,
450    ) -> Self {
451        self.inner.metadata = Some(metadata.into());
452        self
453    }
454    /// A set of options for the session’s verification checks.
455    pub fn options(mut self, options: impl Into<CreateIdentityVerificationSessionOptions>) -> Self {
456        self.inner.options = Some(options.into());
457        self
458    }
459    /// Details provided about the user being verified. These details may be shown to the user.
460    pub fn provided_details(mut self, provided_details: impl Into<ProvidedDetailsParam>) -> Self {
461        self.inner.provided_details = Some(provided_details.into());
462        self
463    }
464    /// Customer ID
465    pub fn related_customer(mut self, related_customer: impl Into<String>) -> Self {
466        self.inner.related_customer = Some(related_customer.into());
467        self
468    }
469    /// Tokens referencing a Person resource and it's associated account.
470    pub fn related_person(
471        mut self,
472        related_person: impl Into<CreateIdentityVerificationSessionRelatedPerson>,
473    ) -> Self {
474        self.inner.related_person = Some(related_person.into());
475        self
476    }
477    /// The URL that the user will be redirected to upon completing the verification flow.
478    pub fn return_url(mut self, return_url: impl Into<String>) -> Self {
479        self.inner.return_url = Some(return_url.into());
480        self
481    }
482    /// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
483    /// You must provide a `type` if not passing `verification_flow`.
484    pub fn type_(mut self, type_: impl Into<CreateIdentityVerificationSessionType>) -> Self {
485        self.inner.type_ = Some(type_.into());
486        self
487    }
488    /// The ID of a verification flow from the Dashboard.
489    /// See <https://docs.stripe.com/identity/verification-flows>.
490    pub fn verification_flow(mut self, verification_flow: impl Into<String>) -> Self {
491        self.inner.verification_flow = Some(verification_flow.into());
492        self
493    }
494}
495impl Default for CreateIdentityVerificationSession {
496    fn default() -> Self {
497        Self::new()
498    }
499}
500impl CreateIdentityVerificationSession {
501    /// Send the request and return the deserialized response.
502    pub async fn send<C: StripeClient>(
503        &self,
504        client: &C,
505    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
506        self.customize().send(client).await
507    }
508
509    /// Send the request and return the deserialized response, blocking until completion.
510    pub fn send_blocking<C: StripeBlockingClient>(
511        &self,
512        client: &C,
513    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
514        self.customize().send_blocking(client)
515    }
516}
517
518impl StripeRequest for CreateIdentityVerificationSession {
519    type Output = stripe_misc::IdentityVerificationSession;
520
521    fn build(&self) -> RequestBuilder {
522        RequestBuilder::new(StripeMethod::Post, "/identity/verification_sessions").form(&self.inner)
523    }
524}
525#[derive(Clone, Debug, serde::Serialize)]
526struct UpdateIdentityVerificationSessionBuilder {
527    #[serde(skip_serializing_if = "Option::is_none")]
528    expand: Option<Vec<String>>,
529    #[serde(skip_serializing_if = "Option::is_none")]
530    metadata: Option<std::collections::HashMap<String, String>>,
531    #[serde(skip_serializing_if = "Option::is_none")]
532    options: Option<UpdateIdentityVerificationSessionOptions>,
533    #[serde(skip_serializing_if = "Option::is_none")]
534    provided_details: Option<ProvidedDetailsParam>,
535    #[serde(rename = "type")]
536    #[serde(skip_serializing_if = "Option::is_none")]
537    type_: Option<UpdateIdentityVerificationSessionType>,
538}
539impl UpdateIdentityVerificationSessionBuilder {
540    fn new() -> Self {
541        Self { expand: None, metadata: None, options: None, provided_details: None, type_: None }
542    }
543}
544/// A set of options for the session’s verification checks.
545#[derive(Clone, Debug, serde::Serialize)]
546pub struct UpdateIdentityVerificationSessionOptions {
547    /// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
548    #[serde(skip_serializing_if = "Option::is_none")]
549    pub document: Option<UpdateIdentityVerificationSessionOptionsDocument>,
550}
551impl UpdateIdentityVerificationSessionOptions {
552    pub fn new() -> Self {
553        Self { document: None }
554    }
555}
556impl Default for UpdateIdentityVerificationSessionOptions {
557    fn default() -> Self {
558        Self::new()
559    }
560}
561/// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
562#[derive(Clone, Debug, serde::Serialize)]
563pub struct UpdateIdentityVerificationSessionOptionsDocument {
564    /// Array of strings of allowed identity document types.
565    /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
566    #[serde(skip_serializing_if = "Option::is_none")]
567    pub allowed_types: Option<Vec<UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes>>,
568    /// Collect an ID number and perform an [ID number check](https://stripe.com/docs/identity/verification-checks?type=id-number) with the document’s extracted name and date of birth.
569    #[serde(skip_serializing_if = "Option::is_none")]
570    pub require_id_number: Option<bool>,
571    /// Disable image uploads, identity document images have to be captured using the device’s camera.
572    #[serde(skip_serializing_if = "Option::is_none")]
573    pub require_live_capture: Option<bool>,
574    /// Capture a face image and perform a [selfie check](https://stripe.com/docs/identity/verification-checks?type=selfie) comparing a photo ID and a picture of your user’s face.
575    /// [Learn more](https://stripe.com/docs/identity/selfie).
576    #[serde(skip_serializing_if = "Option::is_none")]
577    pub require_matching_selfie: Option<bool>,
578}
579impl UpdateIdentityVerificationSessionOptionsDocument {
580    pub fn new() -> Self {
581        Self {
582            allowed_types: None,
583            require_id_number: None,
584            require_live_capture: None,
585            require_matching_selfie: None,
586        }
587    }
588}
589impl Default for UpdateIdentityVerificationSessionOptionsDocument {
590    fn default() -> Self {
591        Self::new()
592    }
593}
594/// Array of strings of allowed identity document types.
595/// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
596#[derive(Copy, Clone, Eq, PartialEq)]
597pub enum UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
598    DrivingLicense,
599    IdCard,
600    Passport,
601}
602impl UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
603    pub fn as_str(self) -> &'static str {
604        use UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
605        match self {
606            DrivingLicense => "driving_license",
607            IdCard => "id_card",
608            Passport => "passport",
609        }
610    }
611}
612
613impl std::str::FromStr for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
614    type Err = stripe_types::StripeParseError;
615    fn from_str(s: &str) -> Result<Self, Self::Err> {
616        use UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
617        match s {
618            "driving_license" => Ok(DrivingLicense),
619            "id_card" => Ok(IdCard),
620            "passport" => Ok(Passport),
621            _ => Err(stripe_types::StripeParseError),
622        }
623    }
624}
625impl std::fmt::Display for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
626    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
627        f.write_str(self.as_str())
628    }
629}
630
631impl std::fmt::Debug for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
632    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
633        f.write_str(self.as_str())
634    }
635}
636impl serde::Serialize for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
637    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
638    where
639        S: serde::Serializer,
640    {
641        serializer.serialize_str(self.as_str())
642    }
643}
644#[cfg(feature = "deserialize")]
645impl<'de> serde::Deserialize<'de> for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
646    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
647        use std::str::FromStr;
648        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
649        Self::from_str(&s).map_err(|_| {
650            serde::de::Error::custom(
651                "Unknown value for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes",
652            )
653        })
654    }
655}
656/// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
657#[derive(Copy, Clone, Eq, PartialEq)]
658pub enum UpdateIdentityVerificationSessionType {
659    Document,
660    IdNumber,
661}
662impl UpdateIdentityVerificationSessionType {
663    pub fn as_str(self) -> &'static str {
664        use UpdateIdentityVerificationSessionType::*;
665        match self {
666            Document => "document",
667            IdNumber => "id_number",
668        }
669    }
670}
671
672impl std::str::FromStr for UpdateIdentityVerificationSessionType {
673    type Err = stripe_types::StripeParseError;
674    fn from_str(s: &str) -> Result<Self, Self::Err> {
675        use UpdateIdentityVerificationSessionType::*;
676        match s {
677            "document" => Ok(Document),
678            "id_number" => Ok(IdNumber),
679            _ => Err(stripe_types::StripeParseError),
680        }
681    }
682}
683impl std::fmt::Display for UpdateIdentityVerificationSessionType {
684    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
685        f.write_str(self.as_str())
686    }
687}
688
689impl std::fmt::Debug for UpdateIdentityVerificationSessionType {
690    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
691        f.write_str(self.as_str())
692    }
693}
694impl serde::Serialize for UpdateIdentityVerificationSessionType {
695    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
696    where
697        S: serde::Serializer,
698    {
699        serializer.serialize_str(self.as_str())
700    }
701}
702#[cfg(feature = "deserialize")]
703impl<'de> serde::Deserialize<'de> for UpdateIdentityVerificationSessionType {
704    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
705        use std::str::FromStr;
706        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
707        Self::from_str(&s).map_err(|_| {
708            serde::de::Error::custom("Unknown value for UpdateIdentityVerificationSessionType")
709        })
710    }
711}
712/// Updates a VerificationSession object.
713///
714/// When the session status is `requires_input`, you can use this method to update the
715/// verification check and options.
716#[derive(Clone, Debug, serde::Serialize)]
717pub struct UpdateIdentityVerificationSession {
718    inner: UpdateIdentityVerificationSessionBuilder,
719    session: stripe_misc::IdentityVerificationSessionId,
720}
721impl UpdateIdentityVerificationSession {
722    /// Construct a new `UpdateIdentityVerificationSession`.
723    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
724        Self { session: session.into(), inner: UpdateIdentityVerificationSessionBuilder::new() }
725    }
726    /// Specifies which fields in the response should be expanded.
727    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
728        self.inner.expand = Some(expand.into());
729        self
730    }
731    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
732    /// This can be useful for storing additional information about the object in a structured format.
733    /// Individual keys can be unset by posting an empty value to them.
734    /// All keys can be unset by posting an empty value to `metadata`.
735    pub fn metadata(
736        mut self,
737        metadata: impl Into<std::collections::HashMap<String, String>>,
738    ) -> Self {
739        self.inner.metadata = Some(metadata.into());
740        self
741    }
742    /// A set of options for the session’s verification checks.
743    pub fn options(mut self, options: impl Into<UpdateIdentityVerificationSessionOptions>) -> Self {
744        self.inner.options = Some(options.into());
745        self
746    }
747    /// Details provided about the user being verified. These details may be shown to the user.
748    pub fn provided_details(mut self, provided_details: impl Into<ProvidedDetailsParam>) -> Self {
749        self.inner.provided_details = Some(provided_details.into());
750        self
751    }
752    /// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
753    pub fn type_(mut self, type_: impl Into<UpdateIdentityVerificationSessionType>) -> Self {
754        self.inner.type_ = Some(type_.into());
755        self
756    }
757}
758impl UpdateIdentityVerificationSession {
759    /// Send the request and return the deserialized response.
760    pub async fn send<C: StripeClient>(
761        &self,
762        client: &C,
763    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
764        self.customize().send(client).await
765    }
766
767    /// Send the request and return the deserialized response, blocking until completion.
768    pub fn send_blocking<C: StripeBlockingClient>(
769        &self,
770        client: &C,
771    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
772        self.customize().send_blocking(client)
773    }
774}
775
776impl StripeRequest for UpdateIdentityVerificationSession {
777    type Output = stripe_misc::IdentityVerificationSession;
778
779    fn build(&self) -> RequestBuilder {
780        let session = &self.session;
781        RequestBuilder::new(
782            StripeMethod::Post,
783            format!("/identity/verification_sessions/{session}"),
784        )
785        .form(&self.inner)
786    }
787}
788#[derive(Clone, Debug, serde::Serialize)]
789struct CancelIdentityVerificationSessionBuilder {
790    #[serde(skip_serializing_if = "Option::is_none")]
791    expand: Option<Vec<String>>,
792}
793impl CancelIdentityVerificationSessionBuilder {
794    fn new() -> Self {
795        Self { expand: None }
796    }
797}
798/// A VerificationSession object can be canceled when it is in `requires_input` [status](https://stripe.com/docs/identity/how-sessions-work).
799///
800/// Once canceled, future submission attempts are disabled.
801/// This cannot be undone.
802/// [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel).
803#[derive(Clone, Debug, serde::Serialize)]
804pub struct CancelIdentityVerificationSession {
805    inner: CancelIdentityVerificationSessionBuilder,
806    session: stripe_misc::IdentityVerificationSessionId,
807}
808impl CancelIdentityVerificationSession {
809    /// Construct a new `CancelIdentityVerificationSession`.
810    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
811        Self { session: session.into(), inner: CancelIdentityVerificationSessionBuilder::new() }
812    }
813    /// Specifies which fields in the response should be expanded.
814    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
815        self.inner.expand = Some(expand.into());
816        self
817    }
818}
819impl CancelIdentityVerificationSession {
820    /// Send the request and return the deserialized response.
821    pub async fn send<C: StripeClient>(
822        &self,
823        client: &C,
824    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
825        self.customize().send(client).await
826    }
827
828    /// Send the request and return the deserialized response, blocking until completion.
829    pub fn send_blocking<C: StripeBlockingClient>(
830        &self,
831        client: &C,
832    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
833        self.customize().send_blocking(client)
834    }
835}
836
837impl StripeRequest for CancelIdentityVerificationSession {
838    type Output = stripe_misc::IdentityVerificationSession;
839
840    fn build(&self) -> RequestBuilder {
841        let session = &self.session;
842        RequestBuilder::new(
843            StripeMethod::Post,
844            format!("/identity/verification_sessions/{session}/cancel"),
845        )
846        .form(&self.inner)
847    }
848}
849#[derive(Clone, Debug, serde::Serialize)]
850struct RedactIdentityVerificationSessionBuilder {
851    #[serde(skip_serializing_if = "Option::is_none")]
852    expand: Option<Vec<String>>,
853}
854impl RedactIdentityVerificationSessionBuilder {
855    fn new() -> Self {
856        Self { expand: None }
857    }
858}
859/// Redact a VerificationSession to remove all collected information from Stripe. This will redact
860/// the VerificationSession and all objects related to it, including VerificationReports, Events,
861/// request logs, etc.
862///
863/// A VerificationSession object can be redacted when it is in `requires_input` or `verified`
864/// [status](https://stripe.com/docs/identity/how-sessions-work).
865/// Redacting a VerificationSession in `requires_action`.
866/// state will automatically cancel it.
867///
868/// The redaction process may take up to four days. When the redaction process is in progress, the
869/// VerificationSession’s `redaction.status` field will be set to `processing`; when the process is
870/// finished, it will change to `redacted` and an `identity.verification_session.redacted` event
871/// will be emitted.
872///
873/// Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the
874/// fields that contain personal data will be replaced by the string `[redacted]` or a similar
875/// placeholder. The `metadata` field will also be erased. Redacted objects cannot be updated or
876/// used for any purpose.
877///
878/// [Learn more](https://stripe.com/docs/identity/verification-sessions#redact).
879#[derive(Clone, Debug, serde::Serialize)]
880pub struct RedactIdentityVerificationSession {
881    inner: RedactIdentityVerificationSessionBuilder,
882    session: stripe_misc::IdentityVerificationSessionId,
883}
884impl RedactIdentityVerificationSession {
885    /// Construct a new `RedactIdentityVerificationSession`.
886    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
887        Self { session: session.into(), inner: RedactIdentityVerificationSessionBuilder::new() }
888    }
889    /// Specifies which fields in the response should be expanded.
890    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
891        self.inner.expand = Some(expand.into());
892        self
893    }
894}
895impl RedactIdentityVerificationSession {
896    /// Send the request and return the deserialized response.
897    pub async fn send<C: StripeClient>(
898        &self,
899        client: &C,
900    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
901        self.customize().send(client).await
902    }
903
904    /// Send the request and return the deserialized response, blocking until completion.
905    pub fn send_blocking<C: StripeBlockingClient>(
906        &self,
907        client: &C,
908    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
909        self.customize().send_blocking(client)
910    }
911}
912
913impl StripeRequest for RedactIdentityVerificationSession {
914    type Output = stripe_misc::IdentityVerificationSession;
915
916    fn build(&self) -> RequestBuilder {
917        let session = &self.session;
918        RequestBuilder::new(
919            StripeMethod::Post,
920            format!("/identity/verification_sessions/{session}/redact"),
921        )
922        .form(&self.inner)
923    }
924}
925
926#[derive(Clone, Debug, serde::Serialize)]
927pub struct ProvidedDetailsParam {
928    /// Email of user being verified
929    #[serde(skip_serializing_if = "Option::is_none")]
930    pub email: Option<String>,
931    /// Phone number of user being verified
932    #[serde(skip_serializing_if = "Option::is_none")]
933    pub phone: Option<String>,
934}
935impl ProvidedDetailsParam {
936    pub fn new() -> Self {
937        Self { email: None, phone: None }
938    }
939}
940impl Default for ProvidedDetailsParam {
941    fn default() -> Self {
942        Self::new()
943    }
944}