stripe_misc/climate_order/
requests.rs

1use 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/// Lists all Climate order objects. The orders are returned sorted by creation date, with the
22/// most recently created orders appearing first.
23#[derive(Clone, Debug, serde::Serialize)]
24pub struct ListClimateOrder {
25    inner: ListClimateOrderBuilder,
26}
27impl ListClimateOrder {
28    /// Construct a new `ListClimateOrder`.
29    pub fn new() -> Self {
30        Self { inner: ListClimateOrderBuilder::new() }
31    }
32    /// A cursor for use in pagination.
33    /// `ending_before` is an object ID that defines your place in the list.
34    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
35    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    /// Specifies which fields in the response should be expanded.
40    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
41        self.inner.expand = Some(expand.into());
42        self
43    }
44    /// A limit on the number of objects to be returned.
45    /// Limit can range between 1 and 100, and the default is 10.
46    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
47        self.inner.limit = Some(limit.into());
48        self
49    }
50    /// A cursor for use in pagination.
51    /// `starting_after` is an object ID that defines your place in the list.
52    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
53    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    /// Send the request and return the deserialized response.
65    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    /// Send the request and return the deserialized response, blocking until completion.
73    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/// Retrieves the details of a Climate order object with the given ID.
105#[derive(Clone, Debug, serde::Serialize)]
106pub struct RetrieveClimateOrder {
107    inner: RetrieveClimateOrderBuilder,
108    order: stripe_misc::ClimateOrderId,
109}
110impl RetrieveClimateOrder {
111    /// Construct a new `RetrieveClimateOrder`.
112    pub fn new(order: impl Into<stripe_misc::ClimateOrderId>) -> Self {
113        Self { order: order.into(), inner: RetrieveClimateOrderBuilder::new() }
114    }
115    /// Specifies which fields in the response should be expanded.
116    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    /// Send the request and return the deserialized response.
123    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    /// Send the request and return the deserialized response, blocking until completion.
131    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/// Creates a Climate order object for a given Climate product. The order will be processed immediately
178/// after creation and payment will be deducted your Stripe balance.
179#[derive(Clone, Debug, serde::Serialize)]
180pub struct CreateClimateOrder {
181    inner: CreateClimateOrderBuilder,
182}
183impl CreateClimateOrder {
184    /// Construct a new `CreateClimateOrder`.
185    pub fn new(product: impl Into<String>) -> Self {
186        Self { inner: CreateClimateOrderBuilder::new(product.into()) }
187    }
188    /// Requested amount of carbon removal units. Either this or `metric_tons` must be specified.
189    pub fn amount(mut self, amount: impl Into<i64>) -> Self {
190        self.inner.amount = Some(amount.into());
191        self
192    }
193    /// Publicly sharable reference for the end beneficiary of carbon removal.
194    /// Assumed to be the Stripe account if not set.
195    pub fn beneficiary(mut self, beneficiary: impl Into<BeneficiaryParams>) -> Self {
196        self.inner.beneficiary = Some(beneficiary.into());
197        self
198    }
199    /// Request currency for the order as a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
200    /// Must be a supported [settlement currency for your account](https://stripe.com/docs/currencies).
201    /// If omitted, the account's default currency will be used.
202    pub fn currency(mut self, currency: impl Into<stripe_types::Currency>) -> Self {
203        self.inner.currency = Some(currency.into());
204        self
205    }
206    /// Specifies which fields in the response should be expanded.
207    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
208        self.inner.expand = Some(expand.into());
209        self
210    }
211    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
212    /// This can be useful for storing additional information about the object in a structured format.
213    /// Individual keys can be unset by posting an empty value to them.
214    /// All keys can be unset by posting an empty value to `metadata`.
215    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    /// Requested number of tons for the order. Either this or `amount` must be specified.
223    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    /// Send the request and return the deserialized response.
230    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    /// Send the request and return the deserialized response, blocking until completion.
238    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/// Updates the specified order by setting the values of the parameters passed.
268#[derive(Clone, Debug, serde::Serialize)]
269pub struct UpdateClimateOrder {
270    inner: UpdateClimateOrderBuilder,
271    order: stripe_misc::ClimateOrderId,
272}
273impl UpdateClimateOrder {
274    /// Construct a new `UpdateClimateOrder`.
275    pub fn new(order: impl Into<stripe_misc::ClimateOrderId>) -> Self {
276        Self { order: order.into(), inner: UpdateClimateOrderBuilder::new() }
277    }
278    /// Publicly sharable reference for the end beneficiary of carbon removal.
279    /// Assumed to be the Stripe account if not set.
280    pub fn beneficiary(mut self, beneficiary: impl Into<BeneficiaryParams>) -> Self {
281        self.inner.beneficiary = Some(beneficiary.into());
282        self
283    }
284    /// Specifies which fields in the response should be expanded.
285    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
286        self.inner.expand = Some(expand.into());
287        self
288    }
289    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
290    /// This can be useful for storing additional information about the object in a structured format.
291    /// Individual keys can be unset by posting an empty value to them.
292    /// All keys can be unset by posting an empty value to `metadata`.
293    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    /// Send the request and return the deserialized response.
303    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    /// Send the request and return the deserialized response, blocking until completion.
311    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/// Cancels a Climate order. You can cancel an order within 24 hours of creation. Stripe refunds the
339/// reservation `amount_subtotal`, but not the `amount_fees` for user-triggered cancellations. Frontier
340/// might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe
341/// provides 90 days advance notice and refunds the `amount_total`.
342#[derive(Clone, Debug, serde::Serialize)]
343pub struct CancelClimateOrder {
344    inner: CancelClimateOrderBuilder,
345    order: stripe_misc::ClimateOrderId,
346}
347impl CancelClimateOrder {
348    /// Construct a new `CancelClimateOrder`.
349    pub fn new(order: impl Into<stripe_misc::ClimateOrderId>) -> Self {
350        Self { order: order.into(), inner: CancelClimateOrderBuilder::new() }
351    }
352    /// Specifies which fields in the response should be expanded.
353    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    /// Send the request and return the deserialized response.
360    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    /// Send the request and return the deserialized response, blocking until completion.
368    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    /// Publicly displayable name for the end beneficiary of carbon removal.
389    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}