stripe_misc/ephemeral_key/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct DeleteEphemeralKeyBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    expand: Option<Vec<String>>,
9}
10impl DeleteEphemeralKeyBuilder {
11    fn new() -> Self {
12        Self { expand: None }
13    }
14}
15/// Invalidates a short-lived API key for a given resource.
16#[derive(Clone, Debug, serde::Serialize)]
17pub struct DeleteEphemeralKey {
18    inner: DeleteEphemeralKeyBuilder,
19    key: stripe_misc::EphemeralKeyId,
20}
21impl DeleteEphemeralKey {
22    /// Construct a new `DeleteEphemeralKey`.
23    pub fn new(key: impl Into<stripe_misc::EphemeralKeyId>) -> Self {
24        Self { key: key.into(), inner: DeleteEphemeralKeyBuilder::new() }
25    }
26    /// Specifies which fields in the response should be expanded.
27    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
28        self.inner.expand = Some(expand.into());
29        self
30    }
31}
32impl DeleteEphemeralKey {
33    /// Send the request and return the deserialized response.
34    pub async fn send<C: StripeClient>(
35        &self,
36        client: &C,
37    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
38        self.customize().send(client).await
39    }
40
41    /// Send the request and return the deserialized response, blocking until completion.
42    pub fn send_blocking<C: StripeBlockingClient>(
43        &self,
44        client: &C,
45    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
46        self.customize().send_blocking(client)
47    }
48}
49
50impl StripeRequest for DeleteEphemeralKey {
51    type Output = stripe_misc::EphemeralKey;
52
53    fn build(&self) -> RequestBuilder {
54        let key = &self.key;
55        RequestBuilder::new(StripeMethod::Delete, format!("/ephemeral_keys/{key}"))
56            .form(&self.inner)
57    }
58}
59#[derive(Clone, Debug, serde::Serialize)]
60struct CreateEphemeralKeyBuilder {
61    #[serde(skip_serializing_if = "Option::is_none")]
62    customer: Option<String>,
63    #[serde(skip_serializing_if = "Option::is_none")]
64    expand: Option<Vec<String>>,
65    #[serde(skip_serializing_if = "Option::is_none")]
66    issuing_card: Option<String>,
67    #[serde(skip_serializing_if = "Option::is_none")]
68    nonce: Option<String>,
69    #[serde(skip_serializing_if = "Option::is_none")]
70    verification_session: Option<String>,
71}
72impl CreateEphemeralKeyBuilder {
73    fn new() -> Self {
74        Self {
75            customer: None,
76            expand: None,
77            issuing_card: None,
78            nonce: None,
79            verification_session: None,
80        }
81    }
82}
83/// Creates a short-lived API key for a given resource.
84#[derive(Clone, Debug, serde::Serialize)]
85pub struct CreateEphemeralKey {
86    inner: CreateEphemeralKeyBuilder,
87}
88impl CreateEphemeralKey {
89    /// Construct a new `CreateEphemeralKey`.
90    pub fn new() -> Self {
91        Self { inner: CreateEphemeralKeyBuilder::new() }
92    }
93    /// The ID of the Customer you'd like to modify using the resulting ephemeral key.
94    pub fn customer(mut self, customer: impl Into<String>) -> Self {
95        self.inner.customer = Some(customer.into());
96        self
97    }
98    /// Specifies which fields in the response should be expanded.
99    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
100        self.inner.expand = Some(expand.into());
101        self
102    }
103    /// The ID of the Issuing Card you'd like to access using the resulting ephemeral key.
104    pub fn issuing_card(mut self, issuing_card: impl Into<String>) -> Self {
105        self.inner.issuing_card = Some(issuing_card.into());
106        self
107    }
108    /// A single-use token, created by Stripe.js, used for creating ephemeral keys for Issuing Cards without exchanging sensitive information.
109    pub fn nonce(mut self, nonce: impl Into<String>) -> Self {
110        self.inner.nonce = Some(nonce.into());
111        self
112    }
113    /// The ID of the Identity VerificationSession you'd like to access using the resulting ephemeral key
114    pub fn verification_session(mut self, verification_session: impl Into<String>) -> Self {
115        self.inner.verification_session = Some(verification_session.into());
116        self
117    }
118}
119impl Default for CreateEphemeralKey {
120    fn default() -> Self {
121        Self::new()
122    }
123}
124impl CreateEphemeralKey {
125    /// Send the request and return the deserialized response.
126    pub async fn send<C: StripeClient>(
127        &self,
128        client: &C,
129    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
130        self.customize().send(client).await
131    }
132
133    /// Send the request and return the deserialized response, blocking until completion.
134    pub fn send_blocking<C: StripeBlockingClient>(
135        &self,
136        client: &C,
137    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
138        self.customize().send_blocking(client)
139    }
140}
141
142impl StripeRequest for CreateEphemeralKey {
143    type Output = stripe_misc::EphemeralKey;
144
145    fn build(&self) -> RequestBuilder {
146        RequestBuilder::new(StripeMethod::Post, "/ephemeral_keys").form(&self.inner)
147    }
148}