1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteSocialAccountsByIdError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteSocialPostsByIdError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetSocialAccountsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetSocialAccountsByIdError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetSocialPostsError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetSocialPostsByIdError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetSocialProvidersError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetSocialSummaryError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostSocialAccountsError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PostSocialPostsError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum PostSocialPostsByIdPublishError {
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum PutSocialAccountsByIdError {
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum PutSocialPostsByIdError {
106 UnknownValue(serde_json::Value),
107}
108
109
110pub async fn delete_social_accounts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteSocialAccountsByIdError>> {
112 let p_id = id;
114
115 let uri_str = format!("{}/v1/social/accounts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
116 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
117
118 if let Some(ref user_agent) = configuration.user_agent {
119 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
120 }
121 if let Some(ref token) = configuration.bearer_access_token {
122 req_builder = req_builder.bearer_auth(token.to_owned());
123 };
124
125 let req = req_builder.build()?;
126 let resp = configuration.client.execute(req).await?;
127
128 let status = resp.status();
129
130 if !status.is_client_error() && !status.is_server_error() {
131 Ok(())
132 } else {
133 let content = resp.text().await?;
134 let entity: Option<DeleteSocialAccountsByIdError> = serde_json::from_str(&content).ok();
135 Err(Error::ResponseError(ResponseContent { status, content, entity }))
136 }
137}
138
139pub async fn delete_social_posts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteSocialPostsByIdError>> {
141 let p_id = id;
143
144 let uri_str = format!("{}/v1/social/posts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
145 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
146
147 if let Some(ref user_agent) = configuration.user_agent {
148 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149 }
150 if let Some(ref token) = configuration.bearer_access_token {
151 req_builder = req_builder.bearer_auth(token.to_owned());
152 };
153
154 let req = req_builder.build()?;
155 let resp = configuration.client.execute(req).await?;
156
157 let status = resp.status();
158
159 if !status.is_client_error() && !status.is_server_error() {
160 Ok(())
161 } else {
162 let content = resp.text().await?;
163 let entity: Option<DeleteSocialPostsByIdError> = serde_json::from_str(&content).ok();
164 Err(Error::ResponseError(ResponseContent { status, content, entity }))
165 }
166}
167
168pub async fn get_social_accounts(configuration: &configuration::Configuration, provider: Option<&str>, limit: Option<&str>) -> Result<models::SocialAccounts, Error<GetSocialAccountsError>> {
170 let p_provider = provider;
172 let p_limit = limit;
173
174 let uri_str = format!("{}/v1/social/accounts", configuration.base_path);
175 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
176
177 if let Some(ref param_value) = p_provider {
178 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
179 }
180 if let Some(ref param_value) = p_limit {
181 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
182 }
183 if let Some(ref user_agent) = configuration.user_agent {
184 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
185 }
186 if let Some(ref token) = configuration.bearer_access_token {
187 req_builder = req_builder.bearer_auth(token.to_owned());
188 };
189
190 let req = req_builder.build()?;
191 let resp = configuration.client.execute(req).await?;
192
193 let status = resp.status();
194 let content_type = resp
195 .headers()
196 .get("content-type")
197 .and_then(|v| v.to_str().ok())
198 .unwrap_or("application/octet-stream");
199 let content_type = super::ContentType::from(content_type);
200
201 if !status.is_client_error() && !status.is_server_error() {
202 let content = resp.text().await?;
203 match content_type {
204 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
205 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialAccounts`"))),
206 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::SocialAccounts`")))),
207 }
208 } else {
209 let content = resp.text().await?;
210 let entity: Option<GetSocialAccountsError> = serde_json::from_str(&content).ok();
211 Err(Error::ResponseError(ResponseContent { status, content, entity }))
212 }
213}
214
215pub async fn get_social_accounts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::SocialAccount, Error<GetSocialAccountsByIdError>> {
217 let p_id = id;
219
220 let uri_str = format!("{}/v1/social/accounts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
221 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
222
223 if let Some(ref user_agent) = configuration.user_agent {
224 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
225 }
226 if let Some(ref token) = configuration.bearer_access_token {
227 req_builder = req_builder.bearer_auth(token.to_owned());
228 };
229
230 let req = req_builder.build()?;
231 let resp = configuration.client.execute(req).await?;
232
233 let status = resp.status();
234 let content_type = resp
235 .headers()
236 .get("content-type")
237 .and_then(|v| v.to_str().ok())
238 .unwrap_or("application/octet-stream");
239 let content_type = super::ContentType::from(content_type);
240
241 if !status.is_client_error() && !status.is_server_error() {
242 let content = resp.text().await?;
243 match content_type {
244 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
245 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialAccount`"))),
246 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::SocialAccount`")))),
247 }
248 } else {
249 let content = resp.text().await?;
250 let entity: Option<GetSocialAccountsByIdError> = serde_json::from_str(&content).ok();
251 Err(Error::ResponseError(ResponseContent { status, content, entity }))
252 }
253}
254
255pub async fn get_social_posts(configuration: &configuration::Configuration, status: Option<&str>, limit: Option<&str>) -> Result<models::SocialPosts, Error<GetSocialPostsError>> {
257 let p_status = status;
259 let p_limit = limit;
260
261 let uri_str = format!("{}/v1/social/posts", configuration.base_path);
262 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
263
264 if let Some(ref param_value) = p_status {
265 req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
266 }
267 if let Some(ref param_value) = p_limit {
268 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
269 }
270 if let Some(ref user_agent) = configuration.user_agent {
271 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
272 }
273 if let Some(ref token) = configuration.bearer_access_token {
274 req_builder = req_builder.bearer_auth(token.to_owned());
275 };
276
277 let req = req_builder.build()?;
278 let resp = configuration.client.execute(req).await?;
279
280 let status = resp.status();
281 let content_type = resp
282 .headers()
283 .get("content-type")
284 .and_then(|v| v.to_str().ok())
285 .unwrap_or("application/octet-stream");
286 let content_type = super::ContentType::from(content_type);
287
288 if !status.is_client_error() && !status.is_server_error() {
289 let content = resp.text().await?;
290 match content_type {
291 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
292 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialPosts`"))),
293 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::SocialPosts`")))),
294 }
295 } else {
296 let content = resp.text().await?;
297 let entity: Option<GetSocialPostsError> = serde_json::from_str(&content).ok();
298 Err(Error::ResponseError(ResponseContent { status, content, entity }))
299 }
300}
301
302pub async fn get_social_posts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::SocialPost, Error<GetSocialPostsByIdError>> {
304 let p_id = id;
306
307 let uri_str = format!("{}/v1/social/posts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
308 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
309
310 if let Some(ref user_agent) = configuration.user_agent {
311 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
312 }
313 if let Some(ref token) = configuration.bearer_access_token {
314 req_builder = req_builder.bearer_auth(token.to_owned());
315 };
316
317 let req = req_builder.build()?;
318 let resp = configuration.client.execute(req).await?;
319
320 let status = resp.status();
321 let content_type = resp
322 .headers()
323 .get("content-type")
324 .and_then(|v| v.to_str().ok())
325 .unwrap_or("application/octet-stream");
326 let content_type = super::ContentType::from(content_type);
327
328 if !status.is_client_error() && !status.is_server_error() {
329 let content = resp.text().await?;
330 match content_type {
331 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
332 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialPost`"))),
333 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::SocialPost`")))),
334 }
335 } else {
336 let content = resp.text().await?;
337 let entity: Option<GetSocialPostsByIdError> = serde_json::from_str(&content).ok();
338 Err(Error::ResponseError(ResponseContent { status, content, entity }))
339 }
340}
341
342pub async fn get_social_providers(configuration: &configuration::Configuration, ) -> Result<models::SocialProviders, Error<GetSocialProvidersError>> {
344
345 let uri_str = format!("{}/v1/social/providers", configuration.base_path);
346 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
347
348 if let Some(ref user_agent) = configuration.user_agent {
349 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
350 }
351 if let Some(ref token) = configuration.bearer_access_token {
352 req_builder = req_builder.bearer_auth(token.to_owned());
353 };
354
355 let req = req_builder.build()?;
356 let resp = configuration.client.execute(req).await?;
357
358 let status = resp.status();
359 let content_type = resp
360 .headers()
361 .get("content-type")
362 .and_then(|v| v.to_str().ok())
363 .unwrap_or("application/octet-stream");
364 let content_type = super::ContentType::from(content_type);
365
366 if !status.is_client_error() && !status.is_server_error() {
367 let content = resp.text().await?;
368 match content_type {
369 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
370 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialProviders`"))),
371 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::SocialProviders`")))),
372 }
373 } else {
374 let content = resp.text().await?;
375 let entity: Option<GetSocialProvidersError> = serde_json::from_str(&content).ok();
376 Err(Error::ResponseError(ResponseContent { status, content, entity }))
377 }
378}
379
380pub async fn get_social_summary(configuration: &configuration::Configuration, ) -> Result<models::SocialSummary, Error<GetSocialSummaryError>> {
382
383 let uri_str = format!("{}/v1/social/summary", configuration.base_path);
384 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
385
386 if let Some(ref user_agent) = configuration.user_agent {
387 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
388 }
389 if let Some(ref token) = configuration.bearer_access_token {
390 req_builder = req_builder.bearer_auth(token.to_owned());
391 };
392
393 let req = req_builder.build()?;
394 let resp = configuration.client.execute(req).await?;
395
396 let status = resp.status();
397 let content_type = resp
398 .headers()
399 .get("content-type")
400 .and_then(|v| v.to_str().ok())
401 .unwrap_or("application/octet-stream");
402 let content_type = super::ContentType::from(content_type);
403
404 if !status.is_client_error() && !status.is_server_error() {
405 let content = resp.text().await?;
406 match content_type {
407 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
408 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialSummary`"))),
409 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::SocialSummary`")))),
410 }
411 } else {
412 let content = resp.text().await?;
413 let entity: Option<GetSocialSummaryError> = serde_json::from_str(&content).ok();
414 Err(Error::ResponseError(ResponseContent { status, content, entity }))
415 }
416}
417
418pub async fn post_social_accounts(configuration: &configuration::Configuration, social_account_body: models::SocialAccountBody) -> Result<models::SocialAccount, Error<PostSocialAccountsError>> {
420 let p_social_account_body = social_account_body;
422
423 let uri_str = format!("{}/v1/social/accounts", configuration.base_path);
424 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
425
426 if let Some(ref user_agent) = configuration.user_agent {
427 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
428 }
429 if let Some(ref token) = configuration.bearer_access_token {
430 req_builder = req_builder.bearer_auth(token.to_owned());
431 };
432 req_builder = req_builder.json(&p_social_account_body);
433
434 let req = req_builder.build()?;
435 let resp = configuration.client.execute(req).await?;
436
437 let status = resp.status();
438 let content_type = resp
439 .headers()
440 .get("content-type")
441 .and_then(|v| v.to_str().ok())
442 .unwrap_or("application/octet-stream");
443 let content_type = super::ContentType::from(content_type);
444
445 if !status.is_client_error() && !status.is_server_error() {
446 let content = resp.text().await?;
447 match content_type {
448 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
449 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialAccount`"))),
450 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::SocialAccount`")))),
451 }
452 } else {
453 let content = resp.text().await?;
454 let entity: Option<PostSocialAccountsError> = serde_json::from_str(&content).ok();
455 Err(Error::ResponseError(ResponseContent { status, content, entity }))
456 }
457}
458
459pub async fn post_social_posts(configuration: &configuration::Configuration, social_post_body: models::SocialPostBody) -> Result<models::SocialPost, Error<PostSocialPostsError>> {
461 let p_social_post_body = social_post_body;
463
464 let uri_str = format!("{}/v1/social/posts", configuration.base_path);
465 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
466
467 if let Some(ref user_agent) = configuration.user_agent {
468 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
469 }
470 if let Some(ref token) = configuration.bearer_access_token {
471 req_builder = req_builder.bearer_auth(token.to_owned());
472 };
473 req_builder = req_builder.json(&p_social_post_body);
474
475 let req = req_builder.build()?;
476 let resp = configuration.client.execute(req).await?;
477
478 let status = resp.status();
479 let content_type = resp
480 .headers()
481 .get("content-type")
482 .and_then(|v| v.to_str().ok())
483 .unwrap_or("application/octet-stream");
484 let content_type = super::ContentType::from(content_type);
485
486 if !status.is_client_error() && !status.is_server_error() {
487 let content = resp.text().await?;
488 match content_type {
489 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
490 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialPost`"))),
491 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::SocialPost`")))),
492 }
493 } else {
494 let content = resp.text().await?;
495 let entity: Option<PostSocialPostsError> = serde_json::from_str(&content).ok();
496 Err(Error::ResponseError(ResponseContent { status, content, entity }))
497 }
498}
499
500pub async fn post_social_posts_by_id_publish(configuration: &configuration::Configuration, id: &str) -> Result<models::SocialPost, Error<PostSocialPostsByIdPublishError>> {
502 let p_id = id;
504
505 let uri_str = format!("{}/v1/social/posts/{id}/publish", configuration.base_path, id=crate::apis::urlencode(p_id));
506 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
507
508 if let Some(ref user_agent) = configuration.user_agent {
509 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
510 }
511 if let Some(ref token) = configuration.bearer_access_token {
512 req_builder = req_builder.bearer_auth(token.to_owned());
513 };
514
515 let req = req_builder.build()?;
516 let resp = configuration.client.execute(req).await?;
517
518 let status = resp.status();
519 let content_type = resp
520 .headers()
521 .get("content-type")
522 .and_then(|v| v.to_str().ok())
523 .unwrap_or("application/octet-stream");
524 let content_type = super::ContentType::from(content_type);
525
526 if !status.is_client_error() && !status.is_server_error() {
527 let content = resp.text().await?;
528 match content_type {
529 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
530 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialPost`"))),
531 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::SocialPost`")))),
532 }
533 } else {
534 let content = resp.text().await?;
535 let entity: Option<PostSocialPostsByIdPublishError> = serde_json::from_str(&content).ok();
536 Err(Error::ResponseError(ResponseContent { status, content, entity }))
537 }
538}
539
540pub async fn put_social_accounts_by_id(configuration: &configuration::Configuration, id: &str, social_account_write: models::SocialAccountWrite) -> Result<models::SocialAccount, Error<PutSocialAccountsByIdError>> {
542 let p_id = id;
544 let p_social_account_write = social_account_write;
545
546 let uri_str = format!("{}/v1/social/accounts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
547 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
548
549 if let Some(ref user_agent) = configuration.user_agent {
550 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
551 }
552 if let Some(ref token) = configuration.bearer_access_token {
553 req_builder = req_builder.bearer_auth(token.to_owned());
554 };
555 req_builder = req_builder.json(&p_social_account_write);
556
557 let req = req_builder.build()?;
558 let resp = configuration.client.execute(req).await?;
559
560 let status = resp.status();
561 let content_type = resp
562 .headers()
563 .get("content-type")
564 .and_then(|v| v.to_str().ok())
565 .unwrap_or("application/octet-stream");
566 let content_type = super::ContentType::from(content_type);
567
568 if !status.is_client_error() && !status.is_server_error() {
569 let content = resp.text().await?;
570 match content_type {
571 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
572 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialAccount`"))),
573 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::SocialAccount`")))),
574 }
575 } else {
576 let content = resp.text().await?;
577 let entity: Option<PutSocialAccountsByIdError> = serde_json::from_str(&content).ok();
578 Err(Error::ResponseError(ResponseContent { status, content, entity }))
579 }
580}
581
582pub async fn put_social_posts_by_id(configuration: &configuration::Configuration, id: &str, social_post_write: models::SocialPostWrite) -> Result<models::SocialPost, Error<PutSocialPostsByIdError>> {
584 let p_id = id;
586 let p_social_post_write = social_post_write;
587
588 let uri_str = format!("{}/v1/social/posts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
589 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
590
591 if let Some(ref user_agent) = configuration.user_agent {
592 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
593 }
594 if let Some(ref token) = configuration.bearer_access_token {
595 req_builder = req_builder.bearer_auth(token.to_owned());
596 };
597 req_builder = req_builder.json(&p_social_post_write);
598
599 let req = req_builder.build()?;
600 let resp = configuration.client.execute(req).await?;
601
602 let status = resp.status();
603 let content_type = resp
604 .headers()
605 .get("content-type")
606 .and_then(|v| v.to_str().ok())
607 .unwrap_or("application/octet-stream");
608 let content_type = super::ContentType::from(content_type);
609
610 if !status.is_client_error() && !status.is_server_error() {
611 let content = resp.text().await?;
612 match content_type {
613 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
614 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SocialPost`"))),
615 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::SocialPost`")))),
616 }
617 } else {
618 let content = resp.text().await?;
619 let entity: Option<PutSocialPostsByIdError> = serde_json::from_str(&content).ok();
620 Err(Error::ResponseError(ResponseContent { status, content, entity }))
621 }
622}
623