Skip to main content

stripe_connect/application_fee/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Eq, PartialEq)]
6#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
7#[derive(serde::Serialize)]
8struct ListApplicationFeeBuilder {
9    #[serde(skip_serializing_if = "Option::is_none")]
10    charge: Option<String>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    created: Option<stripe_types::RangeQueryTs>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    ending_before: Option<String>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    expand: Option<Vec<String>>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    limit: Option<i64>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    starting_after: Option<String>,
21}
22#[cfg(feature = "redact-generated-debug")]
23impl std::fmt::Debug for ListApplicationFeeBuilder {
24    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
25        f.debug_struct("ListApplicationFeeBuilder").finish_non_exhaustive()
26    }
27}
28impl ListApplicationFeeBuilder {
29    fn new() -> Self {
30        Self {
31            charge: None,
32            created: None,
33            ending_before: None,
34            expand: None,
35            limit: None,
36            starting_after: None,
37        }
38    }
39}
40/// Returns a list of application fees you’ve previously collected.
41/// The application fees are returned in sorted order, with the most recent fees appearing first.
42#[derive(Clone)]
43#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
44#[derive(serde::Serialize)]
45pub struct ListApplicationFee {
46    inner: ListApplicationFeeBuilder,
47}
48#[cfg(feature = "redact-generated-debug")]
49impl std::fmt::Debug for ListApplicationFee {
50    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
51        f.debug_struct("ListApplicationFee").finish_non_exhaustive()
52    }
53}
54impl ListApplicationFee {
55    /// Construct a new `ListApplicationFee`.
56    pub fn new() -> Self {
57        Self { inner: ListApplicationFeeBuilder::new() }
58    }
59    /// Only return application fees for the charge specified by this charge ID.
60    pub fn charge(mut self, charge: impl Into<String>) -> Self {
61        self.inner.charge = Some(charge.into());
62        self
63    }
64    /// Only return applications fees that were created during the given date interval.
65    pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
66        self.inner.created = Some(created.into());
67        self
68    }
69    /// A cursor for use in pagination.
70    /// `ending_before` is an object ID that defines your place in the list.
71    /// 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.
72    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
73        self.inner.ending_before = Some(ending_before.into());
74        self
75    }
76    /// Specifies which fields in the response should be expanded.
77    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
78        self.inner.expand = Some(expand.into());
79        self
80    }
81    /// A limit on the number of objects to be returned.
82    /// Limit can range between 1 and 100, and the default is 10.
83    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
84        self.inner.limit = Some(limit.into());
85        self
86    }
87    /// A cursor for use in pagination.
88    /// `starting_after` is an object ID that defines your place in the list.
89    /// 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.
90    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
91        self.inner.starting_after = Some(starting_after.into());
92        self
93    }
94}
95impl Default for ListApplicationFee {
96    fn default() -> Self {
97        Self::new()
98    }
99}
100impl ListApplicationFee {
101    /// Send the request and return the deserialized response.
102    pub async fn send<C: StripeClient>(
103        &self,
104        client: &C,
105    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
106        self.customize().send(client).await
107    }
108
109    /// Send the request and return the deserialized response, blocking until completion.
110    pub fn send_blocking<C: StripeBlockingClient>(
111        &self,
112        client: &C,
113    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
114        self.customize().send_blocking(client)
115    }
116
117    pub fn paginate(
118        &self,
119    ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::ApplicationFee>> {
120        stripe_client_core::ListPaginator::new_list("/application_fees", &self.inner)
121    }
122}
123
124impl StripeRequest for ListApplicationFee {
125    type Output = stripe_types::List<stripe_shared::ApplicationFee>;
126
127    fn build(&self) -> RequestBuilder {
128        RequestBuilder::new(StripeMethod::Get, "/application_fees").query(&self.inner)
129    }
130}
131#[derive(Clone, Eq, PartialEq)]
132#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
133#[derive(serde::Serialize)]
134struct RetrieveApplicationFeeBuilder {
135    #[serde(skip_serializing_if = "Option::is_none")]
136    expand: Option<Vec<String>>,
137}
138#[cfg(feature = "redact-generated-debug")]
139impl std::fmt::Debug for RetrieveApplicationFeeBuilder {
140    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
141        f.debug_struct("RetrieveApplicationFeeBuilder").finish_non_exhaustive()
142    }
143}
144impl RetrieveApplicationFeeBuilder {
145    fn new() -> Self {
146        Self { expand: None }
147    }
148}
149/// Retrieves the details of an application fee that your account has collected.
150/// The same information is returned when refunding the application fee.
151#[derive(Clone)]
152#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
153#[derive(serde::Serialize)]
154pub struct RetrieveApplicationFee {
155    inner: RetrieveApplicationFeeBuilder,
156    id: stripe_shared::ApplicationFeeId,
157}
158#[cfg(feature = "redact-generated-debug")]
159impl std::fmt::Debug for RetrieveApplicationFee {
160    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
161        f.debug_struct("RetrieveApplicationFee").finish_non_exhaustive()
162    }
163}
164impl RetrieveApplicationFee {
165    /// Construct a new `RetrieveApplicationFee`.
166    pub fn new(id: impl Into<stripe_shared::ApplicationFeeId>) -> Self {
167        Self { id: id.into(), inner: RetrieveApplicationFeeBuilder::new() }
168    }
169    /// Specifies which fields in the response should be expanded.
170    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
171        self.inner.expand = Some(expand.into());
172        self
173    }
174}
175impl RetrieveApplicationFee {
176    /// Send the request and return the deserialized response.
177    pub async fn send<C: StripeClient>(
178        &self,
179        client: &C,
180    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
181        self.customize().send(client).await
182    }
183
184    /// Send the request and return the deserialized response, blocking until completion.
185    pub fn send_blocking<C: StripeBlockingClient>(
186        &self,
187        client: &C,
188    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
189        self.customize().send_blocking(client)
190    }
191}
192
193impl StripeRequest for RetrieveApplicationFee {
194    type Output = stripe_shared::ApplicationFee;
195
196    fn build(&self) -> RequestBuilder {
197        let id = &self.id;
198        RequestBuilder::new(StripeMethod::Get, format!("/application_fees/{id}")).query(&self.inner)
199    }
200}