stripe_misc/climate_order/
requests.rs1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListClimateOrderBuilder {
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 ListClimateOrderBuilder {
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 ListClimateOrder {
25 inner: ListClimateOrderBuilder,
26}
27impl ListClimateOrder {
28 pub fn new() -> Self {
30 Self { inner: ListClimateOrderBuilder::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 ListClimateOrder {
59 fn default() -> Self {
60 Self::new()
61 }
62}
63impl ListClimateOrder {
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::ClimateOrder>> {
83 stripe_client_core::ListPaginator::new_list("/climate/orders", &self.inner)
84 }
85}
86
87impl StripeRequest for ListClimateOrder {
88 type Output = stripe_types::List<stripe_misc::ClimateOrder>;
89
90 fn build(&self) -> RequestBuilder {
91 RequestBuilder::new(StripeMethod::Get, "/climate/orders").query(&self.inner)
92 }
93}
94#[derive(Clone, Debug, serde::Serialize)]
95struct RetrieveClimateOrderBuilder {
96 #[serde(skip_serializing_if = "Option::is_none")]
97 expand: Option<Vec<String>>,
98}
99impl RetrieveClimateOrderBuilder {
100 fn new() -> Self {
101 Self { expand: None }
102 }
103}
104#[derive(Clone, Debug, serde::Serialize)]
106pub struct RetrieveClimateOrder {
107 inner: RetrieveClimateOrderBuilder,
108 order: stripe_misc::ClimateOrderId,
109}
110impl RetrieveClimateOrder {
111 pub fn new(order: impl Into<stripe_misc::ClimateOrderId>) -> Self {
113 Self { order: order.into(), inner: RetrieveClimateOrderBuilder::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 RetrieveClimateOrder {
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 RetrieveClimateOrder {
140 type Output = stripe_misc::ClimateOrder;
141
142 fn build(&self) -> RequestBuilder {
143 let order = &self.order;
144 RequestBuilder::new(StripeMethod::Get, format!("/climate/orders/{order}"))
145 .query(&self.inner)
146 }
147}
148#[derive(Clone, Debug, serde::Serialize)]
149struct CreateClimateOrderBuilder {
150 #[serde(skip_serializing_if = "Option::is_none")]
151 amount: Option<i64>,
152 #[serde(skip_serializing_if = "Option::is_none")]
153 beneficiary: Option<BeneficiaryParams>,
154 #[serde(skip_serializing_if = "Option::is_none")]
155 currency: Option<stripe_types::Currency>,
156 #[serde(skip_serializing_if = "Option::is_none")]
157 expand: Option<Vec<String>>,
158 #[serde(skip_serializing_if = "Option::is_none")]
159 metadata: Option<std::collections::HashMap<String, String>>,
160 #[serde(skip_serializing_if = "Option::is_none")]
161 metric_tons: Option<String>,
162 product: String,
163}
164impl CreateClimateOrderBuilder {
165 fn new(product: impl Into<String>) -> Self {
166 Self {
167 amount: None,
168 beneficiary: None,
169 currency: None,
170 expand: None,
171 metadata: None,
172 metric_tons: None,
173 product: product.into(),
174 }
175 }
176}
177#[derive(Clone, Debug, serde::Serialize)]
180pub struct CreateClimateOrder {
181 inner: CreateClimateOrderBuilder,
182}
183impl CreateClimateOrder {
184 pub fn new(product: impl Into<String>) -> Self {
186 Self { inner: CreateClimateOrderBuilder::new(product.into()) }
187 }
188 pub fn amount(mut self, amount: impl Into<i64>) -> Self {
190 self.inner.amount = Some(amount.into());
191 self
192 }
193 pub fn beneficiary(mut self, beneficiary: impl Into<BeneficiaryParams>) -> Self {
196 self.inner.beneficiary = Some(beneficiary.into());
197 self
198 }
199 pub fn currency(mut self, currency: impl Into<stripe_types::Currency>) -> Self {
203 self.inner.currency = Some(currency.into());
204 self
205 }
206 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
208 self.inner.expand = Some(expand.into());
209 self
210 }
211 pub fn metadata(
216 mut self,
217 metadata: impl Into<std::collections::HashMap<String, String>>,
218 ) -> Self {
219 self.inner.metadata = Some(metadata.into());
220 self
221 }
222 pub fn metric_tons(mut self, metric_tons: impl Into<String>) -> Self {
224 self.inner.metric_tons = Some(metric_tons.into());
225 self
226 }
227}
228impl CreateClimateOrder {
229 pub async fn send<C: StripeClient>(
231 &self,
232 client: &C,
233 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
234 self.customize().send(client).await
235 }
236
237 pub fn send_blocking<C: StripeBlockingClient>(
239 &self,
240 client: &C,
241 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
242 self.customize().send_blocking(client)
243 }
244}
245
246impl StripeRequest for CreateClimateOrder {
247 type Output = stripe_misc::ClimateOrder;
248
249 fn build(&self) -> RequestBuilder {
250 RequestBuilder::new(StripeMethod::Post, "/climate/orders").form(&self.inner)
251 }
252}
253#[derive(Clone, Debug, serde::Serialize)]
254struct UpdateClimateOrderBuilder {
255 #[serde(skip_serializing_if = "Option::is_none")]
256 beneficiary: Option<BeneficiaryParams>,
257 #[serde(skip_serializing_if = "Option::is_none")]
258 expand: Option<Vec<String>>,
259 #[serde(skip_serializing_if = "Option::is_none")]
260 metadata: Option<std::collections::HashMap<String, String>>,
261}
262impl UpdateClimateOrderBuilder {
263 fn new() -> Self {
264 Self { beneficiary: None, expand: None, metadata: None }
265 }
266}
267#[derive(Clone, Debug, serde::Serialize)]
269pub struct UpdateClimateOrder {
270 inner: UpdateClimateOrderBuilder,
271 order: stripe_misc::ClimateOrderId,
272}
273impl UpdateClimateOrder {
274 pub fn new(order: impl Into<stripe_misc::ClimateOrderId>) -> Self {
276 Self { order: order.into(), inner: UpdateClimateOrderBuilder::new() }
277 }
278 pub fn beneficiary(mut self, beneficiary: impl Into<BeneficiaryParams>) -> Self {
281 self.inner.beneficiary = Some(beneficiary.into());
282 self
283 }
284 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
286 self.inner.expand = Some(expand.into());
287 self
288 }
289 pub fn metadata(
294 mut self,
295 metadata: impl Into<std::collections::HashMap<String, String>>,
296 ) -> Self {
297 self.inner.metadata = Some(metadata.into());
298 self
299 }
300}
301impl UpdateClimateOrder {
302 pub async fn send<C: StripeClient>(
304 &self,
305 client: &C,
306 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
307 self.customize().send(client).await
308 }
309
310 pub fn send_blocking<C: StripeBlockingClient>(
312 &self,
313 client: &C,
314 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
315 self.customize().send_blocking(client)
316 }
317}
318
319impl StripeRequest for UpdateClimateOrder {
320 type Output = stripe_misc::ClimateOrder;
321
322 fn build(&self) -> RequestBuilder {
323 let order = &self.order;
324 RequestBuilder::new(StripeMethod::Post, format!("/climate/orders/{order}"))
325 .form(&self.inner)
326 }
327}
328#[derive(Clone, Debug, serde::Serialize)]
329struct CancelClimateOrderBuilder {
330 #[serde(skip_serializing_if = "Option::is_none")]
331 expand: Option<Vec<String>>,
332}
333impl CancelClimateOrderBuilder {
334 fn new() -> Self {
335 Self { expand: None }
336 }
337}
338#[derive(Clone, Debug, serde::Serialize)]
343pub struct CancelClimateOrder {
344 inner: CancelClimateOrderBuilder,
345 order: stripe_misc::ClimateOrderId,
346}
347impl CancelClimateOrder {
348 pub fn new(order: impl Into<stripe_misc::ClimateOrderId>) -> Self {
350 Self { order: order.into(), inner: CancelClimateOrderBuilder::new() }
351 }
352 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
354 self.inner.expand = Some(expand.into());
355 self
356 }
357}
358impl CancelClimateOrder {
359 pub async fn send<C: StripeClient>(
361 &self,
362 client: &C,
363 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
364 self.customize().send(client).await
365 }
366
367 pub fn send_blocking<C: StripeBlockingClient>(
369 &self,
370 client: &C,
371 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
372 self.customize().send_blocking(client)
373 }
374}
375
376impl StripeRequest for CancelClimateOrder {
377 type Output = stripe_misc::ClimateOrder;
378
379 fn build(&self) -> RequestBuilder {
380 let order = &self.order;
381 RequestBuilder::new(StripeMethod::Post, format!("/climate/orders/{order}/cancel"))
382 .form(&self.inner)
383 }
384}
385
386#[derive(Clone, Debug, serde::Serialize)]
387pub struct BeneficiaryParams {
388 pub public_name: String,
390}
391impl BeneficiaryParams {
392 pub fn new(public_name: impl Into<String>) -> Self {
393 Self { public_name: public_name.into() }
394 }
395}