Skip to main content

hanzo_client/apis/
social_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
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 [`delete_social_accounts_by_id`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteSocialAccountsByIdError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`delete_social_posts_by_id`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteSocialPostsByIdError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_social_accounts`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetSocialAccountsError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_social_accounts_by_id`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetSocialAccountsByIdError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_social_posts`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetSocialPostsError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_social_posts_by_id`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetSocialPostsByIdError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_social_providers`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetSocialProvidersError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`get_social_summary`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetSocialSummaryError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`post_social_accounts`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostSocialAccountsError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`post_social_posts`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PostSocialPostsError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`post_social_posts_by_id_publish`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum PostSocialPostsByIdPublishError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`put_social_accounts_by_id`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum PutSocialAccountsByIdError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`put_social_posts_by_id`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum PutSocialPostsByIdError {
106    UnknownValue(serde_json::Value),
107}
108
109
110/// Removes one connected account from the org and answers 204 with no body; an id that is not there is 404.  It removes the account record only. Posts that already published through it keep their published state and their recorded external ids — this does not retract anything from the network.
111pub async fn delete_social_accounts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteSocialAccountsByIdError>> {
112    // add a prefix to parameters to efficiently prevent name collisions
113    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
139/// Removes one post from the org and answers 204 with no body; an id that is not there is 404.  It deletes the record here only. A post that has already published is not retracted from the network by deleting it.
140pub async fn delete_social_posts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteSocialPostsByIdError>> {
141    // add a prefix to parameters to efficiently prevent name collisions
142    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
168/// Returns the org's connected accounts — each one's id, network, handle, status and timestamps, most-recently-updated first.  An account's provider access token is NEVER included in any response on this surface. Only the publisher reads it.
169pub async fn get_social_accounts(configuration: &configuration::Configuration, provider: Option<&str>, limit: Option<&str>) -> Result<models::SocialAccounts, Error<GetSocialAccountsError>> {
170    // add a prefix to parameters to efficiently prevent name collisions
171    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", &param_value.to_string())]);
179    }
180    if let Some(ref param_value) = p_limit {
181        req_builder = req_builder.query(&[("limit", &param_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
215/// Returns one of the org's connected accounts by id — its network, handle, status and timestamps — or 404. The provider access token is not part of the response.
216pub async fn get_social_accounts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::SocialAccount, Error<GetSocialAccountsByIdError>> {
217    // add a prefix to parameters to efficiently prevent name collisions
218    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
255/// Returns the org's posts — content, channel, status, scheduled time, media and timestamps — most-recently-updated first.
256pub async fn get_social_posts(configuration: &configuration::Configuration, status: Option<&str>, limit: Option<&str>) -> Result<models::SocialPosts, Error<GetSocialPostsError>> {
257    // add a prefix to parameters to efficiently prevent name collisions
258    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", &param_value.to_string())]);
266    }
267    if let Some(ref param_value) = p_limit {
268        req_builder = req_builder.query(&[("limit", &param_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
302/// Returns one of the org's posts by id, with its current status, scheduled time, media and — once it has published — the account and external id it published under. 404 when there is no such post for this org.
303pub async fn get_social_posts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::SocialPost, Error<GetSocialPostsByIdError>> {
304    // add a prefix to parameters to efficiently prevent name collisions
305    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
342/// Reports each supported network's publish-readiness: whether this deployment holds the OAuth application credentials for it and, when it does not, exactly which environment variables are missing.  This is a live read of the deployment's own configuration, not a static list of networks — it answers \"can I connect this today\", which is what a connect affordance and a pre-cutover checklist both need. It says nothing about whether the caller has connected an account; that is the accounts listing.
343pub 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
380/// Returns four counts for the caller's org: total posts, how many are scheduled, how many have published, and how many accounts are connected. It is the dashboard roll-up, computed over the org's own rows in one read.
381pub 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
418/// Records a social account for the org and answers 201 with the stored row, including the generated id later calls address it by.
419pub async fn post_social_accounts(configuration: &configuration::Configuration, social_account_body: models::SocialAccountBody) -> Result<models::SocialAccount, Error<PostSocialAccountsError>> {
420    // add a prefix to parameters to efficiently prevent name collisions
421    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
459/// Stores a post for the org and answers 201 with the stored row.  A post created as scheduled for a time that has already passed is published IMMEDIATELY, and the row returned carries that outcome — this is the one behaviour a reader would otherwise miss. A future-scheduled post is left for the scheduler, and a draft is left alone. Publishing never fails the creation: the post is stored either way, and a publish that could not run leaves the row for the scheduler to retry.
460pub async fn post_social_posts(configuration: &configuration::Configuration, social_post_body: models::SocialPostBody) -> Result<models::SocialPost, Error<PostSocialPostsError>> {
461    // add a prefix to parameters to efficiently prevent name collisions
462    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
500/// Publishes the post immediately to the connected accounts on its channel and answers with the updated row, carrying the account and external id it published under.  It is IDEMPOTENT: a post that has already published, or that another caller is publishing right now, comes back unchanged rather than being posted twice. That claim is taken before any network call, which is what makes a double submit safe.  The two failure shapes differ on purpose. Having no connected account for the channel is the caller's to fix, so it is recorded ON the post as failed with the reason and answers normally. A deployment that lacks the network's own credentials cannot publish for anyone, so that is a 503 naming exactly what is missing.
501pub async fn post_social_posts_by_id_publish(configuration: &configuration::Configuration, id: &str) -> Result<models::SocialPost, Error<PostSocialPostsByIdPublishError>> {
502    // add a prefix to parameters to efficiently prevent name collisions
503    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
540/// Replaces the account's network, handle and status with what the body carries, and answers with the stored row.  This is a REPLACEMENT, not a merge, which is the rule most easily got wrong: a field the body omits is written as its default, so leaving out the handle blanks it and leaving out the status resets it to connected. Send the whole record. The same vocabularies as create apply, and an unknown network or status is refused rather than coerced.
541pub async fn put_social_accounts_by_id(configuration: &configuration::Configuration, id: &str, social_account_write: models::SocialAccountWrite) -> Result<models::SocialAccount, Error<PutSocialAccountsByIdError>> {
542    // add a prefix to parameters to efficiently prevent name collisions
543    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
582/// Replaces the post's content, channel, status, scheduled time and media with what the body carries, and answers with the stored row.  A REPLACEMENT, not a merge: an omitted field is written as its default, so omitting media clears it and omitting the status resets the post to draft. `content` is required on every update. Unlike create, this never triggers a publish — moving a post's scheduled time into the past here leaves it for the scheduler; publish now is its own operation.
583pub async fn put_social_posts_by_id(configuration: &configuration::Configuration, id: &str, social_post_write: models::SocialPostWrite) -> Result<models::SocialPost, Error<PutSocialPostsByIdError>> {
584    // add a prefix to parameters to efficiently prevent name collisions
585    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