1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use serde::{Deserialize, Serialize};
use crate::client::{Client, Response};
use crate::ids::{CustomerId, EphemeralKeyId, IssuingCardId};
use crate::params::{Deleted, Expand, Object, Timestamp};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct EphemeralKey {
pub id: EphemeralKeyId,
pub created: Timestamp,
pub expires: Timestamp,
pub livemode: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub secret: Option<String>,
}
impl EphemeralKey {
pub fn create(client: &Client, params: CreateEphemeralKey<'_>) -> Response<EphemeralKey> {
client.post_form("/ephemeral_keys", ¶ms)
}
pub fn delete(client: &Client, id: &EphemeralKeyId) -> Response<Deleted<EphemeralKeyId>> {
client.delete(&format!("/ephemeral_keys/{}", id))
}
}
impl Object for EphemeralKey {
type Id = EphemeralKeyId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"ephemeral_key"
}
}
#[derive(Clone, Debug, Serialize, Default)]
pub struct CreateEphemeralKey<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub customer: Option<CustomerId>,
#[serde(skip_serializing_if = "Expand::is_empty")]
pub expand: &'a [&'a str],
#[serde(skip_serializing_if = "Option::is_none")]
pub issuing_card: Option<IssuingCardId>,
}
impl<'a> CreateEphemeralKey<'a> {
pub fn new() -> Self {
CreateEphemeralKey {
customer: Default::default(),
expand: Default::default(),
issuing_card: Default::default(),
}
}
}