kittycad/
payments.rs

1use anyhow::Result;
2
3use crate::Client;
4#[derive(Clone, Debug)]
5pub struct Payments {
6    pub client: Client,
7}
8
9impl Payments {
10    #[doc(hidden)]
11    pub fn new(client: Client) -> Self {
12        Self { client }
13    }
14
15    #[doc = "Get payment info about your org.\n\nThis includes billing address, phone, and \
16             name.\n\nThis endpoint requires authentication by an org admin. It gets the payment \
17             information for the authenticated user's org.\n\n```rust,no_run\nasync fn \
18             example_payments_get_information_for_org() -> anyhow::Result<()> {\n    let client = \
19             kittycad::Client::new_from_env();\n    let result: kittycad::types::Customer = \
20             client.payments().get_information_for_org().await?;\n    println!(\"{:?}\", \
21             result);\n    Ok(())\n}\n```"]
22    #[tracing::instrument]
23    pub async fn get_information_for_org<'a>(
24        &'a self,
25    ) -> Result<crate::types::Customer, crate::types::error::Error> {
26        let mut req = self.client.client.request(
27            http::Method::GET,
28            format!("{}/{}", self.client.base_url, "org/payment"),
29        );
30        req = req.bearer_auth(&self.client.token);
31        let resp = req.send().await?;
32        let status = resp.status();
33        if status.is_success() {
34            let text = resp.text().await.unwrap_or_default();
35            serde_json::from_str(&text).map_err(|err| {
36                crate::types::error::Error::from_serde_error(
37                    format_serde_error::SerdeError::new(text.to_string(), err),
38                    status,
39                )
40            })
41        } else {
42            let text = resp.text().await.unwrap_or_default();
43            Err(crate::types::error::Error::Server {
44                body: text.to_string(),
45                status,
46            })
47        }
48    }
49
50    #[doc = "Update payment info for your org.\n\nThis includes billing address, phone, and \
51             name.\n\nThis endpoint requires authentication by an org admin. It updates the \
52             payment information for the authenticated user's org.\n\n```rust,no_run\nuse \
53             std::str::FromStr;\nasync fn example_payments_update_information_for_org() -> \
54             anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let \
55             result: kittycad::types::Customer = client\n        .payments()\n        \
56             .update_information_for_org(&kittycad::types::BillingInfo {\n            address: \
57             Some(kittycad::types::AddressDetails {\n                city: \
58             Some(\"some-string\".to_string()),\n                country: \
59             \"some-string\".to_string(),\n                state: \
60             Some(\"some-string\".to_string()),\n                street_1: \
61             Some(\"some-string\".to_string()),\n                street_2: \
62             Some(\"some-string\".to_string()),\n                zip: \
63             Some(\"some-string\".to_string()),\n            }),\n            name: \
64             Some(\"some-string\".to_string()),\n            phone: \
65             kittycad::types::phone_number::PhoneNumber::from_str(\"+1555-555-5555\")?,\n        \
66             })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
67    #[tracing::instrument]
68    pub async fn update_information_for_org<'a>(
69        &'a self,
70        body: &crate::types::BillingInfo,
71    ) -> Result<crate::types::Customer, crate::types::error::Error> {
72        let mut req = self.client.client.request(
73            http::Method::PUT,
74            format!("{}/{}", self.client.base_url, "org/payment"),
75        );
76        req = req.bearer_auth(&self.client.token);
77        req = req.json(body);
78        let resp = req.send().await?;
79        let status = resp.status();
80        if status.is_success() {
81            let text = resp.text().await.unwrap_or_default();
82            serde_json::from_str(&text).map_err(|err| {
83                crate::types::error::Error::from_serde_error(
84                    format_serde_error::SerdeError::new(text.to_string(), err),
85                    status,
86                )
87            })
88        } else {
89            let text = resp.text().await.unwrap_or_default();
90            Err(crate::types::error::Error::Server {
91                body: text.to_string(),
92                status,
93            })
94        }
95    }
96
97    #[doc = "Create payment info for your org.\n\nThis includes billing address, phone, and \
98             name.\n\nThis endpoint requires authentication by the org admin. It creates the \
99             payment information for the authenticated user's org.\n\n```rust,no_run\nuse \
100             std::str::FromStr;\nasync fn example_payments_create_information_for_org() -> \
101             anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let \
102             result: kittycad::types::Customer = client\n        .payments()\n        \
103             .create_information_for_org(&kittycad::types::BillingInfo {\n            address: \
104             Some(kittycad::types::AddressDetails {\n                city: \
105             Some(\"some-string\".to_string()),\n                country: \
106             \"some-string\".to_string(),\n                state: \
107             Some(\"some-string\".to_string()),\n                street_1: \
108             Some(\"some-string\".to_string()),\n                street_2: \
109             Some(\"some-string\".to_string()),\n                zip: \
110             Some(\"some-string\".to_string()),\n            }),\n            name: \
111             Some(\"some-string\".to_string()),\n            phone: \
112             kittycad::types::phone_number::PhoneNumber::from_str(\"+1555-555-5555\")?,\n        \
113             })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
114    #[tracing::instrument]
115    pub async fn create_information_for_org<'a>(
116        &'a self,
117        body: &crate::types::BillingInfo,
118    ) -> Result<crate::types::Customer, crate::types::error::Error> {
119        let mut req = self.client.client.request(
120            http::Method::POST,
121            format!("{}/{}", self.client.base_url, "org/payment"),
122        );
123        req = req.bearer_auth(&self.client.token);
124        req = req.json(body);
125        let resp = req.send().await?;
126        let status = resp.status();
127        if status.is_success() {
128            let text = resp.text().await.unwrap_or_default();
129            serde_json::from_str(&text).map_err(|err| {
130                crate::types::error::Error::from_serde_error(
131                    format_serde_error::SerdeError::new(text.to_string(), err),
132                    status,
133                )
134            })
135        } else {
136            let text = resp.text().await.unwrap_or_default();
137            Err(crate::types::error::Error::Server {
138                body: text.to_string(),
139                status,
140            })
141        }
142    }
143
144    #[doc = "Delete payment info for your org.\n\nThis includes billing address, phone, and \
145             name.\n\nThis endpoint requires authentication by an org admin. It deletes the \
146             payment information for the authenticated user's org.\n\n```rust,no_run\nasync fn \
147             example_payments_delete_information_for_org() -> anyhow::Result<()> {\n    let client \
148             = kittycad::Client::new_from_env();\n    \
149             client.payments().delete_information_for_org().await?;\n    Ok(())\n}\n```"]
150    #[tracing::instrument]
151    pub async fn delete_information_for_org<'a>(
152        &'a self,
153    ) -> Result<(), crate::types::error::Error> {
154        let mut req = self.client.client.request(
155            http::Method::DELETE,
156            format!("{}/{}", self.client.base_url, "org/payment"),
157        );
158        req = req.bearer_auth(&self.client.token);
159        let resp = req.send().await?;
160        let status = resp.status();
161        if status.is_success() {
162            Ok(())
163        } else {
164            let text = resp.text().await.unwrap_or_default();
165            Err(crate::types::error::Error::Server {
166                body: text.to_string(),
167                status,
168            })
169        }
170    }
171
172    #[doc = "Get balance for your org.\n\nThis endpoint requires authentication by an org admin. \
173             It gets the balance information for the authenticated user's \
174             org.\n\n**Parameters:**\n\n- `include_total_due: Option<bool>`: If you would like to \
175             return the total due for a user. This makes the API call take longer so it is off by \
176             default.\n\n```rust,no_run\nasync fn example_payments_get_balance_for_org() -> \
177             anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let \
178             result: kittycad::types::CustomerBalance =\n        \
179             client.payments().get_balance_for_org(Some(true)).await?;\n    println!(\"{:?}\", \
180             result);\n    Ok(())\n}\n```"]
181    #[tracing::instrument]
182    pub async fn get_balance_for_org<'a>(
183        &'a self,
184        include_total_due: Option<bool>,
185    ) -> Result<crate::types::CustomerBalance, crate::types::error::Error> {
186        let mut req = self.client.client.request(
187            http::Method::GET,
188            format!("{}/{}", self.client.base_url, "org/payment/balance"),
189        );
190        req = req.bearer_auth(&self.client.token);
191        let mut query_params = vec![];
192        if let Some(p) = include_total_due {
193            query_params.push(("include_total_due", format!("{}", p)));
194        }
195
196        req = req.query(&query_params);
197        let resp = req.send().await?;
198        let status = resp.status();
199        if status.is_success() {
200            let text = resp.text().await.unwrap_or_default();
201            serde_json::from_str(&text).map_err(|err| {
202                crate::types::error::Error::from_serde_error(
203                    format_serde_error::SerdeError::new(text.to_string(), err),
204                    status,
205                )
206            })
207        } else {
208            let text = resp.text().await.unwrap_or_default();
209            Err(crate::types::error::Error::Server {
210                body: text.to_string(),
211                status,
212            })
213        }
214    }
215
216    #[doc = "Create a payment intent for your org.\n\nThis endpoint requires authentication by the org admin. It creates a new payment intent for the authenticated user's org's org.\n\n```rust,no_run\nasync fn example_payments_create_intent_for_org() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::PaymentIntent = client.payments().create_intent_for_org().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
217    #[tracing::instrument]
218    pub async fn create_intent_for_org<'a>(
219        &'a self,
220    ) -> Result<crate::types::PaymentIntent, crate::types::error::Error> {
221        let mut req = self.client.client.request(
222            http::Method::POST,
223            format!("{}/{}", self.client.base_url, "org/payment/intent"),
224        );
225        req = req.bearer_auth(&self.client.token);
226        let resp = req.send().await?;
227        let status = resp.status();
228        if status.is_success() {
229            let text = resp.text().await.unwrap_or_default();
230            serde_json::from_str(&text).map_err(|err| {
231                crate::types::error::Error::from_serde_error(
232                    format_serde_error::SerdeError::new(text.to_string(), err),
233                    status,
234                )
235            })
236        } else {
237            let text = resp.text().await.unwrap_or_default();
238            Err(crate::types::error::Error::Server {
239                body: text.to_string(),
240                status,
241            })
242        }
243    }
244
245    #[doc = "List invoices for your org.\n\nThis endpoint requires authentication by an org admin. It lists invoices for the authenticated user's org.\n\n```rust,no_run\nasync fn example_payments_list_invoices_for_org() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: Vec<kittycad::types::Invoice> = client.payments().list_invoices_for_org().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
246    #[tracing::instrument]
247    pub async fn list_invoices_for_org<'a>(
248        &'a self,
249    ) -> Result<Vec<crate::types::Invoice>, crate::types::error::Error> {
250        let mut req = self.client.client.request(
251            http::Method::GET,
252            format!("{}/{}", self.client.base_url, "org/payment/invoices"),
253        );
254        req = req.bearer_auth(&self.client.token);
255        let resp = req.send().await?;
256        let status = resp.status();
257        if status.is_success() {
258            let text = resp.text().await.unwrap_or_default();
259            serde_json::from_str(&text).map_err(|err| {
260                crate::types::error::Error::from_serde_error(
261                    format_serde_error::SerdeError::new(text.to_string(), err),
262                    status,
263                )
264            })
265        } else {
266            let text = resp.text().await.unwrap_or_default();
267            Err(crate::types::error::Error::Server {
268                body: text.to_string(),
269                status,
270            })
271        }
272    }
273
274    #[doc = "List payment methods for your org.\n\nThis endpoint requires authentication by an org admin. It lists payment methods for the authenticated user's org.\n\n```rust,no_run\nasync fn example_payments_list_methods_for_org() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: Vec<kittycad::types::PaymentMethod> = client.payments().list_methods_for_org().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
275    #[tracing::instrument]
276    pub async fn list_methods_for_org<'a>(
277        &'a self,
278    ) -> Result<Vec<crate::types::PaymentMethod>, crate::types::error::Error> {
279        let mut req = self.client.client.request(
280            http::Method::GET,
281            format!("{}/{}", self.client.base_url, "org/payment/methods"),
282        );
283        req = req.bearer_auth(&self.client.token);
284        let resp = req.send().await?;
285        let status = resp.status();
286        if status.is_success() {
287            let text = resp.text().await.unwrap_or_default();
288            serde_json::from_str(&text).map_err(|err| {
289                crate::types::error::Error::from_serde_error(
290                    format_serde_error::SerdeError::new(text.to_string(), err),
291                    status,
292                )
293            })
294        } else {
295            let text = resp.text().await.unwrap_or_default();
296            Err(crate::types::error::Error::Server {
297                body: text.to_string(),
298                status,
299            })
300        }
301    }
302
303    #[doc = "Delete a payment method for your org.\n\nThis endpoint requires authentication by an \
304             org admin. It deletes the specified payment method for the authenticated user's \
305             org.\n\n**Parameters:**\n\n- `id: &'astr`: The ID of the payment method. \
306             (required)\n\n```rust,no_run\nasync fn example_payments_delete_method_for_org() -> \
307             anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    \
308             client\n        .payments()\n        .delete_method_for_org(\"some-string\")\n        \
309             .await?;\n    Ok(())\n}\n```"]
310    #[tracing::instrument]
311    pub async fn delete_method_for_org<'a>(
312        &'a self,
313        id: &'a str,
314    ) -> Result<(), crate::types::error::Error> {
315        let mut req = self.client.client.request(
316            http::Method::DELETE,
317            format!(
318                "{}/{}",
319                self.client.base_url,
320                "org/payment/methods/{id}".replace("{id}", id)
321            ),
322        );
323        req = req.bearer_auth(&self.client.token);
324        let resp = req.send().await?;
325        let status = resp.status();
326        if status.is_success() {
327            Ok(())
328        } else {
329            let text = resp.text().await.unwrap_or_default();
330            Err(crate::types::error::Error::Server {
331                body: text.to_string(),
332                status,
333            })
334        }
335    }
336
337    #[doc = "Get the subscription for an org.\n\nThis endpoint requires authentication by an org admin. It gets the subscription for the authenticated user's org.\n\n```rust,no_run\nasync fn example_payments_get_org_subscription() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::ZooProductSubscriptions =\n        client.payments().get_org_subscription().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
338    #[tracing::instrument]
339    pub async fn get_org_subscription<'a>(
340        &'a self,
341    ) -> Result<crate::types::ZooProductSubscriptions, crate::types::error::Error> {
342        let mut req = self.client.client.request(
343            http::Method::GET,
344            format!("{}/{}", self.client.base_url, "org/payment/subscriptions"),
345        );
346        req = req.bearer_auth(&self.client.token);
347        let resp = req.send().await?;
348        let status = resp.status();
349        if status.is_success() {
350            let text = resp.text().await.unwrap_or_default();
351            serde_json::from_str(&text).map_err(|err| {
352                crate::types::error::Error::from_serde_error(
353                    format_serde_error::SerdeError::new(text.to_string(), err),
354                    status,
355                )
356            })
357        } else {
358            let text = resp.text().await.unwrap_or_default();
359            Err(crate::types::error::Error::Server {
360                body: text.to_string(),
361                status,
362            })
363        }
364    }
365
366    #[doc = "Update the subscription for an org.\n\nThis endpoint requires authentication by an org admin. It updates the subscription for the authenticated user's org.\n\n```rust,no_run\nasync fn example_payments_update_org_subscription() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::ZooProductSubscriptions = client\n        .payments()\n        .update_org_subscription(&kittycad::types::ZooProductSubscriptionsOrgRequest {\n            modeling_app: Some(kittycad::types::ModelingAppOrganizationSubscriptionTier::Enterprise),\n            pay_annually: Some(true),\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
367    #[tracing::instrument]
368    pub async fn update_org_subscription<'a>(
369        &'a self,
370        body: &crate::types::ZooProductSubscriptionsOrgRequest,
371    ) -> Result<crate::types::ZooProductSubscriptions, crate::types::error::Error> {
372        let mut req = self.client.client.request(
373            http::Method::PUT,
374            format!("{}/{}", self.client.base_url, "org/payment/subscriptions"),
375        );
376        req = req.bearer_auth(&self.client.token);
377        req = req.json(body);
378        let resp = req.send().await?;
379        let status = resp.status();
380        if status.is_success() {
381            let text = resp.text().await.unwrap_or_default();
382            serde_json::from_str(&text).map_err(|err| {
383                crate::types::error::Error::from_serde_error(
384                    format_serde_error::SerdeError::new(text.to_string(), err),
385                    status,
386                )
387            })
388        } else {
389            let text = resp.text().await.unwrap_or_default();
390            Err(crate::types::error::Error::Server {
391                body: text.to_string(),
392                status,
393            })
394        }
395    }
396
397    #[doc = "Create the subscription for an org.\n\nThis endpoint requires authentication by an org admin. It creates the subscription for the authenticated user's org.\n\n```rust,no_run\nasync fn example_payments_create_org_subscription() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::ZooProductSubscriptions = client\n        .payments()\n        .create_org_subscription(&kittycad::types::ZooProductSubscriptionsOrgRequest {\n            modeling_app: Some(kittycad::types::ModelingAppOrganizationSubscriptionTier::Enterprise),\n            pay_annually: Some(true),\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
398    #[tracing::instrument]
399    pub async fn create_org_subscription<'a>(
400        &'a self,
401        body: &crate::types::ZooProductSubscriptionsOrgRequest,
402    ) -> Result<crate::types::ZooProductSubscriptions, crate::types::error::Error> {
403        let mut req = self.client.client.request(
404            http::Method::POST,
405            format!("{}/{}", self.client.base_url, "org/payment/subscriptions"),
406        );
407        req = req.bearer_auth(&self.client.token);
408        req = req.json(body);
409        let resp = req.send().await?;
410        let status = resp.status();
411        if status.is_success() {
412            let text = resp.text().await.unwrap_or_default();
413            serde_json::from_str(&text).map_err(|err| {
414                crate::types::error::Error::from_serde_error(
415                    format_serde_error::SerdeError::new(text.to_string(), err),
416                    status,
417                )
418            })
419        } else {
420            let text = resp.text().await.unwrap_or_default();
421            Err(crate::types::error::Error::Server {
422                body: text.to_string(),
423                status,
424            })
425        }
426    }
427
428    #[doc = "Validate an orgs's information is correct and valid for automatic tax.\n\nThis endpoint requires authentication by an org admin. It will return an error if the org's information is not valid for automatic tax. Otherwise, it will return an empty successful response.\n\n```rust,no_run\nasync fn example_payments_validate_customer_tax_information_for_org() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    client\n        .payments()\n        .validate_customer_tax_information_for_org()\n        .await?;\n    Ok(())\n}\n```"]
429    #[tracing::instrument]
430    pub async fn validate_customer_tax_information_for_org<'a>(
431        &'a self,
432    ) -> Result<(), crate::types::error::Error> {
433        let mut req = self.client.client.request(
434            http::Method::GET,
435            format!("{}/{}", self.client.base_url, "org/payment/tax"),
436        );
437        req = req.bearer_auth(&self.client.token);
438        let resp = req.send().await?;
439        let status = resp.status();
440        if status.is_success() {
441            Ok(())
442        } else {
443            let text = resp.text().await.unwrap_or_default();
444            Err(crate::types::error::Error::Server {
445                body: text.to_string(),
446                status,
447            })
448        }
449    }
450
451    #[doc = "Get balance for an org.\n\nThis endpoint requires authentication by a Zoo employee. \
452             It gets the balance information for the specified org.\n\n**Parameters:**\n\n- `id: \
453             uuid::Uuid`: The organization ID. (required)\n- `include_total_due: Option<bool>`: If \
454             you would like to return the total due for a user. This makes the API call take \
455             longer so it is off by default.\n\n```rust,no_run\nuse std::str::FromStr;\nasync fn \
456             example_payments_get_balance_for_any_org() -> anyhow::Result<()> {\n    let client = \
457             kittycad::Client::new_from_env();\n    let result: kittycad::types::CustomerBalance = \
458             client\n        .payments()\n        .get_balance_for_any_org(\n            \
459             uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n            \
460             Some(true),\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    \
461             Ok(())\n}\n```"]
462    #[tracing::instrument]
463    pub async fn get_balance_for_any_org<'a>(
464        &'a self,
465        id: uuid::Uuid,
466        include_total_due: Option<bool>,
467    ) -> Result<crate::types::CustomerBalance, crate::types::error::Error> {
468        let mut req = self.client.client.request(
469            http::Method::GET,
470            format!(
471                "{}/{}",
472                self.client.base_url,
473                "orgs/{id}/payment/balance".replace("{id}", &format!("{}", id))
474            ),
475        );
476        req = req.bearer_auth(&self.client.token);
477        let mut query_params = vec![];
478        if let Some(p) = include_total_due {
479            query_params.push(("include_total_due", format!("{}", p)));
480        }
481
482        req = req.query(&query_params);
483        let resp = req.send().await?;
484        let status = resp.status();
485        if status.is_success() {
486            let text = resp.text().await.unwrap_or_default();
487            serde_json::from_str(&text).map_err(|err| {
488                crate::types::error::Error::from_serde_error(
489                    format_serde_error::SerdeError::new(text.to_string(), err),
490                    status,
491                )
492            })
493        } else {
494            let text = resp.text().await.unwrap_or_default();
495            Err(crate::types::error::Error::Server {
496                body: text.to_string(),
497                status,
498            })
499        }
500    }
501
502    #[doc = "Update balance for an org.\n\nThis endpoint requires authentication by a Zoo employee. It updates the balance information for the specified org.\n\n**Parameters:**\n\n- `id: uuid::Uuid`: The organization ID. (required)\n- `include_total_due: Option<bool>`: If you would like to return the total due for a user. This makes the API call take longer so it is off by default.\n\n```rust,no_run\nuse std::str::FromStr;\nasync fn example_payments_update_balance_for_any_org() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::CustomerBalance = client\n        .payments()\n        .update_balance_for_any_org(\n            uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n            Some(true),\n            &kittycad::types::UpdatePaymentBalance {\n                monthly_api_credits_remaining_monetary_value: Some(3.14 as f64),\n                stable_api_credits_remaining_monetary_value: Some(3.14 as f64),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
503    #[tracing::instrument]
504    pub async fn update_balance_for_any_org<'a>(
505        &'a self,
506        id: uuid::Uuid,
507        include_total_due: Option<bool>,
508        body: &crate::types::UpdatePaymentBalance,
509    ) -> Result<crate::types::CustomerBalance, crate::types::error::Error> {
510        let mut req = self.client.client.request(
511            http::Method::PUT,
512            format!(
513                "{}/{}",
514                self.client.base_url,
515                "orgs/{id}/payment/balance".replace("{id}", &format!("{}", id))
516            ),
517        );
518        req = req.bearer_auth(&self.client.token);
519        let mut query_params = vec![];
520        if let Some(p) = include_total_due {
521            query_params.push(("include_total_due", format!("{}", p)));
522        }
523
524        req = req.query(&query_params);
525        req = req.json(body);
526        let resp = req.send().await?;
527        let status = resp.status();
528        if status.is_success() {
529            let text = resp.text().await.unwrap_or_default();
530            serde_json::from_str(&text).map_err(|err| {
531                crate::types::error::Error::from_serde_error(
532                    format_serde_error::SerdeError::new(text.to_string(), err),
533                    status,
534                )
535            })
536        } else {
537            let text = resp.text().await.unwrap_or_default();
538            Err(crate::types::error::Error::Server {
539                body: text.to_string(),
540                status,
541            })
542        }
543    }
544
545    #[doc = "Get payment info about your user.\n\nThis includes billing address, phone, and \
546             name.\n\nThis endpoint requires authentication by any Zoo user. It gets the payment \
547             information for the authenticated user.\n\n```rust,no_run\nasync fn \
548             example_payments_get_information_for_user() -> anyhow::Result<()> {\n    let client = \
549             kittycad::Client::new_from_env();\n    let result: kittycad::types::Customer = \
550             client.payments().get_information_for_user().await?;\n    println!(\"{:?}\", \
551             result);\n    Ok(())\n}\n```"]
552    #[tracing::instrument]
553    pub async fn get_information_for_user<'a>(
554        &'a self,
555    ) -> Result<crate::types::Customer, crate::types::error::Error> {
556        let mut req = self.client.client.request(
557            http::Method::GET,
558            format!("{}/{}", self.client.base_url, "user/payment"),
559        );
560        req = req.bearer_auth(&self.client.token);
561        let resp = req.send().await?;
562        let status = resp.status();
563        if status.is_success() {
564            let text = resp.text().await.unwrap_or_default();
565            serde_json::from_str(&text).map_err(|err| {
566                crate::types::error::Error::from_serde_error(
567                    format_serde_error::SerdeError::new(text.to_string(), err),
568                    status,
569                )
570            })
571        } else {
572            let text = resp.text().await.unwrap_or_default();
573            Err(crate::types::error::Error::Server {
574                body: text.to_string(),
575                status,
576            })
577        }
578    }
579
580    #[doc = "Update payment info for your user.\n\nThis includes billing address, phone, and \
581             name.\n\nThis endpoint requires authentication by any Zoo user. It updates the \
582             payment information for the authenticated user.\n\n```rust,no_run\nuse \
583             std::str::FromStr;\nasync fn example_payments_update_information_for_user() -> \
584             anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let \
585             result: kittycad::types::Customer = client\n        .payments()\n        \
586             .update_information_for_user(&kittycad::types::BillingInfo {\n            address: \
587             Some(kittycad::types::AddressDetails {\n                city: \
588             Some(\"some-string\".to_string()),\n                country: \
589             \"some-string\".to_string(),\n                state: \
590             Some(\"some-string\".to_string()),\n                street_1: \
591             Some(\"some-string\".to_string()),\n                street_2: \
592             Some(\"some-string\".to_string()),\n                zip: \
593             Some(\"some-string\".to_string()),\n            }),\n            name: \
594             Some(\"some-string\".to_string()),\n            phone: \
595             kittycad::types::phone_number::PhoneNumber::from_str(\"+1555-555-5555\")?,\n        \
596             })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
597    #[tracing::instrument]
598    pub async fn update_information_for_user<'a>(
599        &'a self,
600        body: &crate::types::BillingInfo,
601    ) -> Result<crate::types::Customer, crate::types::error::Error> {
602        let mut req = self.client.client.request(
603            http::Method::PUT,
604            format!("{}/{}", self.client.base_url, "user/payment"),
605        );
606        req = req.bearer_auth(&self.client.token);
607        req = req.json(body);
608        let resp = req.send().await?;
609        let status = resp.status();
610        if status.is_success() {
611            let text = resp.text().await.unwrap_or_default();
612            serde_json::from_str(&text).map_err(|err| {
613                crate::types::error::Error::from_serde_error(
614                    format_serde_error::SerdeError::new(text.to_string(), err),
615                    status,
616                )
617            })
618        } else {
619            let text = resp.text().await.unwrap_or_default();
620            Err(crate::types::error::Error::Server {
621                body: text.to_string(),
622                status,
623            })
624        }
625    }
626
627    #[doc = "Create payment info for your user.\n\nThis includes billing address, phone, and \
628             name.\n\nThis endpoint requires authentication by any Zoo user. It creates the \
629             payment information for the authenticated user.\n\n```rust,no_run\nuse \
630             std::str::FromStr;\nasync fn example_payments_create_information_for_user() -> \
631             anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let \
632             result: kittycad::types::Customer = client\n        .payments()\n        \
633             .create_information_for_user(&kittycad::types::BillingInfo {\n            address: \
634             Some(kittycad::types::AddressDetails {\n                city: \
635             Some(\"some-string\".to_string()),\n                country: \
636             \"some-string\".to_string(),\n                state: \
637             Some(\"some-string\".to_string()),\n                street_1: \
638             Some(\"some-string\".to_string()),\n                street_2: \
639             Some(\"some-string\".to_string()),\n                zip: \
640             Some(\"some-string\".to_string()),\n            }),\n            name: \
641             Some(\"some-string\".to_string()),\n            phone: \
642             kittycad::types::phone_number::PhoneNumber::from_str(\"+1555-555-5555\")?,\n        \
643             })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
644    #[tracing::instrument]
645    pub async fn create_information_for_user<'a>(
646        &'a self,
647        body: &crate::types::BillingInfo,
648    ) -> Result<crate::types::Customer, crate::types::error::Error> {
649        let mut req = self.client.client.request(
650            http::Method::POST,
651            format!("{}/{}", self.client.base_url, "user/payment"),
652        );
653        req = req.bearer_auth(&self.client.token);
654        req = req.json(body);
655        let resp = req.send().await?;
656        let status = resp.status();
657        if status.is_success() {
658            let text = resp.text().await.unwrap_or_default();
659            serde_json::from_str(&text).map_err(|err| {
660                crate::types::error::Error::from_serde_error(
661                    format_serde_error::SerdeError::new(text.to_string(), err),
662                    status,
663                )
664            })
665        } else {
666            let text = resp.text().await.unwrap_or_default();
667            Err(crate::types::error::Error::Server {
668                body: text.to_string(),
669                status,
670            })
671        }
672    }
673
674    #[doc = "Delete payment info for your user.\n\nThis includes billing address, phone, and \
675             name.\n\nThis endpoint requires authentication by any Zoo user. It deletes the \
676             payment information for the authenticated user.\n\n```rust,no_run\nasync fn \
677             example_payments_delete_information_for_user() -> anyhow::Result<()> {\n    let \
678             client = kittycad::Client::new_from_env();\n    \
679             client.payments().delete_information_for_user().await?;\n    Ok(())\n}\n```"]
680    #[tracing::instrument]
681    pub async fn delete_information_for_user<'a>(
682        &'a self,
683    ) -> Result<(), crate::types::error::Error> {
684        let mut req = self.client.client.request(
685            http::Method::DELETE,
686            format!("{}/{}", self.client.base_url, "user/payment"),
687        );
688        req = req.bearer_auth(&self.client.token);
689        let resp = req.send().await?;
690        let status = resp.status();
691        if status.is_success() {
692            Ok(())
693        } else {
694            let text = resp.text().await.unwrap_or_default();
695            Err(crate::types::error::Error::Server {
696                body: text.to_string(),
697                status,
698            })
699        }
700    }
701
702    #[doc = "Get balance for your user.\n\nThis endpoint requires authentication by any Zoo user. \
703             It gets the balance information for the authenticated user.\n\n**Parameters:**\n\n- \
704             `include_total_due: Option<bool>`: If you would like to return the total due for a \
705             user. This makes the API call take longer so it is off by \
706             default.\n\n```rust,no_run\nasync fn example_payments_get_balance_for_user() -> \
707             anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let \
708             result: kittycad::types::CustomerBalance =\n        \
709             client.payments().get_balance_for_user(Some(true)).await?;\n    println!(\"{:?}\", \
710             result);\n    Ok(())\n}\n```"]
711    #[tracing::instrument]
712    pub async fn get_balance_for_user<'a>(
713        &'a self,
714        include_total_due: Option<bool>,
715    ) -> Result<crate::types::CustomerBalance, crate::types::error::Error> {
716        let mut req = self.client.client.request(
717            http::Method::GET,
718            format!("{}/{}", self.client.base_url, "user/payment/balance"),
719        );
720        req = req.bearer_auth(&self.client.token);
721        let mut query_params = vec![];
722        if let Some(p) = include_total_due {
723            query_params.push(("include_total_due", format!("{}", p)));
724        }
725
726        req = req.query(&query_params);
727        let resp = req.send().await?;
728        let status = resp.status();
729        if status.is_success() {
730            let text = resp.text().await.unwrap_or_default();
731            serde_json::from_str(&text).map_err(|err| {
732                crate::types::error::Error::from_serde_error(
733                    format_serde_error::SerdeError::new(text.to_string(), err),
734                    status,
735                )
736            })
737        } else {
738            let text = resp.text().await.unwrap_or_default();
739            Err(crate::types::error::Error::Server {
740                body: text.to_string(),
741                status,
742            })
743        }
744    }
745
746    #[doc = "Create a payment intent for your user.\n\nThis endpoint requires authentication by any Zoo user. It creates a new payment intent for the authenticated user.\n\n```rust,no_run\nasync fn example_payments_create_intent_for_user() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::PaymentIntent = client.payments().create_intent_for_user().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
747    #[tracing::instrument]
748    pub async fn create_intent_for_user<'a>(
749        &'a self,
750    ) -> Result<crate::types::PaymentIntent, crate::types::error::Error> {
751        let mut req = self.client.client.request(
752            http::Method::POST,
753            format!("{}/{}", self.client.base_url, "user/payment/intent"),
754        );
755        req = req.bearer_auth(&self.client.token);
756        let resp = req.send().await?;
757        let status = resp.status();
758        if status.is_success() {
759            let text = resp.text().await.unwrap_or_default();
760            serde_json::from_str(&text).map_err(|err| {
761                crate::types::error::Error::from_serde_error(
762                    format_serde_error::SerdeError::new(text.to_string(), err),
763                    status,
764                )
765            })
766        } else {
767            let text = resp.text().await.unwrap_or_default();
768            Err(crate::types::error::Error::Server {
769                body: text.to_string(),
770                status,
771            })
772        }
773    }
774
775    #[doc = "List invoices for your user.\n\nThis endpoint requires authentication by any Zoo user. It lists invoices for the authenticated user.\n\n```rust,no_run\nasync fn example_payments_list_invoices_for_user() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: Vec<kittycad::types::Invoice> = client.payments().list_invoices_for_user().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
776    #[tracing::instrument]
777    pub async fn list_invoices_for_user<'a>(
778        &'a self,
779    ) -> Result<Vec<crate::types::Invoice>, crate::types::error::Error> {
780        let mut req = self.client.client.request(
781            http::Method::GET,
782            format!("{}/{}", self.client.base_url, "user/payment/invoices"),
783        );
784        req = req.bearer_auth(&self.client.token);
785        let resp = req.send().await?;
786        let status = resp.status();
787        if status.is_success() {
788            let text = resp.text().await.unwrap_or_default();
789            serde_json::from_str(&text).map_err(|err| {
790                crate::types::error::Error::from_serde_error(
791                    format_serde_error::SerdeError::new(text.to_string(), err),
792                    status,
793                )
794            })
795        } else {
796            let text = resp.text().await.unwrap_or_default();
797            Err(crate::types::error::Error::Server {
798                body: text.to_string(),
799                status,
800            })
801        }
802    }
803
804    #[doc = "List payment methods for your user.\n\nThis endpoint requires authentication by any Zoo user. It lists payment methods for the authenticated user.\n\n```rust,no_run\nasync fn example_payments_list_methods_for_user() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: Vec<kittycad::types::PaymentMethod> =\n        client.payments().list_methods_for_user().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
805    #[tracing::instrument]
806    pub async fn list_methods_for_user<'a>(
807        &'a self,
808    ) -> Result<Vec<crate::types::PaymentMethod>, crate::types::error::Error> {
809        let mut req = self.client.client.request(
810            http::Method::GET,
811            format!("{}/{}", self.client.base_url, "user/payment/methods"),
812        );
813        req = req.bearer_auth(&self.client.token);
814        let resp = req.send().await?;
815        let status = resp.status();
816        if status.is_success() {
817            let text = resp.text().await.unwrap_or_default();
818            serde_json::from_str(&text).map_err(|err| {
819                crate::types::error::Error::from_serde_error(
820                    format_serde_error::SerdeError::new(text.to_string(), err),
821                    status,
822                )
823            })
824        } else {
825            let text = resp.text().await.unwrap_or_default();
826            Err(crate::types::error::Error::Server {
827                body: text.to_string(),
828                status,
829            })
830        }
831    }
832
833    #[doc = "Delete a payment method for your user.\n\nThis endpoint requires authentication by any Zoo user. It deletes the specified payment method for the authenticated user.\n\n**Parameters:**\n\n- `id: &'astr`: The ID of the payment method. (required)\n\n```rust,no_run\nasync fn example_payments_delete_method_for_user() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    client\n        .payments()\n        .delete_method_for_user(\"some-string\")\n        .await?;\n    Ok(())\n}\n```"]
834    #[tracing::instrument]
835    pub async fn delete_method_for_user<'a>(
836        &'a self,
837        id: &'a str,
838    ) -> Result<(), crate::types::error::Error> {
839        let mut req = self.client.client.request(
840            http::Method::DELETE,
841            format!(
842                "{}/{}",
843                self.client.base_url,
844                "user/payment/methods/{id}".replace("{id}", id)
845            ),
846        );
847        req = req.bearer_auth(&self.client.token);
848        let resp = req.send().await?;
849        let status = resp.status();
850        if status.is_success() {
851            Ok(())
852        } else {
853            let text = resp.text().await.unwrap_or_default();
854            Err(crate::types::error::Error::Server {
855                body: text.to_string(),
856                status,
857            })
858        }
859    }
860
861    #[doc = "Get the subscription for a user.\n\nThis endpoint requires authentication by any Zoo user. It gets the subscription for the user.\n\n```rust,no_run\nasync fn example_payments_get_user_subscription() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::ZooProductSubscriptions =\n        client.payments().get_user_subscription().await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
862    #[tracing::instrument]
863    pub async fn get_user_subscription<'a>(
864        &'a self,
865    ) -> Result<crate::types::ZooProductSubscriptions, crate::types::error::Error> {
866        let mut req = self.client.client.request(
867            http::Method::GET,
868            format!("{}/{}", self.client.base_url, "user/payment/subscriptions"),
869        );
870        req = req.bearer_auth(&self.client.token);
871        let resp = req.send().await?;
872        let status = resp.status();
873        if status.is_success() {
874            let text = resp.text().await.unwrap_or_default();
875            serde_json::from_str(&text).map_err(|err| {
876                crate::types::error::Error::from_serde_error(
877                    format_serde_error::SerdeError::new(text.to_string(), err),
878                    status,
879                )
880            })
881        } else {
882            let text = resp.text().await.unwrap_or_default();
883            Err(crate::types::error::Error::Server {
884                body: text.to_string(),
885                status,
886            })
887        }
888    }
889
890    #[doc = "Update the user's subscription.\n\nThis endpoint requires authentication by any Zoo user. It updates the subscription for the user.\n\n```rust,no_run\nasync fn example_payments_update_user_subscription() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::ZooProductSubscriptions = client\n        .payments()\n        .update_user_subscription(&kittycad::types::ZooProductSubscriptionsUserRequest {\n            modeling_app: Some(kittycad::types::ModelingAppIndividualSubscriptionTier::Plus),\n            pay_annually: Some(true),\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
891    #[tracing::instrument]
892    pub async fn update_user_subscription<'a>(
893        &'a self,
894        body: &crate::types::ZooProductSubscriptionsUserRequest,
895    ) -> Result<crate::types::ZooProductSubscriptions, crate::types::error::Error> {
896        let mut req = self.client.client.request(
897            http::Method::PUT,
898            format!("{}/{}", self.client.base_url, "user/payment/subscriptions"),
899        );
900        req = req.bearer_auth(&self.client.token);
901        req = req.json(body);
902        let resp = req.send().await?;
903        let status = resp.status();
904        if status.is_success() {
905            let text = resp.text().await.unwrap_or_default();
906            serde_json::from_str(&text).map_err(|err| {
907                crate::types::error::Error::from_serde_error(
908                    format_serde_error::SerdeError::new(text.to_string(), err),
909                    status,
910                )
911            })
912        } else {
913            let text = resp.text().await.unwrap_or_default();
914            Err(crate::types::error::Error::Server {
915                body: text.to_string(),
916                status,
917            })
918        }
919    }
920
921    #[doc = "Create the subscription for a user.\n\nThis endpoint requires authentication by any Zoo user. It creates the subscription for the user.\n\n```rust,no_run\nasync fn example_payments_create_user_subscription() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::ZooProductSubscriptions = client\n        .payments()\n        .create_user_subscription(&kittycad::types::ZooProductSubscriptionsUserRequest {\n            modeling_app: Some(kittycad::types::ModelingAppIndividualSubscriptionTier::Plus),\n            pay_annually: Some(true),\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
922    #[tracing::instrument]
923    pub async fn create_user_subscription<'a>(
924        &'a self,
925        body: &crate::types::ZooProductSubscriptionsUserRequest,
926    ) -> Result<crate::types::ZooProductSubscriptions, crate::types::error::Error> {
927        let mut req = self.client.client.request(
928            http::Method::POST,
929            format!("{}/{}", self.client.base_url, "user/payment/subscriptions"),
930        );
931        req = req.bearer_auth(&self.client.token);
932        req = req.json(body);
933        let resp = req.send().await?;
934        let status = resp.status();
935        if status.is_success() {
936            let text = resp.text().await.unwrap_or_default();
937            serde_json::from_str(&text).map_err(|err| {
938                crate::types::error::Error::from_serde_error(
939                    format_serde_error::SerdeError::new(text.to_string(), err),
940                    status,
941                )
942            })
943        } else {
944            let text = resp.text().await.unwrap_or_default();
945            Err(crate::types::error::Error::Server {
946                body: text.to_string(),
947                status,
948            })
949        }
950    }
951
952    #[doc = "Validate a user's information is correct and valid for automatic tax.\n\nThis \
953             endpoint requires authentication by any Zoo user. It will return an error if the \
954             user's information is not valid for automatic tax. Otherwise, it will return an empty \
955             successful response.\n\n```rust,no_run\nasync fn \
956             example_payments_validate_customer_tax_information_for_user() -> anyhow::Result<()> \
957             {\n    let client = kittycad::Client::new_from_env();\n    client\n        \
958             .payments()\n        .validate_customer_tax_information_for_user()\n        \
959             .await?;\n    Ok(())\n}\n```"]
960    #[tracing::instrument]
961    pub async fn validate_customer_tax_information_for_user<'a>(
962        &'a self,
963    ) -> Result<(), crate::types::error::Error> {
964        let mut req = self.client.client.request(
965            http::Method::GET,
966            format!("{}/{}", self.client.base_url, "user/payment/tax"),
967        );
968        req = req.bearer_auth(&self.client.token);
969        let resp = req.send().await?;
970        let status = resp.status();
971        if status.is_success() {
972            Ok(())
973        } else {
974            let text = resp.text().await.unwrap_or_default();
975            Err(crate::types::error::Error::Server {
976                body: text.to_string(),
977                status,
978            })
979        }
980    }
981
982    #[doc = "Get balance for an user.\n\nThis endpoint requires authentication by a Zoo employee. \
983             It gets the balance information for the specified user.\n\n**Parameters:**\n\n- `id: \
984             &'astr`: The user's identifier (uuid or email). (required)\n- `include_total_due: \
985             Option<bool>`: If you would like to return the total due for a user. This makes the \
986             API call take longer so it is off by default.\n\n```rust,no_run\nasync fn \
987             example_payments_get_balance_for_any_user() -> anyhow::Result<()> {\n    let client = \
988             kittycad::Client::new_from_env();\n    let result: kittycad::types::CustomerBalance = \
989             client\n        .payments()\n        .get_balance_for_any_user(\"some-string\", \
990             Some(true))\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
991    #[tracing::instrument]
992    pub async fn get_balance_for_any_user<'a>(
993        &'a self,
994        id: &'a str,
995        include_total_due: Option<bool>,
996    ) -> Result<crate::types::CustomerBalance, crate::types::error::Error> {
997        let mut req = self.client.client.request(
998            http::Method::GET,
999            format!(
1000                "{}/{}",
1001                self.client.base_url,
1002                "users/{id}/payment/balance".replace("{id}", id)
1003            ),
1004        );
1005        req = req.bearer_auth(&self.client.token);
1006        let mut query_params = vec![];
1007        if let Some(p) = include_total_due {
1008            query_params.push(("include_total_due", format!("{}", p)));
1009        }
1010
1011        req = req.query(&query_params);
1012        let resp = req.send().await?;
1013        let status = resp.status();
1014        if status.is_success() {
1015            let text = resp.text().await.unwrap_or_default();
1016            serde_json::from_str(&text).map_err(|err| {
1017                crate::types::error::Error::from_serde_error(
1018                    format_serde_error::SerdeError::new(text.to_string(), err),
1019                    status,
1020                )
1021            })
1022        } else {
1023            let text = resp.text().await.unwrap_or_default();
1024            Err(crate::types::error::Error::Server {
1025                body: text.to_string(),
1026                status,
1027            })
1028        }
1029    }
1030
1031    #[doc = "Update balance for an user.\n\nThis endpoint requires authentication by a Zoo employee. It updates the balance information for the specified user.\n\n**Parameters:**\n\n- `id: &'astr`: The user's identifier (uuid or email). (required)\n- `include_total_due: Option<bool>`: If you would like to return the total due for a user. This makes the API call take longer so it is off by default.\n\n```rust,no_run\nasync fn example_payments_update_balance_for_any_user() -> anyhow::Result<()> {\n    let client = kittycad::Client::new_from_env();\n    let result: kittycad::types::CustomerBalance = client\n        .payments()\n        .update_balance_for_any_user(\n            \"some-string\",\n            Some(true),\n            &kittycad::types::UpdatePaymentBalance {\n                monthly_api_credits_remaining_monetary_value: Some(3.14 as f64),\n                stable_api_credits_remaining_monetary_value: Some(3.14 as f64),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
1032    #[tracing::instrument]
1033    pub async fn update_balance_for_any_user<'a>(
1034        &'a self,
1035        id: &'a str,
1036        include_total_due: Option<bool>,
1037        body: &crate::types::UpdatePaymentBalance,
1038    ) -> Result<crate::types::CustomerBalance, crate::types::error::Error> {
1039        let mut req = self.client.client.request(
1040            http::Method::PUT,
1041            format!(
1042                "{}/{}",
1043                self.client.base_url,
1044                "users/{id}/payment/balance".replace("{id}", id)
1045            ),
1046        );
1047        req = req.bearer_auth(&self.client.token);
1048        let mut query_params = vec![];
1049        if let Some(p) = include_total_due {
1050            query_params.push(("include_total_due", format!("{}", p)));
1051        }
1052
1053        req = req.query(&query_params);
1054        req = req.json(body);
1055        let resp = req.send().await?;
1056        let status = resp.status();
1057        if status.is_success() {
1058            let text = resp.text().await.unwrap_or_default();
1059            serde_json::from_str(&text).map_err(|err| {
1060                crate::types::error::Error::from_serde_error(
1061                    format_serde_error::SerdeError::new(text.to_string(), err),
1062                    status,
1063                )
1064            })
1065        } else {
1066            let text = resp.text().await.unwrap_or_default();
1067            Err(crate::types::error::Error::Server {
1068                body: text.to_string(),
1069                status,
1070            })
1071        }
1072    }
1073}