stripe/resources/generated/
account_link.rs1use crate::client::{Client, Response};
6use crate::ids::AccountId;
7use crate::params::{Expand, Object, Timestamp};
8use serde::{Deserialize, Serialize};
9
10#[derive(Clone, Debug, Default, Deserialize, Serialize)]
14pub struct AccountLink {
15 pub created: Timestamp,
19
20 pub expires_at: Timestamp,
22
23 pub url: String,
25}
26
27impl AccountLink {
28 pub fn create(client: &Client, params: CreateAccountLink<'_>) -> Response<AccountLink> {
30 #[allow(clippy::needless_borrows_for_generic_args)]
31 client.post_form("/account_links", ¶ms)
32 }
33}
34
35impl Object for AccountLink {
36 type Id = ();
37 fn id(&self) -> Self::Id {}
38 fn object(&self) -> &'static str {
39 "account_link"
40 }
41}
42
43#[derive(Clone, Debug, Serialize)]
45pub struct CreateAccountLink<'a> {
46 pub account: AccountId,
48
49 #[serde(skip_serializing_if = "Option::is_none")]
53 pub collect: Option<AccountLinkCollect>,
54
55 #[serde(skip_serializing_if = "Option::is_none")]
57 pub collection_options: Option<CreateAccountLinkCollectionOptions>,
58
59 #[serde(skip_serializing_if = "Expand::is_empty")]
61 pub expand: &'a [&'a str],
62
63 #[serde(skip_serializing_if = "Option::is_none")]
68 pub refresh_url: Option<&'a str>,
69
70 #[serde(skip_serializing_if = "Option::is_none")]
72 pub return_url: Option<&'a str>,
73
74 #[serde(rename = "type")]
78 pub type_: AccountLinkType,
79}
80
81impl<'a> CreateAccountLink<'a> {
82 pub fn new(account: AccountId, type_: AccountLinkType) -> Self {
83 CreateAccountLink {
84 account,
85 collect: Default::default(),
86 collection_options: Default::default(),
87 expand: Default::default(),
88 refresh_url: Default::default(),
89 return_url: Default::default(),
90 type_,
91 }
92 }
93}
94
95#[derive(Clone, Debug, Default, Deserialize, Serialize)]
96pub struct CreateAccountLinkCollectionOptions {
97 pub fields: CreateAccountLinkCollectionOptionsFields,
101
102 #[serde(skip_serializing_if = "Option::is_none")]
106 pub future_requirements: Option<CreateAccountLinkCollectionOptionsFutureRequirements>,
107}
108
109#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
111#[serde(rename_all = "snake_case")]
112pub enum AccountLinkCollect {
113 CurrentlyDue,
114 EventuallyDue,
115}
116
117impl AccountLinkCollect {
118 pub fn as_str(self) -> &'static str {
119 match self {
120 AccountLinkCollect::CurrentlyDue => "currently_due",
121 AccountLinkCollect::EventuallyDue => "eventually_due",
122 }
123 }
124}
125
126impl AsRef<str> for AccountLinkCollect {
127 fn as_ref(&self) -> &str {
128 self.as_str()
129 }
130}
131
132impl std::fmt::Display for AccountLinkCollect {
133 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
134 self.as_str().fmt(f)
135 }
136}
137impl std::default::Default for AccountLinkCollect {
138 fn default() -> Self {
139 Self::CurrentlyDue
140 }
141}
142
143#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
145#[serde(rename_all = "snake_case")]
146pub enum AccountLinkType {
147 AccountOnboarding,
148 AccountUpdate,
149}
150
151impl AccountLinkType {
152 pub fn as_str(self) -> &'static str {
153 match self {
154 AccountLinkType::AccountOnboarding => "account_onboarding",
155 AccountLinkType::AccountUpdate => "account_update",
156 }
157 }
158}
159
160impl AsRef<str> for AccountLinkType {
161 fn as_ref(&self) -> &str {
162 self.as_str()
163 }
164}
165
166impl std::fmt::Display for AccountLinkType {
167 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
168 self.as_str().fmt(f)
169 }
170}
171impl std::default::Default for AccountLinkType {
172 fn default() -> Self {
173 Self::AccountOnboarding
174 }
175}
176
177#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
179#[serde(rename_all = "snake_case")]
180pub enum CreateAccountLinkCollectionOptionsFields {
181 CurrentlyDue,
182 EventuallyDue,
183}
184
185impl CreateAccountLinkCollectionOptionsFields {
186 pub fn as_str(self) -> &'static str {
187 match self {
188 CreateAccountLinkCollectionOptionsFields::CurrentlyDue => "currently_due",
189 CreateAccountLinkCollectionOptionsFields::EventuallyDue => "eventually_due",
190 }
191 }
192}
193
194impl AsRef<str> for CreateAccountLinkCollectionOptionsFields {
195 fn as_ref(&self) -> &str {
196 self.as_str()
197 }
198}
199
200impl std::fmt::Display for CreateAccountLinkCollectionOptionsFields {
201 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
202 self.as_str().fmt(f)
203 }
204}
205impl std::default::Default for CreateAccountLinkCollectionOptionsFields {
206 fn default() -> Self {
207 Self::CurrentlyDue
208 }
209}
210
211#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
213#[serde(rename_all = "snake_case")]
214pub enum CreateAccountLinkCollectionOptionsFutureRequirements {
215 Include,
216 Omit,
217}
218
219impl CreateAccountLinkCollectionOptionsFutureRequirements {
220 pub fn as_str(self) -> &'static str {
221 match self {
222 CreateAccountLinkCollectionOptionsFutureRequirements::Include => "include",
223 CreateAccountLinkCollectionOptionsFutureRequirements::Omit => "omit",
224 }
225 }
226}
227
228impl AsRef<str> for CreateAccountLinkCollectionOptionsFutureRequirements {
229 fn as_ref(&self) -> &str {
230 self.as_str()
231 }
232}
233
234impl std::fmt::Display for CreateAccountLinkCollectionOptionsFutureRequirements {
235 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
236 self.as_str().fmt(f)
237 }
238}
239impl std::default::Default for CreateAccountLinkCollectionOptionsFutureRequirements {
240 fn default() -> Self {
241 Self::Include
242 }
243}