async-stripe-core 1.0.0-rc.5

API bindings for the Stripe HTTP API
Documentation
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
use stripe_client_core::{
    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
};

#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct RetrieveForMyAccountBalanceSettingsBuilder {
    #[serde(skip_serializing_if = "Option::is_none")]
    expand: Option<Vec<String>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrieveForMyAccountBalanceSettingsBuilder {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("RetrieveForMyAccountBalanceSettingsBuilder").finish_non_exhaustive()
    }
}
impl RetrieveForMyAccountBalanceSettingsBuilder {
    fn new() -> Self {
        Self { expand: None }
    }
}
/// Retrieves balance settings for a given connected account.
///  Related guide: <a href="/connect/authentication">Making API calls for connected accounts</a>
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct RetrieveForMyAccountBalanceSettings {
    inner: RetrieveForMyAccountBalanceSettingsBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for RetrieveForMyAccountBalanceSettings {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("RetrieveForMyAccountBalanceSettings").finish_non_exhaustive()
    }
}
impl RetrieveForMyAccountBalanceSettings {
    /// Construct a new `RetrieveForMyAccountBalanceSettings`.
    pub fn new() -> Self {
        Self { inner: RetrieveForMyAccountBalanceSettingsBuilder::new() }
    }
    /// Specifies which fields in the response should be expanded.
    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
        self.inner.expand = Some(expand.into());
        self
    }
}
impl Default for RetrieveForMyAccountBalanceSettings {
    fn default() -> Self {
        Self::new()
    }
}
impl RetrieveForMyAccountBalanceSettings {
    /// Send the request and return the deserialized response.
    pub async fn send<C: StripeClient>(
        &self,
        client: &C,
    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
        self.customize().send(client).await
    }

    /// Send the request and return the deserialized response, blocking until completion.
    pub fn send_blocking<C: StripeBlockingClient>(
        &self,
        client: &C,
    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
        self.customize().send_blocking(client)
    }
}

impl StripeRequest for RetrieveForMyAccountBalanceSettings {
    type Output = stripe_core::BalanceSettings;

