stripe_core/setup_attempt/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListSetupAttemptBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    created: Option<stripe_types::RangeQueryTs>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    ending_before: Option<String>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    expand: Option<Vec<String>>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    limit: Option<i64>,
15    setup_intent: String,
16    #[serde(skip_serializing_if = "Option::is_none")]
17    starting_after: Option<String>,
18}
19impl ListSetupAttemptBuilder {
20    fn new(setup_intent: impl Into<String>) -> Self {
21        Self {
22            created: None,
23            ending_before: None,
24            expand: None,
25            limit: None,
26            setup_intent: setup_intent.into(),
27            starting_after: None,
28        }
29    }
30}
31/// Returns a list of SetupAttempts that associate with a provided SetupIntent.
32#[derive(Clone, Debug, serde::Serialize)]
33pub struct ListSetupAttempt {
34    inner: ListSetupAttemptBuilder,
35}
36impl ListSetupAttempt {
37    /// Construct a new `ListSetupAttempt`.
38    pub fn new(setup_intent: impl Into<String>) -> Self {
39        Self { inner: ListSetupAttemptBuilder::new(setup_intent.into()) }
40    }
41    /// A filter on the list, based on the object `created` field. The value
42    /// can be a string with an integer Unix timestamp or a
43    /// dictionary with a number of different query options.
44    pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
45        self.inner.created = Some(created.into());
46        self
47    }
48    /// A cursor for use in pagination.
49    /// `ending_before` is an object ID that defines your place in the list.
50    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
51    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
52        self.inner.ending_before = Some(ending_before.into());
53        self
54    }
55    /// Specifies which fields in the response should be expanded.
56    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
57        self.inner.expand = Some(expand.into());
58        self
59    }
60    /// A limit on the number of objects to be returned.
61    /// Limit can range between 1 and 100, and the default is 10.
62    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
63        self.inner.limit = Some(limit.into());
64        self
65    }
66    /// A cursor for use in pagination.
67    /// `starting_after` is an object ID that defines your place in the list.
68    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
69    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
70        self.inner.starting_after = Some(starting_after.into());
71        self
72    }
73}
74impl ListSetupAttempt {
75    /// Send the request and return the deserialized response.
76    pub async fn send<C: StripeClient>(
77        &self,
78        client: &C,
79    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
80        self.customize().send(client).await
81    }
82
83    /// Send the request and return the deserialized response, blocking until completion.
84    pub fn send_blocking<C: StripeBlockingClient>(
85        &self,
86        client: &C,
87    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
88        self.customize().send_blocking(client)
89    }
90
91    pub fn paginate(
92        &self,
93    ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::SetupAttempt>> {
94        stripe_client_core::ListPaginator::new_list("/setup_attempts", &self.inner)
95    }
96}
97
98impl StripeRequest for ListSetupAttempt {
99    type Output = stripe_types::List<stripe_shared::SetupAttempt>;
100
101    fn build(&self) -> RequestBuilder {
102        RequestBuilder::new(StripeMethod::Get, "/setup_attempts").query(&self.inner)
103    }
104}