stripe_core/balance_settings/
requests.rs1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct RetrieveForMyAccountBalanceSettingsBuilder {
7 #[serde(skip_serializing_if = "Option::is_none")]
8 expand: Option<Vec<String>>,
9}
10impl RetrieveForMyAccountBalanceSettingsBuilder {
11 fn new() -> Self {
12 Self { expand: None }
13 }
14}
15#[derive(Clone, Debug, serde::Serialize)]
18pub struct RetrieveForMyAccountBalanceSettings {
19 inner: RetrieveForMyAccountBalanceSettingsBuilder,
20}
21impl RetrieveForMyAccountBalanceSettings {
22 pub fn new() -> Self {
24 Self { inner: RetrieveForMyAccountBalanceSettingsBuilder::new() }
25 }
26 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
28 self.inner.expand = Some(expand.into());
29 self
30 }
31}
32impl Default for RetrieveForMyAccountBalanceSettings {
33 fn default() -> Self {
34 Self::new()
35 }
36}
37impl RetrieveForMyAccountBalanceSettings {
38 pub async fn send<C: StripeClient>(
40 &self,
41 client: &C,
42 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
43 self.customize().send(client).await
44 }
45
46 pub fn send_blocking<C: StripeBlockingClient>(
48 &self,
49 client: &C,
50 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
51 self.customize().send_blocking(client)
52 }
53}
54
55impl StripeRequest for RetrieveForMyAccountBalanceSettings {
56 type Output = stripe_core::BalanceSettings;
57
58 fn build(&self) -> RequestBuilder {
59 RequestBuilder::new(StripeMethod::Get, "/balance_settings").query(&self.inner)
60 }
61}
62#[derive(Clone, Debug, serde::Serialize)]
63struct UpdateBalanceSettingsBuilder {
64 #[serde(skip_serializing_if = "Option::is_none")]
65 expand: Option<Vec<String>>,
66 #[serde(skip_serializing_if = "Option::is_none")]
67 payments: Option<UpdateBalanceSettingsPayments>,
68}
69impl UpdateBalanceSettingsBuilder {
70 fn new() -> Self {
71 Self { expand: None, payments: None }
72 }
73}
74#[derive(Clone, Debug, serde::Serialize)]
76pub struct UpdateBalanceSettingsPayments {
77 #[serde(skip_serializing_if = "Option::is_none")]
80 pub debit_negative_balances: Option<bool>,
81 #[serde(skip_serializing_if = "Option::is_none")]
83 pub payouts: Option<UpdateBalanceSettingsPaymentsPayouts>,
84 #[serde(skip_serializing_if = "Option::is_none")]
86 pub settlement_timing: Option<UpdateBalanceSettingsPaymentsSettlementTiming>,
87}
88impl UpdateBalanceSettingsPayments {
89 pub fn new() -> Self {
90 Self { debit_negative_balances: None, payouts: None, settlement_timing: None }
91 }
92}
93impl Default for UpdateBalanceSettingsPayments {
94 fn default() -> Self {
95 Self::new()
96 }
97}
98#[derive(Clone, Debug, serde::Serialize)]
100pub struct UpdateBalanceSettingsPaymentsPayouts {
101 #[serde(skip_serializing_if = "Option::is_none")]
105 pub minimum_balance_by_currency: Option<std::collections::HashMap<String, i64>>,
106 #[serde(skip_serializing_if = "Option::is_none")]
109 pub schedule: Option<UpdateBalanceSettingsPaymentsPayoutsSchedule>,
110 #[serde(skip_serializing_if = "Option::is_none")]
113 pub statement_descriptor: Option<String>,
114}
115impl UpdateBalanceSettingsPaymentsPayouts {
116 pub fn new() -> Self {
117 Self { minimum_balance_by_currency: None, schedule: None, statement_descriptor: None }
118 }
119}
120impl Default for UpdateBalanceSettingsPaymentsPayouts {
121 fn default() -> Self {
122 Self::new()
123 }
124}
125#[derive(Clone, Debug, serde::Serialize)]
128pub struct UpdateBalanceSettingsPaymentsPayoutsSchedule {
129 #[serde(skip_serializing_if = "Option::is_none")]
133 pub interval: Option<UpdateBalanceSettingsPaymentsPayoutsScheduleInterval>,
134 #[serde(skip_serializing_if = "Option::is_none")]
138 pub monthly_payout_days: Option<Vec<u32>>,
139 #[serde(skip_serializing_if = "Option::is_none")]
142 pub weekly_payout_days:
143 Option<Vec<UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays>>,
144}
145impl UpdateBalanceSettingsPaymentsPayoutsSchedule {
146 pub fn new() -> Self {
147 Self { interval: None, monthly_payout_days: None, weekly_payout_days: None }
148 }
149}
150impl Default for UpdateBalanceSettingsPaymentsPayoutsSchedule {
151 fn default() -> Self {
152 Self::new()
153 }
154}
155#[derive(Clone, Eq, PartialEq)]
159#[non_exhaustive]
160pub enum UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
161 Daily,
162 Manual,
163 Monthly,
164 Weekly,
165 Unknown(String),
167}
168impl UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
169 pub fn as_str(&self) -> &str {
170 use UpdateBalanceSettingsPaymentsPayoutsScheduleInterval::*;
171 match self {
172 Daily => "daily",
173 Manual => "manual",
174 Monthly => "monthly",
175 Weekly => "weekly",
176 Unknown(v) => v,
177 }
178 }
179}
180
181impl std::str::FromStr for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
182 type Err = std::convert::Infallible;
183 fn from_str(s: &str) -> Result<Self, Self::Err> {
184 use UpdateBalanceSettingsPaymentsPayoutsScheduleInterval::*;
185 match s {
186 "daily" => Ok(Daily),
187 "manual" => Ok(Manual),
188 "monthly" => Ok(Monthly),
189 "weekly" => Ok(Weekly),
190 v => {
191 tracing::warn!(
192 "Unknown value '{}' for enum '{}'",
193 v,
194 "UpdateBalanceSettingsPaymentsPayoutsScheduleInterval"
195 );
196 Ok(Unknown(v.to_owned()))
197 }
198 }
199 }
200}
201impl std::fmt::Display for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
202 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
203 f.write_str(self.as_str())
204 }
205}
206
207impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
208 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
209 f.write_str(self.as_str())
210 }
211}
212impl serde::Serialize for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
213 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
214 where
215 S: serde::Serializer,
216 {
217 serializer.serialize_str(self.as_str())
218 }
219}
220#[cfg(feature = "deserialize")]
221impl<'de> serde::Deserialize<'de> for UpdateBalanceSettingsPaymentsPayoutsScheduleInterval {
222 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
223 use std::str::FromStr;
224 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
225 Ok(Self::from_str(&s).expect("infallible"))
226 }
227}
228#[derive(Clone, Eq, PartialEq)]
231#[non_exhaustive]
232pub enum UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
233 Friday,
234 Monday,
235 Thursday,
236 Tuesday,
237 Wednesday,
238 Unknown(String),
240}
241impl UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
242 pub fn as_str(&self) -> &str {
243 use UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays::*;
244 match self {
245 Friday => "friday",
246 Monday => "monday",
247 Thursday => "thursday",
248 Tuesday => "tuesday",
249 Wednesday => "wednesday",
250 Unknown(v) => v,
251 }
252 }
253}
254
255impl std::str::FromStr for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
256 type Err = std::convert::Infallible;
257 fn from_str(s: &str) -> Result<Self, Self::Err> {
258 use UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays::*;
259 match s {
260 "friday" => Ok(Friday),
261 "monday" => Ok(Monday),
262 "thursday" => Ok(Thursday),
263 "tuesday" => Ok(Tuesday),
264 "wednesday" => Ok(Wednesday),
265 v => {
266 tracing::warn!(
267 "Unknown value '{}' for enum '{}'",
268 v,
269 "UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays"
270 );
271 Ok(Unknown(v.to_owned()))
272 }
273 }
274 }
275}
276impl std::fmt::Display for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
277 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
278 f.write_str(self.as_str())
279 }
280}
281
282impl std::fmt::Debug for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
283 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
284 f.write_str(self.as_str())
285 }
286}
287impl serde::Serialize for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
288 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
289 where
290 S: serde::Serializer,
291 {
292 serializer.serialize_str(self.as_str())
293 }
294}
295#[cfg(feature = "deserialize")]
296impl<'de> serde::Deserialize<'de> for UpdateBalanceSettingsPaymentsPayoutsScheduleWeeklyPayoutDays {
297 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
298 use std::str::FromStr;
299 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
300 Ok(Self::from_str(&s).expect("infallible"))
301 }
302}
303#[derive(Copy, Clone, Debug, serde::Serialize)]
305pub struct UpdateBalanceSettingsPaymentsSettlementTiming {
306 #[serde(skip_serializing_if = "Option::is_none")]
311 pub delay_days_override: Option<u32>,
312}
313impl UpdateBalanceSettingsPaymentsSettlementTiming {
314 pub fn new() -> Self {
315 Self { delay_days_override: None }
316 }
317}
318impl Default for UpdateBalanceSettingsPaymentsSettlementTiming {
319 fn default() -> Self {
320 Self::new()
321 }
322}
323#[derive(Clone, Debug, serde::Serialize)]
326pub struct UpdateBalanceSettings {
327 inner: UpdateBalanceSettingsBuilder,
328}
329impl UpdateBalanceSettings {
330 pub fn new() -> Self {
332 Self { inner: UpdateBalanceSettingsBuilder::new() }
333 }
334 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
336 self.inner.expand = Some(expand.into());
337 self
338 }
339 pub fn payments(mut self, payments: impl Into<UpdateBalanceSettingsPayments>) -> Self {
341 self.inner.payments = Some(payments.into());
342 self
343 }
344}
345impl Default for UpdateBalanceSettings {
346 fn default() -> Self {
347 Self::new()
348 }
349}
350impl UpdateBalanceSettings {
351 pub async fn send<C: StripeClient>(
353 &self,
354 client: &C,
355 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
356 self.customize().send(client).await
357 }
358
359 pub fn send_blocking<C: StripeBlockingClient>(
361 &self,
362 client: &C,
363 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
364 self.customize().send_blocking(client)
365 }
366}
367
368impl StripeRequest for UpdateBalanceSettings {
369 type Output = stripe_core::BalanceSettings;
370
371 fn build(&self) -> RequestBuilder {
372 RequestBuilder::new(StripeMethod::Post, "/balance_settings").form(&self.inner)
373 }
374}