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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// ======================================
// This file was automatically generated.
// ======================================

use serde::{Deserialize, Serialize};

use crate::client::{Client, Response};
use crate::ids::AccountId;
use crate::params::{Expand, Object, Timestamp};

/// The resource representing a Stripe "AccountLink".
///
/// For more details see <https://stripe.com/docs/api/account_links/object>
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct AccountLink {
    /// Time at which the object was created.
    ///
    /// Measured in seconds since the Unix epoch.
    pub created: Timestamp,

    /// The timestamp at which this account link will expire.
    pub expires_at: Timestamp,

    /// The URL for the account link.
    pub url: String,
}

impl AccountLink {
    /// 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.
    pub fn create(client: &Client, params: CreateAccountLink<'_>) -> Response<AccountLink> {
        #[allow(clippy::needless_borrows_for_generic_args)]
        client.post_form("/account_links", &params)
    }
}

impl Object for AccountLink {
    type Id = ();
    fn id(&self) -> Self::Id {}
    fn object(&self) -> &'static str {
        "account_link"
    }
}

/// The parameters for `AccountLink::create`.
#[derive(Clone, Debug, Serialize)]
pub struct CreateAccountLink<'a> {
    /// The identifier of the account to create an account link for.
    pub account: AccountId,

    /// The collect parameter is deprecated.
    ///
    /// Use `collection_options` instead.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub collect: Option<AccountLinkCollect>,

    /// Specifies the requirements that Stripe collects from connected accounts in the Connect Onboarding flow.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub collection_options: Option<CreateAccountLinkCollectionOptions>,

    /// Specifies which fields in the response should be expanded.
    #[serde(skip_serializing_if = "Expand::is_empty")]
    pub expand: &'a [&'a str],

    /// The URL the user will be redirected to if the account link is expired, has been previously-visited, or is otherwise invalid.
    ///
    /// 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.
    /// If a new account link cannot be generated or the redirect fails you should display a useful error to the user.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub refresh_url: Option<&'a str>,

    /// The URL that the user will be redirected to upon leaving or completing the linked flow.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub return_url: Option<&'a str>,

    /// The type of account link the user is requesting.
    ///
    /// Possible values are `account_onboarding` or `account_update`.
    #[serde(rename = "type")]
    pub type_: AccountLinkType,
}

impl<'a> CreateAccountLink<'a> {
    pub fn new(account: AccountId, type_: AccountLinkType) -> Self {
        CreateAccountLink {
            account,
            collect: Default::default(),
            collection_options: Default::default(),
            expand: Default::default(),
            refresh_url: Default::default(),
            return_url: Default::default(),
            type_,
        }
    }
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreateAccountLinkCollectionOptions {
    /// Specifies whether the platform collects only currently_due requirements (`currently_due`) or both currently_due and eventually_due requirements (`eventually_due`).
    ///
    /// If you don't specify `collection_options`, the default value is `currently_due`.
    pub fields: CreateAccountLinkCollectionOptionsFields,

    /// Specifies whether the platform collects future_requirements in addition to requirements in Connect Onboarding.
    ///
    /// The default value is `omit`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub future_requirements: Option<CreateAccountLinkCollectionOptionsFutureRequirements>,
}

/// An enum representing the possible values of an `CreateAccountLink`'s `collect` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AccountLinkCollect {
    CurrentlyDue,
    EventuallyDue,
}

impl AccountLinkCollect {
    pub fn as_str(self) -> &'static str {
        match self {
            AccountLinkCollect::CurrentlyDue => "currently_due",
            AccountLinkCollect::EventuallyDue => "eventually_due",
        }
    }
}

impl AsRef<str> for AccountLinkCollect {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for AccountLinkCollect {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}
impl std::default::Default for AccountLinkCollect {
    fn default() -> Self {
        Self::CurrentlyDue
    }
}

/// An enum representing the possible values of an `CreateAccountLink`'s `type_` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AccountLinkType {
    AccountOnboarding,
    AccountUpdate,
}

impl AccountLinkType {
    pub fn as_str(self) -> &'static str {
        match self {
            AccountLinkType::AccountOnboarding => "account_onboarding",
            AccountLinkType::AccountUpdate => "account_update",
        }
    }
}

impl AsRef<str> for AccountLinkType {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for AccountLinkType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}
impl std::default::Default for AccountLinkType {
    fn default() -> Self {
        Self::AccountOnboarding
    }
}

/// An enum representing the possible values of an `CreateAccountLinkCollectionOptions`'s `fields` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum CreateAccountLinkCollectionOptionsFields {
    CurrentlyDue,
    EventuallyDue,
}

impl CreateAccountLinkCollectionOptionsFields {
    pub fn as_str(self) -> &'static str {
        match self {
            CreateAccountLinkCollectionOptionsFields::CurrentlyDue => "currently_due",
            CreateAccountLinkCollectionOptionsFields::EventuallyDue => "eventually_due",
        }
    }
}

impl AsRef<str> for CreateAccountLinkCollectionOptionsFields {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for CreateAccountLinkCollectionOptionsFields {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}
impl std::default::Default for CreateAccountLinkCollectionOptionsFields {
    fn default() -> Self {
        Self::CurrentlyDue
    }
}

/// An enum representing the possible values of an `CreateAccountLinkCollectionOptions`'s `future_requirements` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum CreateAccountLinkCollectionOptionsFutureRequirements {
    Include,
    Omit,
}

impl CreateAccountLinkCollectionOptionsFutureRequirements {
    pub fn as_str(self) -> &'static str {
        match self {
            CreateAccountLinkCollectionOptionsFutureRequirements::Include => "include",
            CreateAccountLinkCollectionOptionsFutureRequirements::Omit => "omit",
        }
    }
}

impl AsRef<str> for CreateAccountLinkCollectionOptionsFutureRequirements {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl std::fmt::Display for CreateAccountLinkCollectionOptionsFutureRequirements {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.as_str().fmt(f)
    }
}
impl std::default::Default for CreateAccountLinkCollectionOptionsFutureRequirements {
    fn default() -> Self {
        Self::Include
    }
}