stripe/request/
get_refunds.rs

1use serde_json::json;
2use crate::model::*;
3use crate::FluentRequest;
4use serde::{Serialize, Deserialize};
5use httpclient::InMemoryResponseExt;
6use crate::StripeClient;
7/**You should use this struct via [`StripeClient::get_refunds`].
8
9On request success, this will return a [`GetRefundsResponse`].*/
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct GetRefundsRequest {
12    pub charge: Option<String>,
13    pub created: Option<serde_json::Value>,
14    pub ending_before: Option<String>,
15    pub expand: Option<Vec<String>>,
16    pub limit: Option<i64>,
17    pub payment_intent: Option<String>,
18    pub starting_after: Option<String>,
19}
20impl GetRefundsRequest {}
21impl FluentRequest<'_, GetRefundsRequest> {
22    pub fn charge(mut self, charge: &str) -> Self {
23        self.params.charge = Some(charge.to_owned());
24        self
25    }
26    pub fn created(mut self, created: serde_json::Value) -> Self {
27        self.params.created = Some(created);
28        self
29    }
30    pub fn ending_before(mut self, ending_before: &str) -> Self {
31        self.params.ending_before = Some(ending_before.to_owned());
32        self
33    }
34    pub fn expand(mut self, expand: impl IntoIterator<Item = impl AsRef<str>>) -> Self {
35        self
36            .params
37            .expand = Some(expand.into_iter().map(|s| s.as_ref().to_owned()).collect());
38        self
39    }
40    pub fn limit(mut self, limit: i64) -> Self {
41        self.params.limit = Some(limit);
42        self
43    }
44    pub fn payment_intent(mut self, payment_intent: &str) -> Self {
45        self.params.payment_intent = Some(payment_intent.to_owned());
46        self
47    }
48    pub fn starting_after(mut self, starting_after: &str) -> Self {
49        self.params.starting_after = Some(starting_after.to_owned());
50        self
51    }
52}
53impl<'a> ::std::future::IntoFuture for FluentRequest<'a, GetRefundsRequest> {
54    type Output = httpclient::InMemoryResult<GetRefundsResponse>;
55    type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
56    fn into_future(self) -> Self::IntoFuture {
57        Box::pin(async move {
58            let url = "/v1/refunds";
59            let mut r = self.client.client.get(url);
60            r = r.set_query(self.params);
61            r = self.client.authenticate(r);
62            let res = r.await?;
63            res.json().map_err(Into::into)
64        })
65    }
66}