/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.129.1
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`assign_google_business_location`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AssignGoogleBusinessLocationError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`complete_meta_ads_business_login`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CompleteMetaAdsBusinessLoginError {
Status400(models::ErrorResponse),
Status403(),
Status409(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`complete_telegram_connect`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CompleteTelegramConnectError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`complete_whats_app_phone_selection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CompleteWhatsAppPhoneSelectionError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(models::ErrorResponse),
Status409(),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`configure_tik_tok_ads_brand_identity`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConfigureTikTokAdsBrandIdentityError {
Status400(),
Status401(models::InlineObject1),
Status404(),
Status500(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_ads`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectAdsError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_bluesky_credentials`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectBlueskyCredentialsError {
Status400(),
Status401(models::InlineObject1),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_discord_channel`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectDiscordChannelError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_open_ai_ads_credentials`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectOpenAiAdsCredentialsError {
Status400(models::ErrorResponse),
Status401(),
Status402(models::InlineObject4),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_shopify_with_token`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectShopifyWithTokenError {
Status400(),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_slack_channel`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectSlackChannelError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_whats_app_credentials`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectWhatsAppCredentialsError {
Status400(),
Status401(),
Status403(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_whats_app_embedded_signup`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectWhatsAppEmbeddedSignupError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_word_press_with_application_password`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectWordPressWithApplicationPasswordError {
Status400(),
Status401(),
Status402(models::InlineObject4),
Status403(),
Status404(),
Status502(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_pinterest_board`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreatePinterestBoardError {
Status400(),
Status401(models::InlineObject1),
Status404(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_youtube_playlist`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateYoutubePlaylistError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status429(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_connect_url`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetConnectUrlError {
Status400(),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_facebook_pages`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetFacebookPagesError {
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_gmb_locations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetGmbLocationsError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_linked_in_organizations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetLinkedInOrganizationsError {
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_page_webhook_subscription`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPageWebhookSubscriptionError {
Status400(models::ErrorResponse),
Status404(models::InlineObject2),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_pending_o_auth_data`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPendingOAuthDataError {
Status400(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_pinterest_boards`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPinterestBoardsError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_reddit_flairs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRedditFlairsError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_reddit_subreddits`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRedditSubredditsError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_shopify_connect_url`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetShopifyConnectUrlError {
Status400(),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status403(),
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_subreddit_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSubredditRulesError {
Status400(),
Status401(models::InlineObject1),
Status404(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_telegram_connect_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTelegramConnectStatusError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_whats_app_sdk_config`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWhatsAppSdkConfigError {
Status401(models::InlineObject1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_word_press_auth_url`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWordPressAuthUrlError {
Status400(),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status403(),
Status404(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_youtube_captions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetYoutubeCaptionsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_youtube_playlists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetYoutubePlaylistsError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`handle_o_auth_callback`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum HandleOAuthCallbackError {
Status400(),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status403(),
Status404(),
Status500(),
Status502(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`initiate_telegram_connect`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InitiateTelegramConnectError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_facebook_pages`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListFacebookPagesError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status500(models::GetYouTubeDailyViews400Response),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_google_business_locations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListGoogleBusinessLocationsError {
Status400(),
Status401(models::InlineObject1),
Status500(models::GetYouTubeDailyViews400Response),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_instagram_pages`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInstagramPagesError {
Status400(),
Status401(models::InlineObject1),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_linked_in_organizations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListLinkedInOrganizationsError {
Status400(models::GetYouTubeDailyViews400Response),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_pinterest_boards_for_selection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListPinterestBoardsForSelectionError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_slack_channels`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSlackChannelsError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_snapchat_profiles`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSnapchatProfilesError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_whats_app_phone_numbers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListWhatsAppPhoneNumbersError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`resync_page_webhook_subscription`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResyncPageWebhookSubscriptionError {
Status400(models::ErrorResponse),
Status404(models::InlineObject2),
Status409(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`select_facebook_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SelectFacebookPageError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(models::ErrorResponse),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`select_google_business_location`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SelectGoogleBusinessLocationError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`select_instagram_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SelectInstagramAccountError {
Status400(),
Status401(models::InlineObject1),
Status402(models::InlineObject4),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`select_linked_in_organization`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SelectLinkedInOrganizationError {
Status400(),
Status401(models::InlineObject1),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`select_pinterest_board`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SelectPinterestBoardError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`select_snapchat_profile`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SelectSnapchatProfileError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status500(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_reddit_post_flair`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetRedditPostFlairError {
Status400(),
Status401(models::InlineObject1),
Status404(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_facebook_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateFacebookPageError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_gmb_location`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateGmbLocationError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_linked_in_organization`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateLinkedInOrganizationError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_pinterest_boards`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdatePinterestBoardsError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_reddit_subreddits`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateRedditSubredditsError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_youtube_default_playlist`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateYoutubeDefaultPlaylistError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`vote_reddit_thing`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum VoteRedditThingError {
Status400(),
Status401(models::InlineObject1),
Status404(),
Status502(),
UnknownValue(serde_json::Value),
}
/// Connect a Google Business Profile location onto a DIFFERENT profile by reusing the OAuth grant from an already-connected Google Business Profile account, with no browser and no re-authorization. Built for agencies whose single Google account has manager access to many client locations and who run one profile per client: connect one location the normal way (browser OAuth), then bulk-assign the rest onto each client's profile via this endpoint. The path `accountId` is a SOURCE connected Google Business Profile account (the token holder); the body `profileId` is the TARGET profile. Returns 409 if the target profile already has a Google Business Profile connection (switch its location with PUT gmb-locations instead).
pub async fn assign_google_business_location(
configuration: &configuration::Configuration,
account_id: &str,
assign_google_business_location_request: models::AssignGoogleBusinessLocationRequest,
) -> Result<models::AssignGoogleBusinessLocation200Response, Error<AssignGoogleBusinessLocationError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_assign_google_business_location_request = assign_google_business_location_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/gmb-locations/assign",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_assign_google_business_location_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AssignGoogleBusinessLocation200Response`"))),
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::AssignGoogleBusinessLocation200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AssignGoogleBusinessLocationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Facebook Login for Business redirect target. Meta supplies the single-use authorization code and the authenticated state returned by connectAds. The state expires after 30 minutes and binds the user, profile, Page selection and ad-account scope. No bearer token is sent by the browser. Success reconnects only metaads and redirects to the original redirect_url. Invalid state returns 400; inaccessible profiles or missing ads access cannot connect. Dashboard logins with several Pages redirect to the Facebook Page picker with an encrypted selectionToken valid for ten minutes. Listing and selecting require the initiating user and current profile access. No plaintext platform token is returned to the browser.
pub async fn complete_meta_ads_business_login(
configuration: &configuration::Configuration,
state: &str,
code: Option<&str>,
error: Option<&str>,
) -> Result<(), Error<CompleteMetaAdsBusinessLoginError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_state = state;
let p_query_code = code;
let p_query_error = error;
let uri_str = format!("{}/v1/connect/meta-ads/callback", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("state", &p_query_state.to_string())]);
if let Some(ref param_value) = p_query_code {
req_builder = req_builder.query(&[("code", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_error {
req_builder = req_builder.query(&[("error", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<CompleteMetaAdsBusinessLoginError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Poll this endpoint to check if a Telegram access code has been used to connect a channel/group. Recommended polling interval: 3 seconds. Status values: pending (waiting for user), connected (channel/group linked), expired (generate a new code).
pub async fn complete_telegram_connect(
configuration: &configuration::Configuration,
code: &str,
) -> Result<models::CompleteTelegramConnect200Response, Error<CompleteTelegramConnectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_code = code;
let uri_str = format!("{}/v1/connect/telegram", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
req_builder = req_builder.query(&[("code", &p_query_code.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CompleteTelegramConnect200Response`"))),
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::CompleteTelegramConnect200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CompleteTelegramConnectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Bind a specific WhatsApp phone number to the Zernio profile after the user picks one from `listWhatsAppPhoneNumbers`. Exchanges the short-lived OAuth token for a long-lived token, subscribes the WABA to webhooks, and creates the SocialAccount.
pub async fn complete_whats_app_phone_selection(
configuration: &configuration::Configuration,
complete_whats_app_phone_selection_request: models::CompleteWhatsAppPhoneSelectionRequest,
x_connect_token: Option<&str>,
) -> Result<
models::CompleteWhatsAppPhoneSelection200Response,
Error<CompleteWhatsAppPhoneSelectionError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_complete_whats_app_phone_selection_request =
complete_whats_app_phone_selection_request;
let p_header_x_connect_token = x_connect_token;
let uri_str = format!(
"{}/v1/connect/whatsapp/select-phone-number",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_connect_token {
req_builder = req_builder.header("X-Connect-Token", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_complete_whats_app_phone_selection_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CompleteWhatsAppPhoneSelection200Response`"))),
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::CompleteWhatsAppPhoneSelection200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CompleteWhatsAppPhoneSelectionError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Set or update the Brand Identity (display name + avatar) for a `tiktokads` SocialAccount. TikTok requires every ad to carry an `identity_id + identity_type` pair. The Brand Identity is the CUSTOMIZED_USER alternative to attributing ads to a real @username (TT_USER). This route uploads the supplied image to TikTok, creates the identity via `/v2/identity/create/`, and caches the resulting `identity_id` on the account so subsequent `POST /v1/ads/create` calls can opt into it via `identityType: 'CUSTOMIZED_USER'`. Configurable on every `tiktokads` account, including linked-mode ones (those with a posting account on the same profile). Configuration is idempotent and harmless when posting is also connected: the default ad-create path still prefers TT_USER, and CUSTOMIZED_USER is only used per-ad when the caller explicitly opts in. TikTok identities are immutable post-creation. Re-saving creates a new identity on TikTok and swaps the cached id; the old identity stays orphaned on TikTok's side (harmless, no billing impact). Alternative: pass `brandIdentity` directly on `POST /v1/ads/create` to configure on first ad creation in a single round-trip.
pub async fn configure_tik_tok_ads_brand_identity(
configuration: &configuration::Configuration,
configure_tik_tok_ads_brand_identity_request: models::ConfigureTikTokAdsBrandIdentityRequest,
) -> Result<
models::ConfigureTikTokAdsBrandIdentity200Response,
Error<ConfigureTikTokAdsBrandIdentityError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_configure_tik_tok_ads_brand_identity_request =
configure_tik_tok_ads_brand_identity_request;
let uri_str = format!("{}/v1/connect/tiktok-ads", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_configure_tik_tok_ads_brand_identity_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigureTikTokAdsBrandIdentity200Response`"))),
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::ConfigureTikTokAdsBrandIdentity200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConfigureTikTokAdsBrandIdentityError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Unified ads connection endpoint. Creates a dedicated ads SocialAccount for the specified platform. **Meta business login (opt-in).** Set `loginMode=business` for `facebook` or `instagram` to use Facebook Login for Business and a Business Integration System User token. No posting account is created or required. This mode always returns an authUrl; it returns 503 when the server has no META_ADS_CONFIG_ID. Complete the dialog in a browser. The callback creates or reconnects only the metaads account, preserving its ID and history. Non-empty successful subscription results replace subscribedAdAccountIds to remove stale grants; an empty result leaves routing unchanged. A reconnect is accepted when the new grant shares at least one ad account with the existing connection (its scopedAdAccountIds plus the previous grant, or the ad accounts its old token can read when neither is stored), so re-running the dialog can add, drop or swap ad accounts. A grant with zero overlap is refused before changing the account and redirects with `error=invalid_field_value` and `error_reason=reconnect_mismatch` (disconnect and connect again to switch); when the previous ad accounts cannot be read at all, it redirects with `error=reconnect_required`. On an accepted reconnect the scope is rebuilt from the new grant: `adAccountIds` passed on the re-auth become the scope; otherwise a stored scope keeps its ad accounts that are still granted plus any granted for the first time, and an unscoped connection follows the new grant. Pass `pageId` to select a granted Page for creatives and lead forms. API integrations otherwise reuse the previous Page or sole granted Page. Multiple Pages without a selection return 400 with available Page IDs for API integrations; restart with pageId. Dashboard session logins use the sole current grant automatically or open the existing Facebook Page picker for several grants, including reconnects. Selection completes the Meta Ads connection. Success redirects with connected=metaads, profileId and accountId. Every failure after Meta's dialog redirects to redirect_url (or the dashboard) with `error`, `platform=metaads`, `error_message`, `request_id` and `stage`, plus `is_user_fixable` and `error_reason` when known. `error` is the API error code: `invalid_field_value` with `error_reason` `no_pages_granted` (no Page ticked), `page_not_granted` (pageId not in the grant), `ad_accounts_not_granted` or `reconnect_mismatch` (the grant shares no ad account with the existing connection); `reconnect_required`, `ads_addon_required`, `payment_required` and the profile gates of GET /v1/connect/{platform}; `invalid_state` with `error_reason=state_expired` after the 30-minute window; `connection_failed` when Meta refuses the code (e.g. a replayed callback). A denial in the dialog is `meta_ads_authorization_denied` with the `platform_error*` params. Only a state that cannot be decrypted at all still answers 400 JSON, since it names no redirect_url. Business login reports metadata.tokenType=system-user in GET /v1/accounts. An absent Meta expires_in leaves tokenExpiresAt absent; no personal-token re-exchange occurs. Subsequent classic requests can change the ad-account scope using the business token; force=true requires loginMode=business to reconnect that connection. **Same-token platforms (facebook, instagram, linkedin, pinterest).** The ads SocialAccount (metaads, linkedinads, pinterestads) reuses the OAuth token of the parent posting account, but only when an active parent exists and, for facebook and instagram, its stored token carries ads_management and ads_read (linkedin and pinterest need no extra scope). In that case no extra OAuth happens and the response is alreadyConnected: true. When no such parent exists, or the scopes are missing, the endpoint returns an authUrl and a full OAuth round trip is required. When a parent exists but carries no token usable for ad accounts, the call fails with 400 RECONNECT_REQUIRED. Independently of the branch, the call can return 403 ADS_ADDON_REQUIRED without the ads add-on and 402 PAYMENT_REQUIRED when the billing gate is closed. Meta Ads prerequisite: connecting Meta Ads (via facebook or instagram) requires a Facebook Page. Not because the ad account is read through a Page, but because both parent posting accounts are: the facebook flow only offers Pages you manage, and the instagram flow with loginMethod=facebook_login only offers Instagram accounts linked to one of those Pages. Without a Page there is no parent account to inherit a token from. A user who manages no Facebook Page cannot complete this connection, and the facebook flow ends with error=no_facebook_pages. **Separate-token platforms (tiktok, twitter).** Starts the platform-specific marketing API OAuth flow and creates an ads SocialAccount (tiktokads, xads) with its own token. If the ads account already exists, returns alreadyConnected: true. - tiktok: accountId is OPTIONAL. With accountId, the new tiktokads account links to that posting account (parentAccountId set), so Spark Ads + standalone ads using the posting TT_USER identity become available. Without accountId, ads-only mode kicks in: the new tiktokads account has parentAccountId=null and standalone ads use a synthetic CUSTOMIZED_USER (\"Brand Identity\"); Spark Ads are unavailable because TikTok requires a posting account for them. The Brand Identity is configured separately via PATCH /v1/connect/tiktok-ads (or inline on POST /v1/ads/create via the brandIdentity field). - twitter (X Ads): accountId is REQUIRED. There's no ads-only mode, because tweets need to be authored by a real X user. **Standalone platforms (googleads).** Starts the Google Ads OAuth flow and creates a standalone ads SocialAccount (googleads) with no parent. If the account already exists and has at least one discovered Google Ads customer account, returns alreadyConnected: true. When the existing connection has zero customer accounts (metadata.googleAdsCustomerIds is empty) or is flagged needsReconnection, it returns an authUrl instead; completing it reconnects the same account (same accountId) and re-runs ad account discovery. Discovery includes the client accounts under every manager (MCC) the Google user can reach, and includes Google Ads test accounts, which Google always reports with status CLOSED. When discovery finds no usable customer account, the callback saves nothing and redirects with `error=google_ads_no_ad_accounts`, `platform=googleads` and an `error_message` naming each customer the Google user can reach and why it was left out (for example CUSTOMER_NOT_ENABLED). Sign in with a Google user that has access to the ad account or to its manager account. When the user unticks the Google Ads permission on Google's consent screen, the callback saves nothing and redirects with `error=missing_google_permissions`, `platform=googleads`, `is_user_fixable=true` and `missing_scopes`. An existing connection whose token lacks that permission is flagged needsReconnection, and the health endpoints report \"Google Ads permission not granted\"; this endpoint then returns an authUrl for it. Ads accounts appear as regular SocialAccount documents with ads platform values (e.g., metaads, tiktokads) in GET /v1/accounts.
pub async fn connect_ads(
configuration: &configuration::Configuration,
platform: &str,
profile_id: &str,
login_mode: Option<&str>,
permission_level: Option<&str>,
page_id: Option<&str>,
account_id: Option<&str>,
redirect_url: Option<&str>,
headless: Option<bool>,
force: Option<bool>,
ad_account_id: Option<&str>,
ad_account_ids: Option<Vec<String>>,
) -> Result<models::ConnectAds200Response, Error<ConnectAdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_platform = platform;
let p_query_profile_id = profile_id;
let p_query_login_mode = login_mode;
let p_query_permission_level = permission_level;
let p_query_page_id = page_id;
let p_query_account_id = account_id;
let p_query_redirect_url = redirect_url;
let p_query_headless = headless;
let p_query_force = force;
let p_query_ad_account_id = ad_account_id;
let p_query_ad_account_ids = ad_account_ids;
let uri_str = format!(
"{}/v1/connect/{platform}/ads",
configuration.base_path,
platform = crate::apis::urlencode(p_path_platform)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_login_mode {
req_builder = req_builder.query(&[("loginMode", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_permission_level {
req_builder = req_builder.query(&[("permissionLevel", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_id {
req_builder = req_builder.query(&[("pageId", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_redirect_url {
req_builder = req_builder.query(&[("redirect_url", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_headless {
req_builder = req_builder.query(&[("headless", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_force {
req_builder = req_builder.query(&[("force", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("adAccountIds".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"adAccountIds",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectAds200Response`"))),
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::ConnectAds200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectAdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Connect a Bluesky account using identifier (handle or email) and an app password. To get your userId for the state parameter, call GET /v1/users which includes a currentUserId field.
pub async fn connect_bluesky_credentials(
configuration: &configuration::Configuration,
connect_bluesky_credentials_request: models::ConnectBlueskyCredentialsRequest,
) -> Result<models::ConnectBlueskyCredentials200Response, Error<ConnectBlueskyCredentialsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_bluesky_credentials_request = connect_bluesky_credentials_request;
let uri_str = format!("{}/v1/connect/bluesky/credentials", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_bluesky_credentials_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectBlueskyCredentials200Response`"))),
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::ConnectBlueskyCredentials200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectBlueskyCredentialsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Finalize a Discord connect by binding one channel to a profile. Served by a dedicated route, so it is not reachable through POST /v1/connect/{platform}. One connected account per channel: repeat the call with a different channelId to add another.
pub async fn connect_discord_channel(
configuration: &configuration::Configuration,
connect_discord_channel_request: models::ConnectDiscordChannelRequest,
) -> Result<(), Error<ConnectDiscordChannelError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_discord_channel_request = connect_discord_channel_request;
let uri_str = format!("{}/v1/connect/discord", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_discord_channel_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<ConnectDiscordChannelError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Connect an OpenAI Ads account using an API key from ChatGPT Ads Manager. The key grants full campaign write access on OpenAI's side (OpenAI does not offer a read-only key scope). Zernio uses it to read ads and performance, and to create and manage campaigns you set up through Zernio (create, status, budget, and cancel). Campaigns created directly in ChatGPT Ads Manager can still be managed there.
pub async fn connect_open_ai_ads_credentials(
configuration: &configuration::Configuration,
connect_open_ai_ads_credentials_request: models::ConnectOpenAiAdsCredentialsRequest,
) -> Result<models::ConnectOpenAiAdsCredentials200Response, Error<ConnectOpenAiAdsCredentialsError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_open_ai_ads_credentials_request = connect_open_ai_ads_credentials_request;
let uri_str = format!(
"{}/v1/connect/openai-ads/credentials",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_open_ai_ads_credentials_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectOpenAiAdsCredentials200Response`"))),
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::ConnectOpenAiAdsCredentials200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectOpenAiAdsCredentialsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Token-paste alternative to the OAuth flow: connect a store using the Admin API access token of a custom app the merchant created in their own Shopify admin (Settings → Apps and sales channels → Develop apps, with the `read_content`, `write_content`, `read_products` and `write_products` scopes). Use this when the one-click OAuth connect is unavailable or when your users prefer not to install a third-party app on their store. The token is validated against the store before anything is saved; custom-app tokens do not expire. Connecting the same profile to a store again replaces the stored token in place.
pub async fn connect_shopify_with_token(
configuration: &configuration::Configuration,
connect_shopify_with_token_request: models::ConnectShopifyWithTokenRequest,
) -> Result<models::ConnectShopifyWithToken200Response, Error<ConnectShopifyWithTokenError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_shopify_with_token_request = connect_shopify_with_token_request;
let uri_str = format!("{}/v1/connect/shopify/token", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_shopify_with_token_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectShopifyWithToken200Response`"))),
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::ConnectShopifyWithToken200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectShopifyWithTokenError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Finalize a Slack connect by creating the per-channel account. Served by a dedicated route, so it is not reachable through POST /v1/connect/{platform}. Send pendingDataToken for a first connect (the nonce from the OAuth redirect) or accountId to add another channel to a workspace already connected.
pub async fn connect_slack_channel(
configuration: &configuration::Configuration,
connect_slack_channel_request: models::ConnectSlackChannelRequest,
) -> Result<(), Error<ConnectSlackChannelError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_slack_channel_request = connect_slack_channel_request;
let uri_str = format!("{}/v1/connect/slack", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_slack_channel_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<ConnectSlackChannelError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Connect a WhatsApp Business Account by providing Meta credentials directly. This is the headless alternative to the Embedded Signup browser flow. To get the required credentials: 1. Go to Meta Business Suite (business.facebook.com) 2. Create or select a WhatsApp Business Account 3. In Business Settings > System Users, create a System User 4. Assign it the whatsapp_business_management and whatsapp_business_messaging permissions 5. Generate a permanent access token 6. Get the WABA ID from WhatsApp Manager > Account Tools > Phone Numbers 7. Get the Phone Number ID from the same page (click on the number) Warning: connecting subscribes your own Meta app to this WABA with an override callback that redirects its webhook delivery to Zernio. This WABA's events stop reaching any callback URL you had configured before, immediately and with no overlap window. Do not unsubscribe your app from the WABA afterward: that also cuts off Zernio's delivery, and recovery requires calling this endpoint again.
pub async fn connect_whats_app_credentials(
configuration: &configuration::Configuration,
connect_whats_app_credentials_request: models::ConnectWhatsAppCredentialsRequest,
) -> Result<models::ConnectWhatsAppCredentials200Response, Error<ConnectWhatsAppCredentialsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_whats_app_credentials_request = connect_whats_app_credentials_request;
let uri_str = format!(
"{}/v1/connect/whatsapp/credentials",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_whats_app_credentials_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectWhatsAppCredentials200Response`"))),
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::ConnectWhatsAppCredentials200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectWhatsAppCredentialsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Exchange the authorization code Meta's Embedded Signup popup returned. This is the call the Zernio-hosted signup page makes after the popup closes (`GET /v1/connect/whatsapp?signup=hosted`), sending the `wabaId` and `phoneNumberId` Meta reported so exactly the chosen number is connected; when both are omitted the first number the token can see is used. The code never passes through a `redirect_uri`, so `POST /v1/connect/{platform}` cannot accept it. Authenticates with an API key, or with the connect token the hosted flow issues (`X-Connect-Token` header).
pub async fn connect_whats_app_embedded_signup(
configuration: &configuration::Configuration,
connect_whats_app_embedded_signup_request: models::ConnectWhatsAppEmbeddedSignupRequest,
x_connect_token: Option<&str>,
) -> Result<
models::ConnectWhatsAppEmbeddedSignup200Response,
Error<ConnectWhatsAppEmbeddedSignupError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_whats_app_embedded_signup_request =
connect_whats_app_embedded_signup_request;
let p_header_x_connect_token = x_connect_token;
let uri_str = format!(
"{}/v1/connect/whatsapp/embedded-signup",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_connect_token {
req_builder = req_builder.header("X-Connect-Token", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_whats_app_embedded_signup_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectWhatsAppEmbeddedSignup200Response`"))),
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::ConnectWhatsAppEmbeddedSignup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectWhatsAppEmbeddedSignupError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Connects one self-hosted WordPress site using a WordPress username and application password. `siteUrl` must use HTTPS and may include the path where WordPress is installed. Zernio discovers the REST API, verifies the credentials and required post/media/taxonomy capabilities, then stores the password encrypted. Create an application password in the WordPress user's profile; do not send the user's login password. Reconnecting the same site and profile updates the connection in place.
pub async fn connect_word_press_with_application_password(
configuration: &configuration::Configuration,
connect_word_press_with_application_password_request: models::ConnectWordPressWithApplicationPasswordRequest,
) -> Result<
models::ConnectWordPressWithApplicationPassword200Response,
Error<ConnectWordPressWithApplicationPasswordError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_connect_word_press_with_application_password_request =
connect_word_press_with_application_password_request;
let uri_str = format!("{}/v1/connect/wordpress/token", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_connect_word_press_with_application_password_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectWordPressWithApplicationPassword200Response`"))),
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::ConnectWordPressWithApplicationPassword200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectWordPressWithApplicationPasswordError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a new board on the connected Pinterest account. The returned board ID can be used immediately as `platformSpecificData.boardId` when creating a Pinterest post.
pub async fn create_pinterest_board(
configuration: &configuration::Configuration,
account_id: &str,
create_pinterest_board_request: models::CreatePinterestBoardRequest,
) -> Result<models::CreatePinterestBoard201Response, Error<CreatePinterestBoardError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_create_pinterest_board_request = create_pinterest_board_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/pinterest-boards",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_pinterest_board_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreatePinterestBoard201Response`"))),
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::CreatePinterestBoard201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreatePinterestBoardError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates an empty playlist on the connected YouTube channel. Requires a title; privacy defaults to private. Returns the same playlist shape as the list endpoint. Pass the returned playlist.id as platformSpecificData.playlistId when publishing a video. Does not change the account's default playlist. Requires the youtube or youtube.force-ssl OAuth scope. Costs 50 YouTube quota units. This operation is not idempotent and is not automatically retried: repeating a request can create another playlist, including after a timeout. List playlists before retrying an ambiguous failure. Official series settings are not exposed by YouTube's public API and must be enabled manually in YouTube's desktop playlist settings.
pub async fn create_youtube_playlist(
configuration: &configuration::Configuration,
account_id: &str,
create_youtube_playlist_request: models::CreateYoutubePlaylistRequest,
) -> Result<models::CreateYoutubePlaylist201Response, Error<CreateYoutubePlaylistError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_create_youtube_playlist_request = create_youtube_playlist_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/youtube-playlists",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_youtube_playlist_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateYoutubePlaylist201Response`"))),
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::CreateYoutubePlaylist201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateYoutubePlaylistError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Initiate an OAuth connection flow. Returns an authUrl to redirect the user to. Standard flow: Zernio hosts the selection UI, then redirects to your redirect_url. Headless mode (headless=true): user is redirected to your redirect_url with OAuth data for custom UI. Use the platform-specific selection endpoints to complete. TikTok: every connection now goes through the TikTok for Business app. One TikTok account per profile, so connecting on a profile that already holds one replaces it. Reconnecting the SAME account keeps it and all of its history; authorizing a DIFFERENT TikTok account takes the slot over and permanently deletes the previous account's analytics, inbox and DM history. The two are told apart by the `@handle` stored at the last connect, so an account whose handle has been renamed on TikTok since then reads as a different account. An authorization that leaves out a permission the connected account needs changes nothing at all and comes back as `missing_tiktok_permissions`; connect again and accept every permission on TikTok's screen.
pub async fn get_connect_url(
configuration: &configuration::Configuration,
platform: &str,
profile_id: &str,
redirect_url: Option<&str>,
headless: Option<bool>,
login_method: Option<&str>,
onboarding: Option<&str>,
signup: Option<&str>,
brand_name: Option<&str>,
primary_color: Option<&str>,
language: Option<&str>,
) -> Result<models::GetConnectUrl200Response, Error<GetConnectUrlError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_platform = platform;
let p_query_profile_id = profile_id;
let p_query_redirect_url = redirect_url;
let p_query_headless = headless;
let p_query_login_method = login_method;
let p_query_onboarding = onboarding;
let p_query_signup = signup;
let p_query_brand_name = brand_name;
let p_query_primary_color = primary_color;
let p_query_language = language;
let uri_str = format!(
"{}/v1/connect/{platform}",
configuration.base_path,
platform = crate::apis::urlencode(p_path_platform)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
if let Some(ref param_value) = p_query_redirect_url {
req_builder = req_builder.query(&[("redirect_url", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_headless {
req_builder = req_builder.query(&[("headless", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_login_method {
req_builder = req_builder.query(&[("loginMethod", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_onboarding {
req_builder = req_builder.query(&[("onboarding", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_signup {
req_builder = req_builder.query(&[("signup", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_brand_name {
req_builder = req_builder.query(&[("brandName", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_primary_color {
req_builder = req_builder.query(&[("primaryColor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_language {
req_builder = req_builder.query(&[("language", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConnectUrl200Response`"))),
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::GetConnectUrl200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetConnectUrlError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns all Facebook pages the connected account has access to, including the currently selected page.
pub async fn get_facebook_pages(
configuration: &configuration::Configuration,
account_id: &str,
refresh: Option<bool>,
) -> Result<models::GetFacebookPages200Response, Error<GetFacebookPagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_query_refresh = refresh;
let uri_str = format!(
"{}/v1/accounts/{accountId}/facebook-page",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_refresh {
req_builder = req_builder.query(&[("refresh", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetFacebookPages200Response`"))),
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::GetFacebookPages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFacebookPagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns Google Business Profile locations the connected account can access, plus the currently selected location. The list is bounded (see hasMore); for accounts that own many locations, use the search or filter query params to find a specific one instead of loading them all, or raise limit to enumerate an account with more than 100 locations.
pub async fn get_gmb_locations(
configuration: &configuration::Configuration,
account_id: &str,
search: Option<&str>,
filter: Option<&str>,
limit: Option<i32>,
) -> Result<models::GetGmbLocations200Response, Error<GetGmbLocationsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_query_search = search;
let p_query_filter = filter;
let p_query_limit = limit;
let uri_str = format!(
"{}/v1/accounts/{accountId}/gmb-locations",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGmbLocations200Response`"))),
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::GetGmbLocations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetGmbLocationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns LinkedIn organizations (company pages) the connected account has admin access to.
pub async fn get_linked_in_organizations(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::GetLinkedInOrganizations200Response, Error<GetLinkedInOrganizationsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/linkedin-organizations",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetLinkedInOrganizations200Response`"))),
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::GetLinkedInOrganizations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetLinkedInOrganizationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the webhook fields Zernio's app is subscribed to on the connected Page, read live from Meta. Use it to confirm `leadgen` is present: a Page missing it keeps delivering every other event while lead ads stop arriving, with nothing to indicate it.
pub async fn get_page_webhook_subscription(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::GetPageWebhookSubscription200Response, Error<GetPageWebhookSubscriptionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/webhook-subscription",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPageWebhookSubscription200Response`"))),
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::GetPageWebhookSubscription200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPageWebhookSubscriptionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Fetch pending OAuth data for headless mode using the pendingDataToken from the redirect URL. **Scope**: This endpoint is used for LinkedIn organizations, Google Business Profile locations, Slack channels, Snapchat profiles, and Pinterest boards, where the selection list is too large to fit in URL params. The redirect carries a `pendingDataToken` instead of the full payload; the response includes the corresponding selection array (e.g. `boards` for Pinterest). WhatsApp, Facebook and other platforms pass selection state directly via URL query params on the redirect (`profileId`, `tempToken`, `step`), no pending record is created, so this endpoint will return 404 for those flows. Use the platform-specific selection endpoint instead (e.g. `/v1/connect/whatsapp/select-phone-number`). Reading the token does not consume it, so this fetch is repeatable until the token expires 1 hour after issuance. Completing the platform selection deletes the pending record, so the token stops working from then on. No authentication required.
pub async fn get_pending_o_auth_data(
configuration: &configuration::Configuration,
token: &str,
) -> Result<models::GetPendingOAuthData200Response, Error<GetPendingOAuthDataError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let uri_str = format!("{}/v1/connect/pending-data", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPendingOAuthData200Response`"))),
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::GetPendingOAuthData200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPendingOAuthDataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the boards available for a connected Pinterest account. Use this to get a board ID when creating a Pinterest post.
pub async fn get_pinterest_boards(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::GetPinterestBoards200Response, Error<GetPinterestBoardsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/pinterest-boards",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetPinterestBoards200Response`"))),
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::GetPinterestBoards200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPinterestBoardsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns available post flairs for a subreddit. Some subreddits require a flair when posting.
pub async fn get_reddit_flairs(
configuration: &configuration::Configuration,
account_id: &str,
subreddit: &str,
) -> Result<models::GetRedditFlairs200Response, Error<GetRedditFlairsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_query_subreddit = subreddit;
let uri_str = format!(
"{}/v1/accounts/{accountId}/reddit-flairs",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("subreddit", &p_query_subreddit.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetRedditFlairs200Response`"))),
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::GetRedditFlairs200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRedditFlairsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the subreddits the connected Reddit account can post to. Use this to get a subreddit name when creating a Reddit post.
pub async fn get_reddit_subreddits(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::GetRedditSubreddits200Response, Error<GetRedditSubredditsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/reddit-subreddits",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetRedditSubreddits200Response`"))),
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::GetRedditSubreddits200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRedditSubredditsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Initiate the Shopify OAuth flow for a store. Shopify is a connect-only platform: the connected account does not publish social posts, it powers the Blogs API (`/v1/accounts/{accountId}/blogs`) and the Products API (`/v1/accounts/{accountId}/products`). Returns an `authUrl` to redirect the merchant to; after they approve the install, Shopify redirects their browser to Zernio's callback, the account is created on the profile (platform `shopify`), and the browser is redirected to `redirect_url` (or the Zernio dashboard when omitted). Requested scopes are `read_content`, `write_content`, `read_products` and `write_products` (content and products only; no customer or order data). Connecting the same profile to a store again refreshes the stored token in place, and is how a store connected under the older content-only grant picks up product access.
pub async fn get_shopify_connect_url(
configuration: &configuration::Configuration,
profile_id: &str,
shop: &str,
redirect_url: Option<&str>,
) -> Result<models::GetConnectUrl200Response, Error<GetShopifyConnectUrlError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let p_query_shop = shop;
let p_query_redirect_url = redirect_url;
let uri_str = format!("{}/v1/connect/shopify", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
req_builder = req_builder.query(&[("shop", &p_query_shop.to_string())]);
if let Some(ref param_value) = p_query_redirect_url {
req_builder = req_builder.query(&[("redirect_url", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConnectUrl200Response`"))),
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::GetConnectUrl200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetShopifyConnectUrlError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns a subreddit's posting rules plus Reddit's site-wide rules, so you can check them before submitting and avoid a removal. Use this alongside `POST /v1/tools/validate/subreddit`, which only confirms that a subreddit exists and reports its basic posting settings.
pub async fn get_subreddit_rules(
configuration: &configuration::Configuration,
account_id: &str,
subreddit: &str,
) -> Result<models::GetSubredditRules200Response, Error<GetSubredditRulesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_subreddit = subreddit;
let uri_str = format!(
"{}/v1/accounts/{accountId}/reddit-subreddits/{subreddit}/rules",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
subreddit = crate::apis::urlencode(p_path_subreddit)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetSubredditRules200Response`"))),
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::GetSubredditRules200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetSubredditRulesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Generate an access code (valid 15 minutes) for connecting a Telegram channel or group. Add the bot as admin, then send the code + @yourchannel to the bot. Poll PATCH /v1/connect/telegram to check status.
pub async fn get_telegram_connect_status(
configuration: &configuration::Configuration,
profile_id: &str,
) -> Result<models::GetTelegramConnectStatus200Response, Error<GetTelegramConnectStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let uri_str = format!("{}/v1/connect/telegram", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTelegramConnectStatus200Response`"))),
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::GetTelegramConnectStatus200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTelegramConnectStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The Meta app id and Embedded Signup configuration id the Zernio-hosted signup page uses to open Meta's popup. Integrators do not need this endpoint: start the hosted flow with `GET /v1/connect/whatsapp?signup=hosted` and send the user to the returned `authUrl`. Authenticates with an API key or with the connect token the hosted flow issues (`X-Connect-Token` header).
pub async fn get_whats_app_sdk_config(
configuration: &configuration::Configuration,
x_connect_token: Option<&str>,
) -> Result<models::GetWhatsAppSdkConfig200Response, Error<GetWhatsAppSdkConfigError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_header_x_connect_token = x_connect_token;
let uri_str = format!("{}/v1/connect/whatsapp/sdk-config", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_connect_token {
req_builder = req_builder.header("X-Connect-Token", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetWhatsAppSdkConfig200Response`"))),
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::GetWhatsAppSdkConfig200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetWhatsAppSdkConfigError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Initiates OAuth for a WordPress.com site or a Jetpack-connected site. WordPress is a connect-only blog platform: the connected account powers the Blogs API (`/v1/accounts/{accountId}/blogs`) and does not support social posts, inbox, analytics, ads, or Shopify product operations. Redirect the user to `authUrl`; after authorization, WordPress returns the browser to Zernio's internal callback and Zernio redirects to `redirect_url` (or the dashboard when omitted). Reconnecting the same site and profile updates the stored connection in place. The consent request omits `scope` to use WordPress.com's default single-site grant. Granular scopes cannot access the `/wp/v2` article API. Zernio checks that API before saving the connection and does not request explicit `global` authorization across all sites.
pub async fn get_word_press_auth_url(
configuration: &configuration::Configuration,
profile_id: &str,
redirect_url: Option<&str>,
) -> Result<models::GetWordPressAuthUrl200Response, Error<GetWordPressAuthUrlError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let p_query_redirect_url = redirect_url;
let uri_str = format!("{}/v1/connect/wordpress", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
if let Some(ref param_value) = p_query_redirect_url {
req_builder = req_builder.query(&[("redirect_url", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetWordPressAuthUrl200Response`"))),
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::GetWordPressAuthUrl200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetWordPressAuthUrlError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the caption track YouTube already holds for one of the connected channel's own videos, as plain text plus timed cues. Use it instead of downloading and transcribing the video yourself. Auto-generated (ASR) tracks are included: YouTube serves them to the channel owner, which is what the connected account is. Uploaded tracks win over auto-generated ones when both exist for a language. Caching: we store the transcript on first read and serve it from there afterwards, so you do not need to cache it yourself. A cached read costs no YouTube quota and does not call YouTube at all. `source` tells you which happened (`youtube` on the first read, `cache` after). Pass `refresh=true` only when the captions actually changed on YouTube, since that re-downloads. Notes: - Only videos owned by this connected channel. Anything else returns 404. - `contentDetails.caption` in YouTube's own API reads `false` on videos that DO have a serving auto-generated track, so it is not a usable availability signal. Call this endpoint and handle the 404. - YouTube generates auto-captions only for videos with recognisable speech, and can take a few hours after upload to publish them.
pub async fn get_youtube_captions(
configuration: &configuration::Configuration,
account_id: &str,
video_id: &str,
language: Option<&str>,
format: Option<&str>,
refresh: Option<bool>,
) -> Result<models::GetYoutubeCaptions200Response, Error<GetYoutubeCaptionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_query_video_id = video_id;
let p_query_language = language;
let p_query_format = format;
let p_query_refresh = refresh;
let uri_str = format!(
"{}/v1/accounts/{accountId}/youtube-captions",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("videoId", &p_query_video_id.to_string())]);
if let Some(ref param_value) = p_query_language {
req_builder = req_builder.query(&[("language", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_format {
req_builder = req_builder.query(&[("format", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_refresh {
req_builder = req_builder.query(&[("refresh", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetYoutubeCaptions200Response`"))),
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::GetYoutubeCaptions200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetYoutubeCaptionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the playlists available for a connected YouTube account. Use this to get a playlist ID when creating a YouTube post with the playlistId field.
pub async fn get_youtube_playlists(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::GetYoutubePlaylists200Response, Error<GetYoutubePlaylistsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/youtube-playlists",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetYoutubePlaylists200Response`"))),
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::GetYoutubePlaylists200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetYoutubePlaylistsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Exchange the OAuth authorization code for tokens and connect the account to the specified profile. Facebook, Google Business Profile, Snapchat and WhatsApp are not accepted here: their account identity is a destination chosen after OAuth, which this single-shot exchange cannot do. Connect them through the redirect flow from `GET /v1/connect/{platform}`, or, for WhatsApp Embedded Signup, through `POST /v1/connect/whatsapp/embedded-signup`.
pub async fn handle_o_auth_callback(
configuration: &configuration::Configuration,
platform: &str,
handle_o_auth_callback_request: models::HandleOAuthCallbackRequest,
) -> Result<(), Error<HandleOAuthCallbackError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_platform = platform;
let p_body_handle_o_auth_callback_request = handle_o_auth_callback_request;
let uri_str = format!(
"{}/v1/connect/{platform}",
configuration.base_path,
platform = crate::apis::urlencode(p_path_platform)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_handle_o_auth_callback_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<HandleOAuthCallbackError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Connect a Telegram channel/group directly using the chat ID. Alternative to the access code flow. The bot must already be an admin in the channel/group.
pub async fn initiate_telegram_connect(
configuration: &configuration::Configuration,
initiate_telegram_connect_request: models::InitiateTelegramConnectRequest,
) -> Result<models::InitiateTelegramConnect200Response, Error<InitiateTelegramConnectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_initiate_telegram_connect_request = initiate_telegram_connect_request;
let uri_str = format!("{}/v1/connect/telegram", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_initiate_telegram_connect_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitiateTelegramConnect200Response`"))),
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::InitiateTelegramConnect200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InitiateTelegramConnectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns Facebook Pages after OAuth. Classic connections require profileId and tempToken from the OAuth redirect. Use X-Connect-Token for headless connections. The dashboard business-login picker instead sends only selectionToken, an encrypted grant valid for ten minutes. This requires the initiating user and current profile access and returns only Page IDs and names. X-Connect-Token cannot authorize business selection.
pub async fn list_facebook_pages(
configuration: &configuration::Configuration,
profile_id: Option<&str>,
temp_token: Option<&str>,
selection_token: Option<&str>,
) -> Result<models::ListFacebookPages200Response, Error<ListFacebookPagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let p_query_temp_token = temp_token;
let p_query_selection_token = selection_token;
let uri_str = format!(
"{}/v1/connect/facebook/select-page",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_temp_token {
req_builder = req_builder.query(&[("tempToken", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_selection_token {
req_builder = req_builder.query(&[("selectionToken", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListFacebookPages200Response`"))),
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::ListFacebookPages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListFacebookPagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// For headless flows. Returns the list of Google Business Profile locations the user can manage. Use pendingDataToken (from the OAuth callback redirect) to list locations without consuming the token, so it remains available for select-location. Use X-Connect-Token header if connecting via API key.
pub async fn list_google_business_locations(
configuration: &configuration::Configuration,
profile_id: Option<&str>,
pending_data_token: Option<&str>,
temp_token: Option<&str>,
search: Option<&str>,
filter: Option<&str>,
) -> Result<models::ListGoogleBusinessLocations200Response, Error<ListGoogleBusinessLocationsError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let p_query_pending_data_token = pending_data_token;
let p_query_temp_token = temp_token;
let p_query_search = search;
let p_query_filter = filter;
let uri_str = format!(
"{}/v1/connect/googlebusiness/locations",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_pending_data_token {
req_builder = req_builder.query(&[("pendingDataToken", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_temp_token {
req_builder = req_builder.query(&[("tempToken", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListGoogleBusinessLocations200Response`"))),
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::ListGoogleBusinessLocations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListGoogleBusinessLocationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Completes the `loginMethod=facebook_login` Instagram flow, i.e. \"Instagram API with Facebook Login\". After the user authorizes on Facebook, extract `tempToken` from the redirect params (headless mode adds `step=select_account`) and pass it here to list the Facebook Pages they manage. Only Pages that have a linked Instagram professional account are returned, so an empty array means the user has no eligible Page. Use the X-Connect-Token header if connecting via API key. Not used by the default `instagram_login` flow, which creates the account without a selection step.
pub async fn list_instagram_pages(
configuration: &configuration::Configuration,
profile_id: &str,
temp_token: &str,
) -> Result<models::ListInstagramPages200Response, Error<ListInstagramPagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let p_query_temp_token = temp_token;
let uri_str = format!(
"{}/v1/connect/instagram/select-account",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
req_builder = req_builder.query(&[("tempToken", &p_query_temp_token.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListInstagramPages200Response`"))),
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::ListInstagramPages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListInstagramPagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Fetch full LinkedIn organization details (logos, vanity names, websites) for custom UI. No authentication required, only the tempToken from OAuth.
pub async fn list_linked_in_organizations(
configuration: &configuration::Configuration,
temp_token: &str,
org_ids: &str,
) -> Result<models::ListLinkedInOrganizations200Response, Error<ListLinkedInOrganizationsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_temp_token = temp_token;
let p_query_org_ids = org_ids;
let uri_str = format!(
"{}/v1/connect/linkedin/organizations",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("tempToken", &p_query_temp_token.to_string())]);
req_builder = req_builder.query(&[("orgIds", &p_query_org_ids.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListLinkedInOrganizations200Response`"))),
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::ListLinkedInOrganizations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListLinkedInOrganizationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// For headless flows. Returns Pinterest boards the user can post to. Use X-Connect-Token from the redirect URL.
pub async fn list_pinterest_boards_for_selection(
configuration: &configuration::Configuration,
x_connect_token: &str,
profile_id: &str,
temp_token: &str,
) -> Result<
models::ListPinterestBoardsForSelection200Response,
Error<ListPinterestBoardsForSelectionError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_header_x_connect_token = x_connect_token;
let p_query_profile_id = profile_id;
let p_query_temp_token = temp_token;
let uri_str = format!(
"{}/v1/connect/pinterest/select-board",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
req_builder = req_builder.query(&[("tempToken", &p_query_temp_token.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.header("X-Connect-Token", p_header_x_connect_token.to_string());
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListPinterestBoardsForSelection200Response`"))),
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::ListPinterestBoardsForSelection200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListPinterestBoardsForSelectionError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Serves the channel picker of the Slack connect flow. Slack's OAuth installs the bot into a workspace, not a channel, so after the redirect the caller lists the workspace's channels here and finalizes one with `POST /v1/connect/slack`. Served by a dedicated route that shadows `GET /v1/connect/{platform}` for `slack`. Send exactly one of `pendingDataToken` (first connect: the nonce from the OAuth redirect, bound to the same `profileId`) or `accountId` (add another channel to a workspace already connected: the existing Slack account's workspace token is reused, no re-OAuth). With neither, the endpoint behaves like `GET /v1/connect/{platform}` and returns `authUrl` and `state` to start the OAuth flow. Channels are read live from Slack (`conversations.list`, public and private, archived excluded, up to 2,000). `isMember` says whether the Zernio bot is already in the channel: a public channel is joined automatically on finalize, a private one must be invited (`/invite @Zernio`) first.
pub async fn list_slack_channels(
configuration: &configuration::Configuration,
profile_id: &str,
pending_data_token: Option<&str>,
account_id: Option<&str>,
redirect_url: Option<&str>,
) -> Result<models::ListSlackChannels200Response, Error<ListSlackChannelsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let p_query_pending_data_token = pending_data_token;
let p_query_account_id = account_id;
let p_query_redirect_url = redirect_url;
let uri_str = format!("{}/v1/connect/slack", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
if let Some(ref param_value) = p_query_pending_data_token {
req_builder = req_builder.query(&[("pendingDataToken", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_redirect_url {
req_builder = req_builder.query(&[("redirect_url", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListSlackChannels200Response`"))),
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::ListSlackChannels200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListSlackChannelsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// For headless flows. Returns Snapchat Public Profiles the user can post to. Use X-Connect-Token from the redirect URL.
pub async fn list_snapchat_profiles(
configuration: &configuration::Configuration,
x_connect_token: &str,
profile_id: &str,
temp_token: &str,
) -> Result<models::ListSnapchatProfiles200Response, Error<ListSnapchatProfilesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_header_x_connect_token = x_connect_token;
let p_query_profile_id = profile_id;
let p_query_temp_token = temp_token;
let uri_str = format!(
"{}/v1/connect/snapchat/select-profile",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
req_builder = req_builder.query(&[("tempToken", &p_query_temp_token.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.header("X-Connect-Token", p_header_x_connect_token.to_string());
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListSnapchatProfiles200Response`"))),
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::ListSnapchatProfiles200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListSnapchatProfilesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Fetch the WhatsApp phone numbers available across the user's WhatsApp Business Accounts (WABAs) after a headless OAuth flow. WhatsApp OAuth grants access at the WABA level. When a connected WABA has 2 or more phone numbers, you must call this endpoint to list them and then `POST /v1/connect/whatsapp/select-phone-number` to bind one to the Zernio profile. Single-phone WABAs auto-complete during the OAuth callback and never reach this endpoint. Use the `profileId` and `tempToken` returned in the headless redirect (`step=select_phone_number`). Alternative: if you already know `wabaId` and `phoneNumberId` (e.g. from Meta Business Suite), use `connectWhatsAppCredentials` instead, which skips this two-step flow.
pub async fn list_whats_app_phone_numbers(
configuration: &configuration::Configuration,
profile_id: &str,
temp_token: &str,
x_connect_token: Option<&str>,
) -> Result<models::ListWhatsAppPhoneNumbers200Response, Error<ListWhatsAppPhoneNumbersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_profile_id = profile_id;
let p_query_temp_token = temp_token;
let p_header_x_connect_token = x_connect_token;
let uri_str = format!(
"{}/v1/connect/whatsapp/select-phone-number",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("profileId", &p_query_profile_id.to_string())]);
req_builder = req_builder.query(&[("tempToken", &p_query_temp_token.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_connect_token {
req_builder = req_builder.header("X-Connect-Token", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListWhatsAppPhoneNumbers200Response`"))),
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::ListWhatsAppPhoneNumbers200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListWhatsAppPhoneNumbersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Re-sends the full field set to Meta and returns the subscription read back afterwards. Meta only honours the field set sent at subscribe time, so a Page connected before a field existed stays without it until this runs. The response reflects what Meta actually granted, not what was requested.
pub async fn resync_page_webhook_subscription(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<
models::ResyncPageWebhookSubscription200Response,
Error<ResyncPageWebhookSubscriptionError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/webhook-subscription",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResyncPageWebhookSubscription200Response`"))),
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::ResyncPageWebhookSubscription200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ResyncPageWebhookSubscriptionError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Complete a classic Facebook Page connection with profileId, pageId, tempToken and userProfile. Use X-Connect-Token for headless connections. The dashboard business-login picker instead sends only selectionToken and pageId to complete a Meta Ads connection. The server verifies the initiating user, profile access, current grants and connection eligibility. The profile, platform token, ad-account scope and return URL come only from the encrypted grant. Business selection requires a session or bearer authentication for the initiating user; X-Connect-Token is not accepted. It returns redirect_url with connected=metaads on success or an eligibility error redirect.
pub async fn select_facebook_page(
configuration: &configuration::Configuration,
select_facebook_page_request: models::SelectFacebookPageRequest,
) -> Result<models::SelectFacebookPage200Response, Error<SelectFacebookPageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_select_facebook_page_request = select_facebook_page_request;
let uri_str = format!(
"{}/v1/connect/facebook/select-page",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_select_facebook_page_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SelectFacebookPage200Response`"))),
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::SelectFacebookPage200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SelectFacebookPageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Complete the headless Google Business Profile flow by saving the user's selected location. The pendingDataToken is returned in your redirect URL after OAuth completes (step=select_location). Tokens and profile data are stored server-side, so only the pendingDataToken is needed here. Use X-Connect-Token header if connecting via API key.
pub async fn select_google_business_location(
configuration: &configuration::Configuration,
select_google_business_location_request: models::SelectGoogleBusinessLocationRequest,
) -> Result<models::SelectGoogleBusinessLocation200Response, Error<SelectGoogleBusinessLocationError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_body_select_google_business_location_request = select_google_business_location_request;
let uri_str = format!(
"{}/v1/connect/googlebusiness/select-location",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_select_google_business_location_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SelectGoogleBusinessLocation200Response`"))),
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::SelectGoogleBusinessLocation200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SelectGoogleBusinessLocationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Saves the selected Page as an Instagram account connected via Facebook Login. The Page access token becomes the account's access token, so every Instagram call for it runs against the Facebook Graph host. One Instagram account per profile: if the profile already has an Instagram account, this replaces it, and picking a different Instagram identity purges the previous account's conversations, external posts and stats.
pub async fn select_instagram_account(
configuration: &configuration::Configuration,
select_instagram_account_request: models::SelectInstagramAccountRequest,
) -> Result<models::SelectInstagramAccount200Response, Error<SelectInstagramAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_select_instagram_account_request = select_instagram_account_request;
let uri_str = format!(
"{}/v1/connect/instagram/select-account",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("X-Connect-Token", value);
};
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_select_instagram_account_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SelectInstagramAccount200Response`"))),
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::SelectInstagramAccount200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SelectInstagramAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Complete the LinkedIn connection flow. Set accountType to \"personal\" or \"organization\" to connect as a company page. Use X-Connect-Token if connecting via API key.
pub async fn select_linked_in_organization(
configuration: &configuration::Configuration,
select_linked_in_organization_request: models::SelectLinkedInOrganizationRequest,
) -> Result<models::SelectLinkedInOrganization200Response, Error<SelectLinkedInOrganizationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_select_linked_in_organization_request = select_linked_in_organization_request;
let uri_str = format!(
"{}/v1/connect/linkedin/select-organization",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_select_linked_in_organization_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SelectLinkedInOrganization200Response`"))),
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::SelectLinkedInOrganization200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SelectLinkedInOrganizationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Complete the Pinterest connection flow. After OAuth, use this endpoint to save the selected board and complete the account connection. Use the X-Connect-Token header if you initiated the connection via API key.
pub async fn select_pinterest_board(
configuration: &configuration::Configuration,
select_pinterest_board_request: models::SelectPinterestBoardRequest,
) -> Result<models::SelectPinterestBoard200Response, Error<SelectPinterestBoardError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_select_pinterest_board_request = select_pinterest_board_request;
let uri_str = format!(
"{}/v1/connect/pinterest/select-board",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_select_pinterest_board_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SelectPinterestBoard200Response`"))),
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::SelectPinterestBoard200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SelectPinterestBoardError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Complete the Snapchat connection flow by saving the selected Public Profile. Snapchat requires a Public Profile to publish content. Use X-Connect-Token if connecting via API key.
pub async fn select_snapchat_profile(
configuration: &configuration::Configuration,
select_snapchat_profile_request: models::SelectSnapchatProfileRequest,
x_connect_token: Option<&str>,
) -> Result<models::SelectSnapchatProfile200Response, Error<SelectSnapchatProfileError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_select_snapchat_profile_request = select_snapchat_profile_request;
let p_header_x_connect_token = x_connect_token;
let uri_str = format!(
"{}/v1/connect/snapchat/select-profile",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_connect_token {
req_builder = req_builder.header("X-Connect-Token", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_select_snapchat_profile_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SelectSnapchatProfile200Response`"))),
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::SelectSnapchatProfile200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SelectSnapchatProfileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Applies a flair to a post the connected account already published. Use the GET on this path to list the available `flairTemplateId` values for the subreddit. Flair can also be set at submit time by passing `flairId` in `platformSpecificData` when creating the post. This endpoint is for changing it afterwards. The subreddit must allow users to select their own post flair. Setting flair on another user's post requires moderator permissions, which Zernio does not request.
pub async fn set_reddit_post_flair(
configuration: &configuration::Configuration,
account_id: &str,
set_reddit_post_flair_request: models::SetRedditPostFlairRequest,
) -> Result<models::UpdateYoutubeDefaultPlaylist200Response, Error<SetRedditPostFlairError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_set_reddit_post_flair_request = set_reddit_post_flair_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/reddit-flairs",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_set_reddit_post_flair_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateYoutubeDefaultPlaylist200Response`"))),
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::UpdateYoutubeDefaultPlaylist200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetRedditPostFlairError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Switch which Facebook Page is active for a connected account.
pub async fn update_facebook_page(
configuration: &configuration::Configuration,
account_id: &str,
update_facebook_page_request: models::UpdateFacebookPageRequest,
) -> Result<models::UpdateFacebookPage200Response, Error<UpdateFacebookPageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_update_facebook_page_request = update_facebook_page_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/facebook-page",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_facebook_page_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateFacebookPage200Response`"))),
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::UpdateFacebookPage200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateFacebookPageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Switch which Google Business Profile location is active for a connected account.
pub async fn update_gmb_location(
configuration: &configuration::Configuration,
account_id: &str,
update_gmb_location_request: models::UpdateGmbLocationRequest,
) -> Result<models::UpdateGmbLocation200Response, Error<UpdateGmbLocationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_update_gmb_location_request = update_gmb_location_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/gmb-locations",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_gmb_location_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateGmbLocation200Response`"))),
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::UpdateGmbLocation200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateGmbLocationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Switch a LinkedIn account between personal profile and organization (company page) posting.
pub async fn update_linked_in_organization(
configuration: &configuration::Configuration,
account_id: &str,
update_linked_in_organization_request: models::UpdateLinkedInOrganizationRequest,
) -> Result<models::UpdateLinkedInOrganization200Response, Error<UpdateLinkedInOrganizationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_update_linked_in_organization_request = update_linked_in_organization_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/linkedin-organization",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_linked_in_organization_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateLinkedInOrganization200Response`"))),
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::UpdateLinkedInOrganization200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateLinkedInOrganizationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sets the default board used when publishing pins for this account.
pub async fn update_pinterest_boards(
configuration: &configuration::Configuration,
account_id: &str,
update_pinterest_boards_request: models::UpdatePinterestBoardsRequest,
) -> Result<models::ConnectBlueskyCredentials200Response, Error<UpdatePinterestBoardsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_update_pinterest_boards_request = update_pinterest_boards_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/pinterest-boards",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_pinterest_boards_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectBlueskyCredentials200Response`"))),
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::ConnectBlueskyCredentials200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdatePinterestBoardsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sets the default subreddit used when publishing posts for this Reddit account.
pub async fn update_reddit_subreddits(
configuration: &configuration::Configuration,
account_id: &str,
update_reddit_subreddits_request: models::UpdateRedditSubredditsRequest,
) -> Result<models::UpdateYoutubeDefaultPlaylist200Response, Error<UpdateRedditSubredditsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_update_reddit_subreddits_request = update_reddit_subreddits_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/reddit-subreddits",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_reddit_subreddits_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateYoutubeDefaultPlaylist200Response`"))),
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::UpdateYoutubeDefaultPlaylist200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateRedditSubredditsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sets the default playlist used when publishing videos for this account. When a post does not specify a playlistId, the default playlist is not automatically used (it is stored for client-side convenience).
pub async fn update_youtube_default_playlist(
configuration: &configuration::Configuration,
account_id: &str,
update_youtube_default_playlist_request: models::UpdateYoutubeDefaultPlaylistRequest,
) -> Result<models::UpdateYoutubeDefaultPlaylist200Response, Error<UpdateYoutubeDefaultPlaylistError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_update_youtube_default_playlist_request = update_youtube_default_playlist_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/youtube-playlists",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_youtube_default_playlist_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateYoutubeDefaultPlaylist200Response`"))),
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::UpdateYoutubeDefaultPlaylist200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateYoutubeDefaultPlaylistError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Cast, change, or clear the connected account's vote on a Reddit post or comment. **Reddit requires that votes be cast by humans.** Reddit's API terms permit a client to proxy a human's action one-for-one, and prohibit a bot from deciding how to vote or from amplifying a human's vote. Call this endpoint only in direct response to an explicit action by the account owner. Automated or agent-decided voting is vote manipulation and puts API access at risk.
pub async fn vote_reddit_thing(
configuration: &configuration::Configuration,
account_id: &str,
vote_reddit_thing_request: models::VoteRedditThingRequest,
) -> Result<models::UpdateYoutubeDefaultPlaylist200Response, Error<VoteRedditThingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_vote_reddit_thing_request = vote_reddit_thing_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/reddit-vote",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_vote_reddit_thing_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateYoutubeDefaultPlaylist200Response`"))),
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::UpdateYoutubeDefaultPlaylist200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<VoteRedditThingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}