stripe_misc/forwarding_request/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListForwardingRequestBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    created: Option<ListForwardingRequestCreated>,
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    #[serde(skip_serializing_if = "Option::is_none")]
16    starting_after: Option<String>,
17}
18impl ListForwardingRequestBuilder {
19    fn new() -> Self {
20        Self { created: None, ending_before: None, expand: None, limit: None, starting_after: None }
21    }
22}
23/// Similar to other List endpoints, filters results based on created timestamp.
24/// You can pass gt, gte, lt, and lte timestamp values.
25#[derive(Copy, Clone, Debug, serde::Serialize)]
26pub struct ListForwardingRequestCreated {
27    /// Return results where the `created` field is greater than this value.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub gt: Option<i64>,
30    /// Return results where the `created` field is greater than or equal to this value.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub gte: Option<i64>,
33    /// Return results where the `created` field is less than this value.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub lt: Option<i64>,
36    /// Return results where the `created` field is less than or equal to this value.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub lte: Option<i64>,
39}
40impl ListForwardingRequestCreated {
41    pub fn new() -> Self {
42        Self { gt: None, gte: None, lt: None, lte: None }
43    }
44}
45impl Default for ListForwardingRequestCreated {
46    fn default() -> Self {
47        Self::new()
48    }
49}
50/// Lists all ForwardingRequest objects.
51#[derive(Clone, Debug, serde::Serialize)]
52pub struct ListForwardingRequest {
53    inner: ListForwardingRequestBuilder,
54}
55impl ListForwardingRequest {
56    /// Construct a new `ListForwardingRequest`.
57    pub fn new() -> Self {
58        Self { inner: ListForwardingRequestBuilder::new() }
59    }
60    /// Similar to other List endpoints, filters results based on created timestamp.
61    /// You can pass gt, gte, lt, and lte timestamp values.
62    pub fn created(mut self, created: impl Into<ListForwardingRequestCreated>) -> Self {
63        self.inner.created = Some(created.into());
64        self
65    }
66    /// A pagination cursor to fetch the previous page of the list.
67    /// The value must be a ForwardingRequest ID.
68    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
69        self.inner.ending_before = Some(ending_before.into());
70        self
71    }
72    /// Specifies which fields in the response should be expanded.
73    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
74        self.inner.expand = Some(expand.into());
75        self
76    }
77    /// A limit on the number of objects to be returned.
78    /// Limit can range between 1 and 100, and the default is 10.
79    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
80        self.inner.limit = Some(limit.into());
81        self
82    }
83    /// A pagination cursor to fetch the next page of the list. The value must be a ForwardingRequest ID.
84    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
85        self.inner.starting_after = Some(starting_after.into());
86        self
87    }
88}
89impl Default for ListForwardingRequest {
90    fn default() -> Self {
91        Self::new()
92    }
93}
94impl ListForwardingRequest {
95    /// Send the request and return the deserialized response.
96    pub async fn send<C: StripeClient>(
97        &self,
98        client: &C,
99    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
100        self.customize().send(client).await
101    }
102
103    /// Send the request and return the deserialized response, blocking until completion.
104    pub fn send_blocking<C: StripeBlockingClient>(
105        &self,
106        client: &C,
107    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
108        self.customize().send_blocking(client)
109    }
110
111    pub fn paginate(
112        &self,
113    ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_misc::ForwardingRequest>> {
114        stripe_client_core::ListPaginator::new_list("/forwarding/requests", &self.inner)
115    }
116}
117
118impl StripeRequest for ListForwardingRequest {
119    type Output = stripe_types::List<stripe_misc::ForwardingRequest>;
120
121    fn build(&self) -> RequestBuilder {
122        RequestBuilder::new(StripeMethod::Get, "/forwarding/requests").query(&self.inner)
123    }
124}
125#[derive(Clone, Debug, serde::Serialize)]
126struct RetrieveForwardingRequestBuilder {
127    #[serde(skip_serializing_if = "Option::is_none")]
128    expand: Option<Vec<String>>,
129}
130impl RetrieveForwardingRequestBuilder {
131    fn new() -> Self {
132        Self { expand: None }
133    }
134}
135/// Retrieves a ForwardingRequest object.
136#[derive(Clone, Debug, serde::Serialize)]
137pub struct RetrieveForwardingRequest {
138    inner: RetrieveForwardingRequestBuilder,
139    id: stripe_misc::ForwardingRequestId,
140}
141impl RetrieveForwardingRequest {
142    /// Construct a new `RetrieveForwardingRequest`.
143    pub fn new(id: impl Into<stripe_misc::ForwardingRequestId>) -> Self {
144        Self { id: id.into(), inner: RetrieveForwardingRequestBuilder::new() }
145    }
146    /// Specifies which fields in the response should be expanded.
147    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
148        self.inner.expand = Some(expand.into());
149        self
150    }
151}
152impl RetrieveForwardingRequest {
153    /// Send the request and return the deserialized response.
154    pub async fn send<C: StripeClient>(
155        &self,
156        client: &C,
157    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
158        self.customize().send(client).await
159    }
160
161    /// Send the request and return the deserialized response, blocking until completion.
162    pub fn send_blocking<C: StripeBlockingClient>(
163        &self,
164        client: &C,
165    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
166        self.customize().send_blocking(client)
167    }
168}
169
170impl StripeRequest for RetrieveForwardingRequest {
171    type Output = stripe_misc::ForwardingRequest;
172
173    fn build(&self) -> RequestBuilder {
174        let id = &self.id;
175        RequestBuilder::new(StripeMethod::Get, format!("/forwarding/requests/{id}"))
176            .query(&self.inner)
177    }
178}
179#[derive(Clone, Debug, serde::Serialize)]
180struct CreateForwardingRequestBuilder {
181    #[serde(skip_serializing_if = "Option::is_none")]
182    expand: Option<Vec<String>>,
183    #[serde(skip_serializing_if = "Option::is_none")]
184    metadata: Option<std::collections::HashMap<String, String>>,
185    payment_method: String,
186    replacements: Vec<stripe_misc::ForwardingRequestReplacements>,
187    #[serde(skip_serializing_if = "Option::is_none")]
188    request: Option<CreateForwardingRequestRequest>,
189    url: String,
190}
191impl CreateForwardingRequestBuilder {
192    fn new(
193        payment_method: impl Into<String>,
194        replacements: impl Into<Vec<stripe_misc::ForwardingRequestReplacements>>,
195        url: impl Into<String>,
196    ) -> Self {
197        Self {
198            expand: None,
199            metadata: None,
200            payment_method: payment_method.into(),
201            replacements: replacements.into(),
202            request: None,
203            url: url.into(),
204        }
205    }
206}
207/// The request body and headers to be sent to the destination endpoint.
208#[derive(Clone, Debug, serde::Serialize)]
209pub struct CreateForwardingRequestRequest {
210    /// The body payload to send to the destination endpoint.
211    #[serde(skip_serializing_if = "Option::is_none")]
212    pub body: Option<String>,
213    /// The headers to include in the forwarded request.
214    /// Can be omitted if no additional headers (excluding Stripe-generated ones such as the Content-Type header) should be included.
215    #[serde(skip_serializing_if = "Option::is_none")]
216    pub headers: Option<Vec<CreateForwardingRequestRequestHeaders>>,
217}
218impl CreateForwardingRequestRequest {
219    pub fn new() -> Self {
220        Self { body: None, headers: None }
221    }
222}
223impl Default for CreateForwardingRequestRequest {
224    fn default() -> Self {
225        Self::new()
226    }
227}
228/// The headers to include in the forwarded request.
229/// Can be omitted if no additional headers (excluding Stripe-generated ones such as the Content-Type header) should be included.
230#[derive(Clone, Debug, serde::Serialize)]
231pub struct CreateForwardingRequestRequestHeaders {
232    /// The header name.
233    pub name: String,
234    /// The header value.
235    pub value: String,
236}
237impl CreateForwardingRequestRequestHeaders {
238    pub fn new(name: impl Into<String>, value: impl Into<String>) -> Self {
239        Self { name: name.into(), value: value.into() }
240    }
241}
242/// Creates a ForwardingRequest object.
243#[derive(Clone, Debug, serde::Serialize)]
244pub struct CreateForwardingRequest {
245    inner: CreateForwardingRequestBuilder,
246}
247impl CreateForwardingRequest {
248    /// Construct a new `CreateForwardingRequest`.
249    pub fn new(
250        payment_method: impl Into<String>,
251        replacements: impl Into<Vec<stripe_misc::ForwardingRequestReplacements>>,
252        url: impl Into<String>,
253    ) -> Self {
254        Self {
255            inner: CreateForwardingRequestBuilder::new(
256                payment_method.into(),
257                replacements.into(),
258                url.into(),
259            ),
260        }
261    }
262    /// Specifies which fields in the response should be expanded.
263    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
264        self.inner.expand = Some(expand.into());
265        self
266    }
267    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
268    /// This can be useful for storing additional information about the object in a structured format.
269    /// Individual keys can be unset by posting an empty value to them.
270    /// All keys can be unset by posting an empty value to `metadata`.
271    pub fn metadata(
272        mut self,
273        metadata: impl Into<std::collections::HashMap<String, String>>,
274    ) -> Self {
275        self.inner.metadata = Some(metadata.into());
276        self
277    }
278    /// The request body and headers to be sent to the destination endpoint.
279    pub fn request(mut self, request: impl Into<CreateForwardingRequestRequest>) -> Self {
280        self.inner.request = Some(request.into());
281        self
282    }
283}
284impl CreateForwardingRequest {
285    /// Send the request and return the deserialized response.
286    pub async fn send<C: StripeClient>(
287        &self,
288        client: &C,
289    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
290        self.customize().send(client).await
291    }
292
293    /// Send the request and return the deserialized response, blocking until completion.
294    pub fn send_blocking<C: StripeBlockingClient>(
295        &self,
296        client: &C,
297    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
298        self.customize().send_blocking(client)
299    }
300}
301
302impl StripeRequest for CreateForwardingRequest {
303    type Output = stripe_misc::ForwardingRequest;
304
305    fn build(&self) -> RequestBuilder {
306        RequestBuilder::new(StripeMethod::Post, "/forwarding/requests").form(&self.inner)
307    }
308}