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)]
24pub struct ListExchangeRate {
25 inner: ListExchangeRateBuilder,
26}
27impl ListExchangeRate {
28 pub fn new() -> Self {
30 Self { inner: ListExchangeRateBuilder::new() }
31 }
32 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
36 self.inner.ending_before = Some(ending_before.into());
37 self
38 }
39 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
41 self.inner.expand = Some(expand.into());
42 self
43 }
44 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
47 self.inner.limit = Some(limit.into());
48 self
49 }
50 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
54 self.inner.starting_after = Some(starting_after.into());
55 self
56 }
57}
58impl Default for ListExchangeRate {
59 fn default() -> Self {
60 Self::new()
61 }
62}
63impl ListExchangeRate {
64 pub async fn send<C: StripeClient>(
66 &self,
67 client: &C,
68 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
69 self.customize().send(client).await
70 }
71
72 pub fn send_blocking<C: StripeBlockingClient>(
74 &self,
75 client: &C,
76 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
77 self.customize().send_blocking(client)
78 }
79
80 pub fn paginate(
81 &self,
82 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_misc::ExchangeRate>> {
83 stripe_client_core::ListPaginator::new_list("/exchange_rates", &self.inner)
84 }
85}
86
87impl StripeRequest for ListExchangeRate {
88 type Output = stripe_types::List<stripe_misc::ExchangeRate>;
89
90 fn build(&self) -> RequestBuilder {
91 RequestBuilder::new(StripeMethod::Get, "/exchange_rates").query(&self.inner)
92 }
93}
94#[derive(Clone, Debug, serde::Serialize)]
95struct RetrieveExchangeRateBuilder {
96 #[serde(skip_serializing_if = "Option::is_none")]
97 expand: Option<Vec<String>>,
98}
99impl RetrieveExchangeRateBuilder {
100 fn new() -> Self {
101 Self { expand: None }
102 }
103}
104#[derive(Clone, Debug, serde::Serialize)]
106pub struct RetrieveExchangeRate {
107 inner: RetrieveExchangeRateBuilder,
108 rate_id: stripe_misc::ExchangeRateId,
109}
110impl RetrieveExchangeRate {
111 pub fn new(rate_id: impl Into<stripe_misc::ExchangeRateId>) -> Self {
113 Self { rate_id: rate_id.into(), inner: RetrieveExchangeRateBuilder::new() }
114 }
115 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
117 self.inner.expand = Some(expand.into());
118 self
119 }
120}
121impl RetrieveExchangeRate {
122 pub async fn send<C: StripeClient>(
124 &self,
125 client: &C,
126 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
127 self.customize().send(client).await
128 }
129
130 pub fn send_blocking<C: StripeBlockingClient>(
132 &self,
133 client: &C,
134 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
135 self.customize().send_blocking(client)
136 }
137}
138
139impl StripeRequest for RetrieveExchangeRate {
140 type Output = stripe_misc::ExchangeRate;
141
142 fn build(&self) -> RequestBuilder {
143 let rate_id = &self.rate_id;
144 RequestBuilder::new(StripeMethod::Get, format!("/exchange_rates/{rate_id}"))
145 .query(&self.inner)
146 }
147}