stripe/resources/generated/
account_link.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::client::{Client, Response};
6use crate::ids::AccountId;
7use crate::params::{Expand, Object, Timestamp};
8use serde::{Deserialize, Serialize};
9
10/// The resource representing a Stripe "AccountLink".
11///
12/// For more details see <https://stripe.com/docs/api/account_links/object>
13#[derive(Clone, Debug, Default, Deserialize, Serialize)]
14pub struct AccountLink {
15    /// Time at which the object was created.
16    ///
17    /// Measured in seconds since the Unix epoch.
18    pub created: Timestamp,
19
20    /// The timestamp at which this account link will expire.
21    pub expires_at: Timestamp,
22
23    /// The URL for the account link.
24    pub url: String,
25}
26
27impl AccountLink {
28    /// Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.
29    pub fn create(client: &Client, params: CreateAccountLink<'_>) -> Response<AccountLink> {
30        #[allow(clippy::needless_borrows_for_generic_args)]
31        client.post_form("/account_links", &params)
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/// The parameters for `AccountLink::create`.
44#[derive(Clone, Debug, Serialize)]
45pub struct CreateAccountLink<'a> {
46    /// The identifier of the account to create an account link for.
47    pub account: AccountId,
48
49    /// The collect parameter is deprecated.
50    ///
51    /// Use `collection_options` instead.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub collect: Option<AccountLinkCollect>,
54
55    /// Specifies the requirements that Stripe collects from connected accounts in the Connect Onboarding flow.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub collection_options: Option<CreateAccountLinkCollectionOptions>,
58
59    /// Specifies which fields in the response should be expanded.
60    #[serde(skip_serializing_if = "Expand::is_empty")]
61    pub expand: &'a [&'a str],
62
63    /// The URL the user will be redirected to if the account link is expired, has been previously-visited, or is otherwise invalid.
64    ///
65    /// The URL you specify should attempt to generate a new account link with the same parameters used to create the original account link, then redirect the user to the new account link's URL so they can continue with Connect Onboarding.
66    /// If a new account link cannot be generated or the redirect fails you should display a useful error to the user.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub refresh_url: Option<&'a str>,
69
70    /// The URL that the user will be redirected to upon leaving or completing the linked flow.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub return_url: Option<&'a str>,
73
74    /// The type of account link the user is requesting.
75    ///
76    /// Possible values are `account_onboarding` or `account_update`.
77    #[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    /// Specifies whether the platform collects only currently_due requirements (`currently_due`) or both currently_due and eventually_due requirements (`eventually_due`).
98    ///
99    /// If you don't specify `collection_options`, the default value is `currently_due`.
100    pub fields: CreateAccountLinkCollectionOptionsFields,
101
102    /// Specifies whether the platform collects future_requirements in addition to requirements in Connect Onboarding.
103    ///
104    /// The default value is `omit`.
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub future_requirements: Option<CreateAccountLinkCollectionOptionsFutureRequirements>,
107}
108
109/// An enum representing the possible values of an `CreateAccountLink`'s `collect` field.
110#[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/// An enum representing the possible values of an `CreateAccountLink`'s `type_` field.
144#[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/// An enum representing the possible values of an `CreateAccountLinkCollectionOptions`'s `fields` field.
178#[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/// An enum representing the possible values of an `CreateAccountLinkCollectionOptions`'s `future_requirements` field.
212#[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}