    fn build(&self) -> RequestBuilder {
        RequestBuilder::new(StripeMethod::Get, "/balance_settings").query(&self.inner)
    }
}
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
struct UpdateBalanceSettingsBuilder {
    #[serde(skip_serializing_if = "Option::is_none")]
    expand: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    payments: Option<UpdateBalanceSettingsPayments>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettingsBuilder {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("UpdateBalanceSettingsBuilder").finish_non_exhaustive()
    }
}
impl UpdateBalanceSettingsBuilder {
    fn new() -> Self {
        Self { expand: None, payments: None }
    }
}
/// Settings that apply to the [Payments Balance](https://docs.stripe.com/api/balance).
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct UpdateBalanceSettingsPayments {
    /// A Boolean indicating whether Stripe should try to reclaim negative balances from an attached bank account.
    /// For details, see [Understanding Connect Account Balances](/connect/account-balances).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub debit_negative_balances: Option<bool>,
    /// Settings specific to the account's payouts.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub payouts: Option<UpdateBalanceSettingsPaymentsPayouts>,
    /// Settings related to the account's balance settlement timing.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub settlement_timing: Option<UpdateBalanceSettingsPaymentsSettlementTiming>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettingsPayments {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("UpdateBalanceSettingsPayments").finish_non_exhaustive()
    }
}
impl UpdateBalanceSettingsPayments {
    pub fn new() -> Self {
        Self { debit_negative_balances: None, payouts: None, settlement_timing: None }
    }
}
impl Default for UpdateBalanceSettingsPayments {
    fn default() -> Self {
        Self::new()
    }
}
/// Settings specific to the account's payouts.
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct UpdateBalanceSettingsPaymentsPayouts {
    /// The minimum balance amount to retain per currency after automatic payouts.
    /// Only funds that exceed these amounts are paid out.
    /// Learn more about the [minimum balances for automatic payouts](/payouts/minimum-balances-for-automatic-payouts).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub minimum_balance_by_currency: Option<std::collections::HashMap<String, i64>>,
    /// Details on when funds from charges are available, and when they are paid out to an external account.
    /// For details, see our [Setting Bank and Debit Card Payouts](/connect/bank-transfers#payout-information) documentation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub schedule: Option<UpdateBalanceSettingsPaymentsPayoutsSchedule>,
    /// The text that appears on the bank account statement for payouts.
    /// If not set, this defaults to the platform's bank descriptor as set in the Dashboard.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub statement_descriptor: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayouts {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("UpdateBalanceSettingsPaymentsPayouts").finish_non_exhaustive()
    }
}
impl UpdateBalanceSettingsPaymentsPayouts {
    pub fn new() -> Self {
        Self { minimum_balance_by_currency: None, schedule: None, statement_descriptor: None }
    }
}
impl Default for UpdateBalanceSettingsPaymentsPayouts {
    fn default() -> Self {
        Self::new()
    }
}
/// Details on when funds from charges are available, and when they are paid out to an external account.
/// For details, see our [Setting Bank and Debit Card Payouts](/connect/bank-transfers#payout-information) documentation.
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct UpdateBalanceSettingsPaymentsPayoutsSchedule {
    /// How frequently available funds are paid out.
    /// One of: `daily`, `manual`, `weekly`, or `monthly`.
    /// Default is `daily`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interval: Option<UpdateBalanceSettingsPaymentsPayoutsScheduleInterval>,
    /// The days of the month when available funds are paid out, specified as an array of numbers between 1--31.
    /// Payouts nominally scheduled between the 29th and 31st of the month are instead sent on the last day of a shorter month.
    /// Required and applicable only if `interval` is `monthly`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub monthly_payout_days: Option<Vec<u32>>,
    /// The days of the week when available funds are paid out, specified as an array, e.g., [`monday`, `tuesday`].
    /// Required and applicable only if `interval` is `weekly`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weekly_payout_days:
        Option<Vec<UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays>>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayoutsSchedule {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("UpdateBalanceSettingsPaymentsPayoutsSchedule").finish_non_exhaustive()
    }
}
impl UpdateBalanceSettingsPaymentsPayoutsSchedule {
    pub fn new() -> Self {
        Self { interval: None, monthly_payout_days: None, weekly_payout_days: None }
    }
}
impl Default for UpdateBalanceSettingsPaymentsPayoutsSchedule {
    fn default() -> Self {
        Self::new()
    }
}
/// How frequently available funds are paid out.
/// One of: `daily`, `manual`, `weekly`, or `monthly`.
/// Default is `daily`.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    Daily,
    Manual,
    Monthly,
    Weekly,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    pub fn as_str(&self) -> &str {
        use UpdateBalanceSettingsPaymentsPayoutsScheduleInterval::*;
        match self {
            Daily => "daily",
            Manual => "manual",
            Monthly => "monthly",
            Weekly => "weekly",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use UpdateBalanceSettingsPaymentsPayoutsScheduleInterval::*;
        match s {
            "daily" => Ok(Daily),
            "manual" => Ok(Manual),
            "monthly" => Ok(Monthly),
            "weekly" => Ok(Weekly),
            v => {
                tracing::warn!(
                    "Unknown value '{}' for enum '{}'",
                    v,
                    "UpdateBalanceSettingsPaymentsPayoutsScheduleInterval"
                );
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(UpdateBalanceSettingsPaymentsPayoutsScheduleInterval))
            .finish_non_exhaustive()
    }
}
impl serde::Serialize for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
/// The days of the week when available funds are paid out, specified as an array, e.g., [`monday`, `tuesday`].
/// Required and applicable only if `interval` is `weekly`.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    Friday,
    Monday,
    Thursday,
    Tuesday,
    Wednesday,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    pub fn as_str(&self) -> &str {
        use UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays::*;
        match self {
            Friday => "friday",
            Monday => "monday",
            Thursday => "thursday",
            Tuesday => "tuesday",
            Wednesday => "wednesday",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays::*;
        match s {
            "friday" => Ok(Friday),
            "monday" => Ok(Monday),
            "thursday" => Ok(Thursday),
            "tuesday" => Ok(Tuesday),
            "wednesday" => Ok(Wednesday),
            v => {
                tracing::warn!(
                    "Unknown value '{}' for enum '{}'",
                    v,
                    "UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays"
                );
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays))
            .finish_non_exhaustive()
    }
}
impl serde::Serialize for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
/// Settings related to the account's balance settlement timing.
#[derive(Copy, Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct UpdateBalanceSettingsPaymentsSettlementTiming {
    /// Change `delay_days` for this account, which determines the number of days charge funds are held before becoming available.
    /// The maximum value is 31.
    /// Passing an empty string to `delay_days_override` will return `delay_days` to the default, which is the lowest available value for the account.
    /// [Learn more about controlling delay days](/connect/manage-payout-schedule).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub delay_days_override: Option<u32>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettingsPaymentsSettlementTiming {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("UpdateBalanceSettingsPaymentsSettlementTiming").finish_non_exhaustive()
    }
}
impl UpdateBalanceSettingsPaymentsSettlementTiming {
    pub fn new() -> Self {
        Self { delay_days_override: None }
    }
}
impl Default for UpdateBalanceSettingsPaymentsSettlementTiming {
    fn default() -> Self {
        Self::new()
    }
}
/// Updates balance settings for a given connected account.
///  Related guide: <a href="/connect/authentication">Making API calls for connected accounts</a>
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[derive(serde::Serialize)]
pub struct UpdateBalanceSettings {
    inner: UpdateBalanceSettingsBuilder,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for UpdateBalanceSettings {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("UpdateBalanceSettings").finish_non_exhaustive()
    }
}
impl UpdateBalanceSettings {
    /// Construct a new `UpdateBalanceSettings`.
    pub fn new() -> Self {
        Self { inner: UpdateBalanceSettingsBuilder::new() }
    }
    /// Specifies which fields in the response should be expanded.
    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
        self.inner.expand = Some(expand.into());
        self
    }
    /// Settings that apply to the [Payments Balance](https://docs.stripe.com/api/balance).
    pub fn payments(mut self, payments: impl Into<UpdateBalanceSettingsPayments>) -> Self {
        self.inner.payments = Some(payments.into());
        self
    }
}
impl Default for UpdateBalanceSettings {
    fn default() -> Self {
        Self::new()
    }
}
impl UpdateBalanceSettings {
    /// Send the request and return the deserialized response.
    pub async fn send<C: StripeClient>(
        &self,
        client: &C,
    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
        self.customize().send(client).await
    }

    /// Send the request and return the deserialized response, blocking until completion.
    pub fn send_blocking<C: StripeBlockingClient>(
        &self,
        client: &C,
    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
        self.customize().send_blocking(client)
    }
}

impl StripeRequest for UpdateBalanceSettings {
    type Output = stripe_core::BalanceSettings;

    fn build(&self) -> RequestBuilder {
        RequestBuilder::new(StripeMethod::Post, "/balance_settings").form(&self.inner)
    }
}