stripe_misc/exchange_rate/
requests.rs1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListExchangeRateBuilder {
7 #[serde(skip_serializing_if = "Option::is_none")]
8 ending_before: Option<String>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 expand: Option<Vec<String>>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 limit: Option<i64>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 starting_after: Option<String>,
15}
16impl ListExchangeRateBuilder {
17 fn new() -> Self {
18 Self { ending_before: None, expand: None, limit: None, starting_after: None }
19 }
20}
21#[derive(Clone, Debug, serde::Serialize)]
27pub struct ListExchangeRate {
28 inner: ListExchangeRateBuilder,
29}
30impl ListExchangeRate {
31 pub fn new() -> Self {
33 Self { inner: ListExchangeRateBuilder::new() }
34 }
35 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
39 self.inner.ending_before = Some(ending_before.into());
40 self
41 }
42 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
44 self.inner.expand = Some(expand.into());
45 self
46 }
47 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
50 self.inner.limit = Some(limit.into());
51 self
52 }
53 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
57 self.inner.starting_after = Some(starting_after.into());
58 self
59 }
60}
61impl Default for ListExchangeRate {
62 fn default() -> Self {
63 Self::new()
64 }
65}
66impl ListExchangeRate {
67 pub async fn send<C: StripeClient>(
69 &self,
70 client: &C,
71 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
72 self.customize().send(client).await
73 }
74
75 pub fn send_blocking<C: StripeBlockingClient>(
77 &self,
78 client: &C,
79 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
80 self.customize().send_blocking(client)
81 }
82
83 pub fn paginate(
84 &self,
85 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_misc::ExchangeRate>> {
86 stripe_client_core::ListPaginator::new_list("/exchange_rates", &self.inner)
87 }
88}
89
90impl StripeRequest for ListExchangeRate {
91 type Output = stripe_types::List<stripe_misc::ExchangeRate>;
92
93 fn build(&self) -> RequestBuilder {
94 RequestBuilder::new(StripeMethod::Get, "/exchange_rates").query(&self.inner)
95 }
96}
97#[derive(Clone, Debug, serde::Serialize)]
98struct RetrieveExchangeRateBuilder {
99 #[serde(skip_serializing_if = "Option::is_none")]
100 expand: Option<Vec<String>>,
101}
102impl RetrieveExchangeRateBuilder {
103 fn new() -> Self {
104 Self { expand: None }
105 }
106}
107#[derive(Clone, Debug, serde::Serialize)]
112pub struct RetrieveExchangeRate {
113 inner: RetrieveExchangeRateBuilder,
114 rate_id: stripe_misc::ExchangeRateId,
115}
116impl RetrieveExchangeRate {
117 pub fn new(rate_id: impl Into<stripe_misc::ExchangeRateId>) -> Self {
119 Self { rate_id: rate_id.into(), inner: RetrieveExchangeRateBuilder::new() }
120 }
121 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
123 self.inner.expand = Some(expand.into());
124 self
125 }
126}
127impl RetrieveExchangeRate {
128 pub async fn send<C: StripeClient>(
130 &self,
131 client: &C,
132 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
133 self.customize().send(client).await
134 }
135
136 pub fn send_blocking<C: StripeBlockingClient>(
138 &self,
139 client: &C,
140 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
141 self.customize().send_blocking(client)
142 }
143}
144
145impl StripeRequest for RetrieveExchangeRate {
146 type Output = stripe_misc::ExchangeRate;
147
148 fn build(&self) -> RequestBuilder {
149 let rate_id = &self.rate_id;
150 RequestBuilder::new(StripeMethod::Get, format!("/exchange_rates/{rate_id}"))
151 .query(&self.inner)
152 }
153}