Skip to main content

spatio_sdk/apis/
contacts_api.rs

1/*
2 * SpatioAPI
3 *
4 * The REST API that owns every resource in your Spatio workspace: notes, sheets, slides, tasks, calendar events, mail, chat, files, and contacts. SpatioMCP wraps this API; Spatio Desktop reads from it. You can call it directly from your own code.  All requests must be authenticated with a Personal Access Token (`Authorization: Bearer pat_...`) or an OAuth 2.1 access token, and use HTTPS.  Official SDKs (MIT, generated from this spec on every release):  - TypeScript: https://github.com/spatio-labs/spatio-ts (`npm install @spatio-labs/spatio-ts`) - Python: https://github.com/spatio-labs/spatio-py (`pip install spatio-sdk`) - Go: https://github.com/spatio-labs/spatio-go (`go get github.com/spatio-labs/spatio-go`)  This specification is generated from the platform-service Go source on every push to `main`. The spec, not hand-written documentation, is the source of truth: server stubs and SDKs are generated from it, and any drift between the spec and the running service fails CI. 
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: hello@spatio.app
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`assign_contact_category`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AssignContactCategoryError {
22    Status401(models::ApiError),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`create_contact`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum CreateContactError {
30    Status401(models::ApiError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`create_contact_category`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum CreateContactCategoryError {
38    Status401(models::ApiError),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`delete_contact`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum DeleteContactError {
46    Status401(models::ApiError),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`delete_contact_category`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum DeleteContactCategoryError {
54    Status401(models::ApiError),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`get_contact`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetContactError {
62    Status401(models::ApiError),
63    Status404(models::ApiError),
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`list_contact_categories`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListContactCategoriesError {
71    Status401(models::ApiError),
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`list_contact_providers`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum ListContactProvidersError {
79    Status401(models::ApiError),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`list_contacts`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum ListContactsError {
87    Status401(models::ApiError),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`unassign_contact_category`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum UnassignContactCategoryError {
95    Status401(models::ApiError),
96    UnknownValue(serde_json::Value),
97}
98
99/// struct for typed errors of method [`update_contact`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum UpdateContactError {
103    Status401(models::ApiError),
104    UnknownValue(serde_json::Value),
105}
106
107/// struct for typed errors of method [`update_contact_category`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum UpdateContactCategoryError {
111    Status401(models::ApiError),
112    UnknownValue(serde_json::Value),
113}
114
115
116pub async fn assign_contact_category(configuration: &configuration::Configuration, id: &str, assign_contact_category_request: models::AssignContactCategoryRequest) -> Result<(), Error<AssignContactCategoryError>> {
117    // add a prefix to parameters to efficiently prevent name collisions
118    let p_path_id = id;
119    let p_body_assign_contact_category_request = assign_contact_category_request;
120
121    let uri_str = format!("{}/v1/contacts/{id}/categories", configuration.base_path, id=crate::apis::urlencode(p_path_id));
122    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
123
124    if let Some(ref user_agent) = configuration.user_agent {
125        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
126    }
127    if let Some(ref token) = configuration.bearer_access_token {
128        req_builder = req_builder.bearer_auth(token.to_owned());
129    };
130    req_builder = req_builder.json(&p_body_assign_contact_category_request);
131
132    let req = req_builder.build()?;
133    let resp = configuration.client.execute(req).await?;
134
135    let status = resp.status();
136
137    if !status.is_client_error() && !status.is_server_error() {
138        Ok(())
139    } else {
140        let content = resp.text().await?;
141        let entity: Option<AssignContactCategoryError> = serde_json::from_str(&content).ok();
142        Err(Error::ResponseError(ResponseContent { status, content, entity }))
143    }
144}
145
146pub async fn create_contact(configuration: &configuration::Configuration, create_contact_request: models::CreateContactRequest) -> Result<models::Contact, Error<CreateContactError>> {
147    // add a prefix to parameters to efficiently prevent name collisions
148    let p_body_create_contact_request = create_contact_request;
149
150    let uri_str = format!("{}/v1/contacts", configuration.base_path);
151    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
152
153    if let Some(ref user_agent) = configuration.user_agent {
154        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155    }
156    if let Some(ref token) = configuration.bearer_access_token {
157        req_builder = req_builder.bearer_auth(token.to_owned());
158    };
159    req_builder = req_builder.json(&p_body_create_contact_request);
160
161    let req = req_builder.build()?;
162    let resp = configuration.client.execute(req).await?;
163
164    let status = resp.status();
165    let content_type = resp
166        .headers()
167        .get("content-type")
168        .and_then(|v| v.to_str().ok())
169        .unwrap_or("application/octet-stream");
170    let content_type = super::ContentType::from(content_type);
171
172    if !status.is_client_error() && !status.is_server_error() {
173        let content = resp.text().await?;
174        match content_type {
175            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
176            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Contact`"))),
177            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Contact`")))),
178        }
179    } else {
180        let content = resp.text().await?;
181        let entity: Option<CreateContactError> = serde_json::from_str(&content).ok();
182        Err(Error::ResponseError(ResponseContent { status, content, entity }))
183    }
184}
185
186pub async fn create_contact_category(configuration: &configuration::Configuration, create_contact_category_request: models::CreateContactCategoryRequest) -> Result<models::ContactCategory, Error<CreateContactCategoryError>> {
187    // add a prefix to parameters to efficiently prevent name collisions
188    let p_body_create_contact_category_request = create_contact_category_request;
189
190    let uri_str = format!("{}/v1/contacts/categories", configuration.base_path);
191    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
192
193    if let Some(ref user_agent) = configuration.user_agent {
194        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
195    }
196    if let Some(ref token) = configuration.bearer_access_token {
197        req_builder = req_builder.bearer_auth(token.to_owned());
198    };
199    req_builder = req_builder.json(&p_body_create_contact_category_request);
200
201    let req = req_builder.build()?;
202    let resp = configuration.client.execute(req).await?;
203
204    let status = resp.status();
205    let content_type = resp
206        .headers()
207        .get("content-type")
208        .and_then(|v| v.to_str().ok())
209        .unwrap_or("application/octet-stream");
210    let content_type = super::ContentType::from(content_type);
211
212    if !status.is_client_error() && !status.is_server_error() {
213        let content = resp.text().await?;
214        match content_type {
215            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
216            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContactCategory`"))),
217            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ContactCategory`")))),
218        }
219    } else {
220        let content = resp.text().await?;
221        let entity: Option<CreateContactCategoryError> = serde_json::from_str(&content).ok();
222        Err(Error::ResponseError(ResponseContent { status, content, entity }))
223    }
224}
225
226pub async fn delete_contact(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteContactError>> {
227    // add a prefix to parameters to efficiently prevent name collisions
228    let p_path_id = id;
229
230    let uri_str = format!("{}/v1/contacts/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
231    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
232
233    if let Some(ref user_agent) = configuration.user_agent {
234        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
235    }
236    if let Some(ref token) = configuration.bearer_access_token {
237        req_builder = req_builder.bearer_auth(token.to_owned());
238    };
239
240    let req = req_builder.build()?;
241    let resp = configuration.client.execute(req).await?;
242
243    let status = resp.status();
244
245    if !status.is_client_error() && !status.is_server_error() {
246        Ok(())
247    } else {
248        let content = resp.text().await?;
249        let entity: Option<DeleteContactError> = serde_json::from_str(&content).ok();
250        Err(Error::ResponseError(ResponseContent { status, content, entity }))
251    }
252}
253
254pub async fn delete_contact_category(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteContactCategoryError>> {
255    // add a prefix to parameters to efficiently prevent name collisions
256    let p_path_id = id;
257
258    let uri_str = format!("{}/v1/contacts/categories/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
259    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
260
261    if let Some(ref user_agent) = configuration.user_agent {
262        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
263    }
264    if let Some(ref token) = configuration.bearer_access_token {
265        req_builder = req_builder.bearer_auth(token.to_owned());
266    };
267
268    let req = req_builder.build()?;
269    let resp = configuration.client.execute(req).await?;
270
271    let status = resp.status();
272
273    if !status.is_client_error() && !status.is_server_error() {
274        Ok(())
275    } else {
276        let content = resp.text().await?;
277        let entity: Option<DeleteContactCategoryError> = serde_json::from_str(&content).ok();
278        Err(Error::ResponseError(ResponseContent { status, content, entity }))
279    }
280}
281
282pub async fn get_contact(configuration: &configuration::Configuration, id: &str) -> Result<models::Contact, Error<GetContactError>> {
283    // add a prefix to parameters to efficiently prevent name collisions
284    let p_path_id = id;
285
286    let uri_str = format!("{}/v1/contacts/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
287    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
288
289    if let Some(ref user_agent) = configuration.user_agent {
290        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
291    }
292    if let Some(ref token) = configuration.bearer_access_token {
293        req_builder = req_builder.bearer_auth(token.to_owned());
294    };
295
296    let req = req_builder.build()?;
297    let resp = configuration.client.execute(req).await?;
298
299    let status = resp.status();
300    let content_type = resp
301        .headers()
302        .get("content-type")
303        .and_then(|v| v.to_str().ok())
304        .unwrap_or("application/octet-stream");
305    let content_type = super::ContentType::from(content_type);
306
307    if !status.is_client_error() && !status.is_server_error() {
308        let content = resp.text().await?;
309        match content_type {
310            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
311            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Contact`"))),
312            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Contact`")))),
313        }
314    } else {
315        let content = resp.text().await?;
316        let entity: Option<GetContactError> = serde_json::from_str(&content).ok();
317        Err(Error::ResponseError(ResponseContent { status, content, entity }))
318    }
319}
320
321pub async fn list_contact_categories(configuration: &configuration::Configuration, organization_id: &str) -> Result<models::ContactCategoryListResponse, Error<ListContactCategoriesError>> {
322    // add a prefix to parameters to efficiently prevent name collisions
323    let p_query_organization_id = organization_id;
324
325    let uri_str = format!("{}/v1/contacts/categories", configuration.base_path);
326    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
327
328    req_builder = req_builder.query(&[("organization_id", &p_query_organization_id.to_string())]);
329    if let Some(ref user_agent) = configuration.user_agent {
330        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
331    }
332    if let Some(ref token) = configuration.bearer_access_token {
333        req_builder = req_builder.bearer_auth(token.to_owned());
334    };
335
336    let req = req_builder.build()?;
337    let resp = configuration.client.execute(req).await?;
338
339    let status = resp.status();
340    let content_type = resp
341        .headers()
342        .get("content-type")
343        .and_then(|v| v.to_str().ok())
344        .unwrap_or("application/octet-stream");
345    let content_type = super::ContentType::from(content_type);
346
347    if !status.is_client_error() && !status.is_server_error() {
348        let content = resp.text().await?;
349        match content_type {
350            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
351            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContactCategoryListResponse`"))),
352            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ContactCategoryListResponse`")))),
353        }
354    } else {
355        let content = resp.text().await?;
356        let entity: Option<ListContactCategoriesError> = serde_json::from_str(&content).ok();
357        Err(Error::ResponseError(ResponseContent { status, content, entity }))
358    }
359}
360
361pub async fn list_contact_providers(configuration: &configuration::Configuration, ) -> Result<models::ContactProviderListResponse, Error<ListContactProvidersError>> {
362
363    let uri_str = format!("{}/v1/contacts/providers", configuration.base_path);
364    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
365
366    if let Some(ref user_agent) = configuration.user_agent {
367        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
368    }
369    if let Some(ref token) = configuration.bearer_access_token {
370        req_builder = req_builder.bearer_auth(token.to_owned());
371    };
372
373    let req = req_builder.build()?;
374    let resp = configuration.client.execute(req).await?;
375
376    let status = resp.status();
377    let content_type = resp
378        .headers()
379        .get("content-type")
380        .and_then(|v| v.to_str().ok())
381        .unwrap_or("application/octet-stream");
382    let content_type = super::ContentType::from(content_type);
383
384    if !status.is_client_error() && !status.is_server_error() {
385        let content = resp.text().await?;
386        match content_type {
387            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
388            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContactProviderListResponse`"))),
389            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ContactProviderListResponse`")))),
390        }
391    } else {
392        let content = resp.text().await?;
393        let entity: Option<ListContactProvidersError> = serde_json::from_str(&content).ok();
394        Err(Error::ResponseError(ResponseContent { status, content, entity }))
395    }
396}
397
398pub async fn list_contacts(configuration: &configuration::Configuration, limit: Option<i32>, provider: Option<&str>, search: Option<&str>) -> Result<models::ContactListResponse, Error<ListContactsError>> {
399    // add a prefix to parameters to efficiently prevent name collisions
400    let p_query_limit = limit;
401    let p_query_provider = provider;
402    let p_query_search = search;
403
404    let uri_str = format!("{}/v1/contacts", configuration.base_path);
405    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
406
407    if let Some(ref param_value) = p_query_limit {
408        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
409    }
410    if let Some(ref param_value) = p_query_provider {
411        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
412    }
413    if let Some(ref param_value) = p_query_search {
414        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
415    }
416    if let Some(ref user_agent) = configuration.user_agent {
417        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
418    }
419    if let Some(ref token) = configuration.bearer_access_token {
420        req_builder = req_builder.bearer_auth(token.to_owned());
421    };
422
423    let req = req_builder.build()?;
424    let resp = configuration.client.execute(req).await?;
425
426    let status = resp.status();
427    let content_type = resp
428        .headers()
429        .get("content-type")
430        .and_then(|v| v.to_str().ok())
431        .unwrap_or("application/octet-stream");
432    let content_type = super::ContentType::from(content_type);
433
434    if !status.is_client_error() && !status.is_server_error() {
435        let content = resp.text().await?;
436        match content_type {
437            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
438            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContactListResponse`"))),
439            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ContactListResponse`")))),
440        }
441    } else {
442        let content = resp.text().await?;
443        let entity: Option<ListContactsError> = serde_json::from_str(&content).ok();
444        Err(Error::ResponseError(ResponseContent { status, content, entity }))
445    }
446}
447
448pub async fn unassign_contact_category(configuration: &configuration::Configuration, id: &str, category_id: &str) -> Result<(), Error<UnassignContactCategoryError>> {
449    // add a prefix to parameters to efficiently prevent name collisions
450    let p_path_id = id;
451    let p_path_category_id = category_id;
452
453    let uri_str = format!("{}/v1/contacts/{id}/categories/{categoryId}", configuration.base_path, id=crate::apis::urlencode(p_path_id), categoryId=crate::apis::urlencode(p_path_category_id));
454    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
455
456    if let Some(ref user_agent) = configuration.user_agent {
457        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
458    }
459    if let Some(ref token) = configuration.bearer_access_token {
460        req_builder = req_builder.bearer_auth(token.to_owned());
461    };
462
463    let req = req_builder.build()?;
464    let resp = configuration.client.execute(req).await?;
465
466    let status = resp.status();
467
468    if !status.is_client_error() && !status.is_server_error() {
469        Ok(())
470    } else {
471        let content = resp.text().await?;
472        let entity: Option<UnassignContactCategoryError> = serde_json::from_str(&content).ok();
473        Err(Error::ResponseError(ResponseContent { status, content, entity }))
474    }
475}
476
477pub async fn update_contact(configuration: &configuration::Configuration, id: &str, update_contact_request: models::UpdateContactRequest) -> Result<models::Contact, Error<UpdateContactError>> {
478    // add a prefix to parameters to efficiently prevent name collisions
479    let p_path_id = id;
480    let p_body_update_contact_request = update_contact_request;
481
482    let uri_str = format!("{}/v1/contacts/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
483    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
484
485    if let Some(ref user_agent) = configuration.user_agent {
486        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
487    }
488    if let Some(ref token) = configuration.bearer_access_token {
489        req_builder = req_builder.bearer_auth(token.to_owned());
490    };
491    req_builder = req_builder.json(&p_body_update_contact_request);
492
493    let req = req_builder.build()?;
494    let resp = configuration.client.execute(req).await?;
495
496    let status = resp.status();
497    let content_type = resp
498        .headers()
499        .get("content-type")
500        .and_then(|v| v.to_str().ok())
501        .unwrap_or("application/octet-stream");
502    let content_type = super::ContentType::from(content_type);
503
504    if !status.is_client_error() && !status.is_server_error() {
505        let content = resp.text().await?;
506        match content_type {
507            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
508            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Contact`"))),
509            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Contact`")))),
510        }
511    } else {
512        let content = resp.text().await?;
513        let entity: Option<UpdateContactError> = serde_json::from_str(&content).ok();
514        Err(Error::ResponseError(ResponseContent { status, content, entity }))
515    }
516}
517
518pub async fn update_contact_category(configuration: &configuration::Configuration, id: &str, update_contact_category_request: models::UpdateContactCategoryRequest) -> Result<models::ContactCategory, Error<UpdateContactCategoryError>> {
519    // add a prefix to parameters to efficiently prevent name collisions
520    let p_path_id = id;
521    let p_body_update_contact_category_request = update_contact_category_request;
522
523    let uri_str = format!("{}/v1/contacts/categories/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
524    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
525
526    if let Some(ref user_agent) = configuration.user_agent {
527        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
528    }
529    if let Some(ref token) = configuration.bearer_access_token {
530        req_builder = req_builder.bearer_auth(token.to_owned());
531    };
532    req_builder = req_builder.json(&p_body_update_contact_category_request);
533
534    let req = req_builder.build()?;
535    let resp = configuration.client.execute(req).await?;
536
537    let status = resp.status();
538    let content_type = resp
539        .headers()
540        .get("content-type")
541        .and_then(|v| v.to_str().ok())
542        .unwrap_or("application/octet-stream");
543    let content_type = super::ContentType::from(content_type);
544
545    if !status.is_client_error() && !status.is_server_error() {
546        let content = resp.text().await?;
547        match content_type {
548            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
549            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContactCategory`"))),
550            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ContactCategory`")))),
551        }
552    } else {
553        let content = resp.text().await?;
554        let entity: Option<UpdateContactCategoryError> = serde_json::from_str(&content).ok();
555        Err(Error::ResponseError(ResponseContent { status, content, entity }))
556    }
557}
558