stripe/resources/generated/
ephemeral_key.rs1use crate::client::{Client, Response};
6use crate::ids::{CustomerId, EphemeralKeyId, IssuingCardId};
7use crate::params::{Deleted, Expand, Object, Timestamp};
8use serde::{Deserialize, Serialize};
9
10#[derive(Clone, Debug, Default, Deserialize, Serialize)]
12pub struct EphemeralKey {
13 pub id: EphemeralKeyId,
15
16 pub created: Timestamp,
20
21 pub expires: Timestamp,
25
26 pub livemode: bool,
28
29 #[serde(skip_serializing_if = "Option::is_none")]
33 pub secret: Option<String>,
34}
35
36impl EphemeralKey {
37 pub fn create(client: &Client, params: CreateEphemeralKey<'_>) -> Response<EphemeralKey> {
39 #[allow(clippy::needless_borrows_for_generic_args)]
40 client.post_form("/ephemeral_keys", ¶ms)
41 }
42
43 pub fn delete(client: &Client, id: &EphemeralKeyId) -> Response<Deleted<EphemeralKeyId>> {
45 client.delete(&format!("/ephemeral_keys/{}", id))
46 }
47}
48
49impl Object for EphemeralKey {
50 type Id = EphemeralKeyId;
51 fn id(&self) -> Self::Id {
52 self.id.clone()
53 }
54 fn object(&self) -> &'static str {
55 "ephemeral_key"
56 }
57}
58
59#[derive(Clone, Debug, Serialize, Default)]
61pub struct CreateEphemeralKey<'a> {
62 #[serde(skip_serializing_if = "Option::is_none")]
64 pub customer: Option<CustomerId>,
65
66 #[serde(skip_serializing_if = "Expand::is_empty")]
68 pub expand: &'a [&'a str],
69
70 #[serde(skip_serializing_if = "Option::is_none")]
72 pub issuing_card: Option<IssuingCardId>,
73
74 #[serde(skip_serializing_if = "Option::is_none")]
76 pub nonce: Option<&'a str>,
77
78 #[serde(skip_serializing_if = "Option::is_none")]
80 pub verification_session: Option<&'a str>,
81}
82
83impl<'a> CreateEphemeralKey<'a> {
84 pub fn new() -> Self {
85 CreateEphemeralKey {
86 customer: Default::default(),
87 expand: Default::default(),
88 issuing_card: Default::default(),
89 nonce: Default::default(),
90 verification_session: Default::default(),
91 }
92 }
93}