Skip to main content

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