stripe_core/mandate/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct RetrieveMandateBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    expand: Option<Vec<String>>,
9}
10impl RetrieveMandateBuilder {
11    fn new() -> Self {
12        Self { expand: None }
13    }
14}
15/// Retrieves a Mandate object.
16#[derive(Clone, Debug, serde::Serialize)]
17pub struct RetrieveMandate {
18    inner: RetrieveMandateBuilder,
19    mandate: stripe_shared::MandateId,
20}
21impl RetrieveMandate {
22    /// Construct a new `RetrieveMandate`.
23    pub fn new(mandate: impl Into<stripe_shared::MandateId>) -> Self {
24        Self { mandate: mandate.into(), inner: RetrieveMandateBuilder::new() }
25    }
26    /// Specifies which fields in the response should be expanded.
27    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
28        self.inner.expand = Some(expand.into());
29        self
30    }
31}
32impl RetrieveMandate {
33    /// Send the request and return the deserialized response.
34    pub async fn send<C: StripeClient>(
35        &self,
36        client: &C,
37    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
38        self.customize().send(client).await
39    }
40
41    /// Send the request and return the deserialized response, blocking until completion.
42    pub fn send_blocking<C: StripeBlockingClient>(
43        &self,
44        client: &C,
45    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
46        self.customize().send_blocking(client)
47    }
48}
49
50impl StripeRequest for RetrieveMandate {
51    type Output = stripe_shared::Mandate;
52
53    fn build(&self) -> RequestBuilder {
54        let mandate = &self.mandate;
55        RequestBuilder::new(StripeMethod::Get, format!("/mandates/{mandate}")).query(&self.inner)
56    }
57}