rippling_api/
custom_object_records.rs

1use anyhow::Result;
2
3use crate::Client;
4#[derive(Clone, Debug)]
5pub struct CustomObjectRecords {
6    pub client: Client,
7}
8
9impl CustomObjectRecords {
10    #[doc(hidden)]
11    pub fn new(client: Client) -> Self {
12        Self { client }
13    }
14
15    #[doc = "List custom object records\n\nA List of custom object records\n- Requires: `API Tier 1`\n\n**Parameters:**\n\n- `cursor: Option<String>`\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_custom_object_records_list_custom_objects_custom_object_api_name_records_stream(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let mut custom_object_records = client.custom_object_records();\n    let mut stream = custom_object_records\n        .list_custom_objects_custom_object_api_name_records_stream(\"some-string\");\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
16    #[tracing::instrument]
17    pub async fn list_custom_objects_custom_object_api_name_records<'a>(
18        &'a self,
19        cursor: Option<String>,
20        custom_object_api_name: &'a str,
21    ) -> Result<
22        crate::types::ListCustomObjectsCustomObjectApiNameRecordsResponse,
23        crate::types::error::Error,
24    > {
25        let mut req = self.client.client.request(
26            http::Method::GET,
27            format!(
28                "{}/{}",
29                self.client.base_url,
30                "custom-objects/{custom_object_api_name}/records"
31                    .replace("{custom_object_api_name}", custom_object_api_name)
32            ),
33        );
34        req = req.bearer_auth(&self.client.token);
35        let mut query_params = vec![];
36        if let Some(p) = cursor {
37            query_params.push(("cursor", p));
38        }
39
40        req = req.query(&query_params);
41        let resp = req.send().await?;
42        let status = resp.status();
43        if status.is_success() {
44            let text = resp.text().await.unwrap_or_default();
45            serde_json::from_str(&text).map_err(|err| {
46                crate::types::error::Error::from_serde_error(
47                    format_serde_error::SerdeError::new(text.to_string(), err),
48                    status,
49                )
50            })
51        } else {
52            let text = resp.text().await.unwrap_or_default();
53            Err(crate::types::error::Error::Server {
54                body: text.to_string(),
55                status,
56            })
57        }
58    }
59
60    #[doc = "List custom object records\n\nA List of custom object records\n- Requires: `API Tier 1`\n\n**Parameters:**\n\n- `cursor: Option<String>`\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nuse futures_util::TryStreamExt;\nasync fn example_custom_object_records_list_custom_objects_custom_object_api_name_records_stream(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let mut custom_object_records = client.custom_object_records();\n    let mut stream = custom_object_records\n        .list_custom_objects_custom_object_api_name_records_stream(\"some-string\");\n    loop {\n        match stream.try_next().await {\n            Ok(Some(item)) => {\n                println!(\"{:?}\", item);\n            }\n            Ok(None) => {\n                break;\n            }\n            Err(err) => {\n                return Err(err.into());\n            }\n        }\n    }\n\n    Ok(())\n}\n```"]
61    #[tracing::instrument]
62    #[cfg(not(feature = "js"))]
63    pub fn list_custom_objects_custom_object_api_name_records_stream<'a>(
64        &'a self,
65        custom_object_api_name: &'a str,
66    ) -> impl futures::Stream<Item = Result<crate::types::Results, crate::types::error::Error>>
67           + Unpin
68           + '_ {
69        use futures::{StreamExt, TryFutureExt, TryStreamExt};
70
71        use crate::types::paginate::Pagination;
72        self . list_custom_objects_custom_object_api_name_records (None , custom_object_api_name) . map_ok (move | result | { let items = futures :: stream :: iter (result . items () . into_iter () . map (Ok)) ; let next_pages = futures :: stream :: try_unfold ((None , result) , move | (prev_page_token , new_result) | async move { if new_result . has_more_pages () && ! new_result . items () . is_empty () && prev_page_token != new_result . next_page_token () { async { let mut req = self . client . client . request (http :: Method :: GET , format ! ("{}/{}" , self . client . base_url , "custom-objects/{custom_object_api_name}/records" . replace ("{custom_object_api_name}" , custom_object_api_name)) ,) ; req = req . bearer_auth (& self . client . token) ; let mut request = req . build () ? ; request = new_result . next_page (request) ? ; let resp = self . client . client . execute (request) . await ? ; let status = resp . status () ; if status . is_success () { let text = resp . text () . await . unwrap_or_default () ; serde_json :: from_str (& text) . map_err (| err | crate :: types :: error :: Error :: from_serde_error (format_serde_error :: SerdeError :: new (text . to_string () , err) , status)) } else { let text = resp . text () . await . unwrap_or_default () ; Err (crate :: types :: error :: Error :: Server { body : text . to_string () , status }) } } . map_ok (| result : crate :: types :: ListCustomObjectsCustomObjectApiNameRecordsResponse | { Some ((futures :: stream :: iter (result . items () . into_iter () . map (Ok) ,) , (new_result . next_page_token () , result) ,)) }) . await } else { Ok (None) } }) . try_flatten () ; items . chain (next_pages) }) . try_flatten_stream () . boxed ()
73    }
74
75    #[doc = "Create a new custom object record\n\nCreate a new custom object record\n\n**Parameters:**\n\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_create_custom_objects_custom_object_api_name_records(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let result: rippling_api::types::CreateCustomObjectsCustomObjectApiNameRecordsResponse = client\n        .custom_object_records()\n        .create_custom_objects_custom_object_api_name_records(\n            \"some-string\",\n            &rippling_api::types::CreateCustomObjectsCustomObjectApiNameRecordsRequestBody {\n                name: Some(\"some-string\".to_string()),\n                field_api_name: Some(\"some-string\".to_string()),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
76    #[tracing::instrument]
77    pub async fn create_custom_objects_custom_object_api_name_records<'a>(
78        &'a self,
79        custom_object_api_name: &'a str,
80        body: &crate::types::CreateCustomObjectsCustomObjectApiNameRecordsRequestBody,
81    ) -> Result<
82        crate::types::CreateCustomObjectsCustomObjectApiNameRecordsResponse,
83        crate::types::error::Error,
84    > {
85        let mut req = self.client.client.request(
86            http::Method::POST,
87            format!(
88                "{}/{}",
89                self.client.base_url,
90                "custom-objects/{custom_object_api_name}/records"
91                    .replace("{custom_object_api_name}", custom_object_api_name)
92            ),
93        );
94        req = req.bearer_auth(&self.client.token);
95        req = req.json(body);
96        let resp = req.send().await?;
97        let status = resp.status();
98        if status.is_success() {
99            let text = resp.text().await.unwrap_or_default();
100            serde_json::from_str(&text).map_err(|err| {
101                crate::types::error::Error::from_serde_error(
102                    format_serde_error::SerdeError::new(text.to_string(), err),
103                    status,
104                )
105            })
106        } else {
107            let text = resp.text().await.unwrap_or_default();
108            Err(crate::types::error::Error::Server {
109                body: text.to_string(),
110                status,
111            })
112        }
113    }
114
115    #[doc = "List custom object records by query\n\nA List of custom object records filtered by querying\n\n**Parameters:**\n\n- `cursor: Option<String>`\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_list_by_query_custom_objects_custom_object_api_name_records(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let result: rippling_api::types::ListByQueryCustomObjectsCustomObjectApiNameRecordsResponse = client\n        .custom_object_records()\n        .list_by_query_custom_objects_custom_object_api_name_records(\n            Some(\"some-string\".to_string()),\n            \"some-string\",\n            &rippling_api::types::ListByQueryCustomObjectsCustomObjectApiNameRecordsRequestBody {\n                query: Some(\"some-string\".to_string()),\n                limit: Some(4 as i64),\n                cursor: Some(\"some-string\".to_string()),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
116    #[tracing::instrument]
117    pub async fn list_by_query_custom_objects_custom_object_api_name_records<'a>(
118        &'a self,
119        cursor: Option<String>,
120        custom_object_api_name: &'a str,
121        body: &crate::types::ListByQueryCustomObjectsCustomObjectApiNameRecordsRequestBody,
122    ) -> Result<
123        crate::types::ListByQueryCustomObjectsCustomObjectApiNameRecordsResponse,
124        crate::types::error::Error,
125    > {
126        let mut req = self.client.client.request(
127            http::Method::POST,
128            format!(
129                "{}/{}",
130                self.client.base_url,
131                "custom-objects/{custom_object_api_name}/records/query"
132                    .replace("{custom_object_api_name}", custom_object_api_name)
133            ),
134        );
135        req = req.bearer_auth(&self.client.token);
136        let mut query_params = vec![];
137        if let Some(p) = cursor {
138            query_params.push(("cursor", p));
139        }
140
141        req = req.query(&query_params);
142        req = req.json(body);
143        let resp = req.send().await?;
144        let status = resp.status();
145        if status.is_success() {
146            let text = resp.text().await.unwrap_or_default();
147            serde_json::from_str(&text).map_err(|err| {
148                crate::types::error::Error::from_serde_error(
149                    format_serde_error::SerdeError::new(text.to_string(), err),
150                    status,
151                )
152            })
153        } else {
154            let text = resp.text().await.unwrap_or_default();
155            Err(crate::types::error::Error::Server {
156                body: text.to_string(),
157                status,
158            })
159        }
160    }
161
162    #[doc = "Retrieve a specific custom object record\n\nRetrieve a specific custom object \
163             record\n\n**Parameters:**\n\n- `codr_id: &'astr` (required)\n- \
164             `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn \
165             example_custom_object_records_get_custom_objects_custom_object_api_name_records(\n) \
166             -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    \
167             let result: rippling_api::types::GetCustomObjectsCustomObjectApiNameRecordsResponse = \
168             client\n        .custom_object_records()\n        \
169             .get_custom_objects_custom_object_api_name_records(\"some-string\", \
170             \"some-string\")\n        .await?;\n    println!(\"{:?}\", result);\n    \
171             Ok(())\n}\n```"]
172    #[tracing::instrument]
173    pub async fn get_custom_objects_custom_object_api_name_records<'a>(
174        &'a self,
175        codr_id: &'a str,
176        custom_object_api_name: &'a str,
177    ) -> Result<
178        crate::types::GetCustomObjectsCustomObjectApiNameRecordsResponse,
179        crate::types::error::Error,
180    > {
181        let mut req = self.client.client.request(
182            http::Method::GET,
183            format!(
184                "{}/{}",
185                self.client.base_url,
186                "custom-objects/{custom_object_api_name}/records/{codr_id}"
187                    .replace("{codr_id}", codr_id)
188                    .replace("{custom_object_api_name}", custom_object_api_name)
189            ),
190        );
191        req = req.bearer_auth(&self.client.token);
192        let resp = req.send().await?;
193        let status = resp.status();
194        if status.is_success() {
195            let text = resp.text().await.unwrap_or_default();
196            serde_json::from_str(&text).map_err(|err| {
197                crate::types::error::Error::from_serde_error(
198                    format_serde_error::SerdeError::new(text.to_string(), err),
199                    status,
200                )
201            })
202        } else {
203            let text = resp.text().await.unwrap_or_default();
204            Err(crate::types::error::Error::Server {
205                body: text.to_string(),
206                status,
207            })
208        }
209    }
210
211    #[doc = "Delete a custom object record\n\n**Parameters:**\n\n- `codr_id: &'astr` (required)\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_delete_custom_objects_custom_object_api_name_records(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    client\n        .custom_object_records()\n        .delete_custom_objects_custom_object_api_name_records(\"some-string\", \"some-string\")\n        .await?;\n    Ok(())\n}\n```"]
212    #[tracing::instrument]
213    pub async fn delete_custom_objects_custom_object_api_name_records<'a>(
214        &'a self,
215        codr_id: &'a str,
216        custom_object_api_name: &'a str,
217    ) -> Result<(), crate::types::error::Error> {
218        let mut req = self.client.client.request(
219            http::Method::DELETE,
220            format!(
221                "{}/{}",
222                self.client.base_url,
223                "custom-objects/{custom_object_api_name}/records/{codr_id}"
224                    .replace("{codr_id}", codr_id)
225                    .replace("{custom_object_api_name}", custom_object_api_name)
226            ),
227        );
228        req = req.bearer_auth(&self.client.token);
229        let resp = req.send().await?;
230        let status = resp.status();
231        if status.is_success() {
232            Ok(())
233        } else {
234            let text = resp.text().await.unwrap_or_default();
235            Err(crate::types::error::Error::Server {
236                body: text.to_string(),
237                status,
238            })
239        }
240    }
241
242    #[doc = "Update a custom object record\n\nUpdated a specific custom object record\n\n**Parameters:**\n\n- `codr_id: &'astr` (required)\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_update_custom_objects_custom_object_api_name_records(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let result: rippling_api::types::UpdateCustomObjectsCustomObjectApiNameRecordsResponse = client\n        .custom_object_records()\n        .update_custom_objects_custom_object_api_name_records(\n            \"some-string\",\n            \"some-string\",\n            &rippling_api::types::UpdateCustomObjectsCustomObjectApiNameRecordsRequestBody {\n                name: Some(\"some-string\".to_string()),\n                field_api_name: Some(\"some-string\".to_string()),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
243    #[tracing::instrument]
244    pub async fn update_custom_objects_custom_object_api_name_records<'a>(
245        &'a self,
246        codr_id: &'a str,
247        custom_object_api_name: &'a str,
248        body: &crate::types::UpdateCustomObjectsCustomObjectApiNameRecordsRequestBody,
249    ) -> Result<
250        crate::types::UpdateCustomObjectsCustomObjectApiNameRecordsResponse,
251        crate::types::error::Error,
252    > {
253        let mut req = self.client.client.request(
254            http::Method::PATCH,
255            format!(
256                "{}/{}",
257                self.client.base_url,
258                "custom-objects/{custom_object_api_name}/records/{codr_id}"
259                    .replace("{codr_id}", codr_id)
260                    .replace("{custom_object_api_name}", custom_object_api_name)
261            ),
262        );
263        req = req.bearer_auth(&self.client.token);
264        req = req.json(body);
265        let resp = req.send().await?;
266        let status = resp.status();
267        if status.is_success() {
268            let text = resp.text().await.unwrap_or_default();
269            serde_json::from_str(&text).map_err(|err| {
270                crate::types::error::Error::from_serde_error(
271                    format_serde_error::SerdeError::new(text.to_string(), err),
272                    status,
273                )
274            })
275        } else {
276            let text = resp.text().await.unwrap_or_default();
277            Err(crate::types::error::Error::Server {
278                body: text.to_string(),
279                status,
280            })
281        }
282    }
283
284    #[doc = "Retrieve a specific custom object record by its external_id\n\nRetrieve a specific custom object record by its external_id\n\n**Parameters:**\n\n- `custom_object_api_name: &'astr` (required)\n- `external_id: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_get_custom_objects_custom_object_api_name_records_by_external_id(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let result: rippling_api::types::GetCustomObjectsCustomObjectApiNameRecordsByExternalIdResponse =\n        client\n            .custom_object_records()\n            .get_custom_objects_custom_object_api_name_records_by_external_id(\n                \"some-string\",\n                \"some-string\",\n            )\n            .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
285    #[tracing::instrument]
286    pub async fn get_custom_objects_custom_object_api_name_records_by_external_id<'a>(
287        &'a self,
288        custom_object_api_name: &'a str,
289        external_id: &'a str,
290    ) -> Result<
291        crate::types::GetCustomObjectsCustomObjectApiNameRecordsByExternalIdResponse,
292        crate::types::error::Error,
293    > {
294        let mut req = self.client.client.request(
295            http::Method::GET,
296            format!(
297                "{}/{}",
298                self.client.base_url,
299                "custom-objects/{custom_object_api_name}/records/external_id/{external_id}"
300                    .replace("{custom_object_api_name}", custom_object_api_name)
301                    .replace("{external_id}", external_id)
302            ),
303        );
304        req = req.bearer_auth(&self.client.token);
305        let resp = req.send().await?;
306        let status = resp.status();
307        if status.is_success() {
308            let text = resp.text().await.unwrap_or_default();
309            serde_json::from_str(&text).map_err(|err| {
310                crate::types::error::Error::from_serde_error(
311                    format_serde_error::SerdeError::new(text.to_string(), err),
312                    status,
313                )
314            })
315        } else {
316            let text = resp.text().await.unwrap_or_default();
317            Err(crate::types::error::Error::Server {
318                body: text.to_string(),
319                status,
320            })
321        }
322    }
323
324    #[doc = "Bulk Create custom object records\n\nbulk create new custom object records\n\n**Parameters:**\n\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_bulk_create_custom_objects_custom_object_api_name_records(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let result: Vec<rippling_api::types::BulkCreateCustomObjectsCustomObjectApiNameRecordsResponse> =\n        client\n            .custom_object_records()\n            .bulk_create_custom_objects_custom_object_api_name_records(\n                \"some-string\",\n                &rippling_api::types::BulkCreateCustomObjectsCustomObjectApiNameRecordsRequestBody {\n                    rows_to_write: Some(vec![rippling_api::types::RowsToWrite {\n                        name: Some(\"some-string\".to_string()),\n                        field_api_name: Some(\"some-string\".to_string()),\n                    }]),\n                    all_or_nothing: Some(true),\n                },\n            )\n            .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
325    #[tracing::instrument]
326    pub async fn bulk_create_custom_objects_custom_object_api_name_records<'a>(
327        &'a self,
328        custom_object_api_name: &'a str,
329        body: &crate::types::BulkCreateCustomObjectsCustomObjectApiNameRecordsRequestBody,
330    ) -> Result<
331        Vec<crate::types::BulkCreateCustomObjectsCustomObjectApiNameRecordsResponse>,
332        crate::types::error::Error,
333    > {
334        let mut req = self.client.client.request(
335            http::Method::POST,
336            format!(
337                "{}/{}",
338                self.client.base_url,
339                "custom-objects/{custom_object_api_name}/records/bulk"
340                    .replace("{custom_object_api_name}", custom_object_api_name)
341            ),
342        );
343        req = req.bearer_auth(&self.client.token);
344        req = req.json(body);
345        let resp = req.send().await?;
346        let status = resp.status();
347        if status.is_success() {
348            let text = resp.text().await.unwrap_or_default();
349            serde_json::from_str(&text).map_err(|err| {
350                crate::types::error::Error::from_serde_error(
351                    format_serde_error::SerdeError::new(text.to_string(), err),
352                    status,
353                )
354            })
355        } else {
356            let text = resp.text().await.unwrap_or_default();
357            Err(crate::types::error::Error::Server {
358                body: text.to_string(),
359                status,
360            })
361        }
362    }
363
364    #[doc = "bulk delete custom object records\n\nBulk Delete custom object records\n\n**Parameters:**\n\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_bulk_delete_custom_objects_custom_object_api_name_records(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    client\n        .custom_object_records()\n        .bulk_delete_custom_objects_custom_object_api_name_records(\n            \"some-string\",\n            &rippling_api::types::BulkDeleteCustomObjectsCustomObjectApiNameRecordsRequestBody {\n                rows_to_delete: Some(\"some-string\".to_string()),\n                all_or_nothing: Some(true),\n            },\n        )\n        .await?;\n    Ok(())\n}\n```"]
365    #[tracing::instrument]
366    pub async fn bulk_delete_custom_objects_custom_object_api_name_records<'a>(
367        &'a self,
368        custom_object_api_name: &'a str,
369        body: &crate::types::BulkDeleteCustomObjectsCustomObjectApiNameRecordsRequestBody,
370    ) -> Result<(), crate::types::error::Error> {
371        let mut req = self.client.client.request(
372            http::Method::DELETE,
373            format!(
374                "{}/{}",
375                self.client.base_url,
376                "custom-objects/{custom_object_api_name}/records/bulk"
377                    .replace("{custom_object_api_name}", custom_object_api_name)
378            ),
379        );
380        req = req.bearer_auth(&self.client.token);
381        req = req.json(body);
382        let resp = req.send().await?;
383        let status = resp.status();
384        if status.is_success() {
385            Ok(())
386        } else {
387            let text = resp.text().await.unwrap_or_default();
388            Err(crate::types::error::Error::Server {
389                body: text.to_string(),
390                status,
391            })
392        }
393    }
394
395    #[doc = "Bulk Update custom object records\n\nBulk Updated a specific custom object records\n\n**Parameters:**\n\n- `custom_object_api_name: &'astr` (required)\n\n```rust,no_run\nasync fn example_custom_object_records_bulk_update_custom_objects_custom_object_api_name_records(\n) -> anyhow::Result<()> {\n    let client = rippling_api::Client::new_from_env();\n    let result: Vec<rippling_api::types::BulkUpdateCustomObjectsCustomObjectApiNameRecordsResponse> =\n        client\n            .custom_object_records()\n            .bulk_update_custom_objects_custom_object_api_name_records(\n                \"some-string\",\n                &rippling_api::types::BulkUpdateCustomObjectsCustomObjectApiNameRecordsRequestBody {\n                    rows_to_update: Some(vec![rippling_api::types::RowsToUpdate {\n                        name: Some(\"some-string\".to_string()),\n                        field_api_name: Some(\"some-string\".to_string()),\n                    }]),\n                    all_or_nothing: Some(true),\n                },\n            )\n            .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
396    #[tracing::instrument]
397    pub async fn bulk_update_custom_objects_custom_object_api_name_records<'a>(
398        &'a self,
399        custom_object_api_name: &'a str,
400        body: &crate::types::BulkUpdateCustomObjectsCustomObjectApiNameRecordsRequestBody,
401    ) -> Result<
402        Vec<crate::types::BulkUpdateCustomObjectsCustomObjectApiNameRecordsResponse>,
403        crate::types::error::Error,
404    > {
405        let mut req = self.client.client.request(
406            http::Method::PATCH,
407            format!(
408                "{}/{}",
409                self.client.base_url,
410                "custom-objects/{custom_object_api_name}/records/bulk"
411                    .replace("{custom_object_api_name}", custom_object_api_name)
412            ),
413        );
414        req = req.bearer_auth(&self.client.token);
415        req = req.json(body);
416        let resp = req.send().await?;
417        let status = resp.status();
418        if status.is_success() {
419            let text = resp.text().await.unwrap_or_default();
420            serde_json::from_str(&text).map_err(|err| {
421                crate::types::error::Error::from_serde_error(
422                    format_serde_error::SerdeError::new(text.to_string(), err),
423                    status,
424                )
425            })
426        } else {
427            let text = resp.text().await.unwrap_or_default();
428            Err(crate::types::error::Error::Server {
429                body: text.to_string(),
430                status,
431            })
432        }
433    }
434}