/*
* 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).
*
* The version of the OpenAPI document: 1.53.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 [`add_business_agent_allowlist_entry`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddBusinessAgentAllowlistEntryError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`add_business_agent_website`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddBusinessAgentWebsiteError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_business_agent_connector`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBusinessAgentConnectorError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_business_agent_connector_tool`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBusinessAgentConnectorToolError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_business_agent_faq`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBusinessAgentFaqError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_business_agent_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBusinessAgentSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_business_agent_ui_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBusinessAgentUiSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_business_agent_connector`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBusinessAgentConnectorError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_business_agent_connector_tool`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBusinessAgentConnectorToolError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_business_agent_faq`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBusinessAgentFaqError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_business_agent_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBusinessAgentFileError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_business_agent_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBusinessAgentSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_business_agent_ui_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBusinessAgentUiSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_business_agent_website`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBusinessAgentWebsiteError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentBudgetError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_business_information`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentBusinessInformationError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_connector`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentConnectorError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_connector_logs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentConnectorLogsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_connector_tool`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentConnectorToolError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentEventError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_faq`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentFaqError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentFileError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentStatusError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_ui_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentUiSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_business_agent_website`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBusinessAgentWebsiteError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_allowlist`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentAllowlistError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_connector_tools`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentConnectorToolsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_connectors`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentConnectorsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_faqs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentFaqsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_files`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentFilesError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentSettingsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_skills`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentSkillsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_ui_skills`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentUiSkillsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_business_agent_websites`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBusinessAgentWebsitesError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`onboard_business_agent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OnboardBusinessAgentError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`read_business_agent_evals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReadBusinessAgentEvalsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`refresh_business_agent_connector_tools`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RefreshBusinessAgentConnectorToolsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_business_agent_allowlist_entry`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveBusinessAgentAllowlistEntryError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`replace_business_agent_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplaceBusinessAgentBudgetError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`replace_business_agent_business_information`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplaceBusinessAgentBusinessInformationError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reset_business_agent_business_information`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResetBusinessAgentBusinessInformationError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`run_business_agent_connector_tool`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RunBusinessAgentConnectorToolError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_business_agent_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendBusinessAgentEventError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_business_agent_test_message`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendBusinessAgentTestMessageError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_business_agent_connector_credentials`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetBusinessAgentConnectorCredentialsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`start_business_agent_eval_run`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StartBusinessAgentEvalRunError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_business_agent_connector`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBusinessAgentConnectorError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_business_agent_connector_tool`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBusinessAgentConnectorToolError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_business_agent_faq`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBusinessAgentFaqError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_business_agent_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBusinessAgentSettingsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_business_agent_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBusinessAgentSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_business_agent_ui_skill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBusinessAgentUiSkillError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_business_agent_website`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBusinessAgentWebsiteError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`upload_business_agent_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UploadBusinessAgentFileError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status413(),
UnknownValue(serde_json::Value),
}
/// One E.164 number per call. Not idempotent.
pub async fn add_business_agent_allowlist_entry(
configuration: &configuration::Configuration,
account_id: &str,
add_business_agent_allowlist_entry_request: models::AddBusinessAgentAllowlistEntryRequest,
) -> Result<models::BusinessAgentAllowlistEntry, Error<AddBusinessAgentAllowlistEntryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_add_business_agent_allowlist_entry_request =
add_business_agent_allowlist_entry_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/allowlist",
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_add_business_agent_allowlist_entry_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::BusinessAgentAllowlistEntry`"))),
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::BusinessAgentAllowlistEntry`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddBusinessAgentAllowlistEntryError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Meta crawls the site into the agent knowledge and recrawls it periodically; check `crawl_status` and `crawl_error` on read. Not idempotent.
pub async fn add_business_agent_website(
configuration: &configuration::Configuration,
account_id: &str,
business_agent_website_input: models::BusinessAgentWebsiteInput,
) -> Result<models::BusinessAgentWebsite, Error<AddBusinessAgentWebsiteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_business_agent_website_input = business_agent_website_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/websites",
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_business_agent_website_input);
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::BusinessAgentWebsite`"))),
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::BusinessAgentWebsite`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddBusinessAgentWebsiteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Base URL plus how to authenticate (OAuth client credentials, API key or none). Names are unique per number. Not idempotent.
pub async fn create_business_agent_connector(
configuration: &configuration::Configuration,
account_id: &str,
business_agent_connector_input: models::BusinessAgentConnectorInput,
) -> Result<models::BusinessAgentConnector, Error<CreateBusinessAgentConnectorError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_business_agent_connector_input = business_agent_connector_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors",
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_business_agent_connector_input);
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::BusinessAgentConnector`"))),
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::BusinessAgentConnector`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBusinessAgentConnectorError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One operation on the connector, with the request definition Meta uses to build the outbound call from the conversation. Type the body params explicitly. Not idempotent.
pub async fn create_business_agent_connector_tool(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
business_agent_connector_tool_input: models::BusinessAgentConnectorToolInput,
) -> Result<models::BusinessAgentConnectorTool, Error<CreateBusinessAgentConnectorToolError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_body_business_agent_connector_tool_input = business_agent_connector_tool_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/tools",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_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_business_agent_connector_tool_input);
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::BusinessAgentConnectorTool`"))),
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::BusinessAgentConnectorTool`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBusinessAgentConnectorToolError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One specific question per entry; beyond a few hundred entries retrieval quality drops. Not idempotent.
pub async fn create_business_agent_faq(
configuration: &configuration::Configuration,
account_id: &str,
business_agent_faq_input: models::BusinessAgentFaqInput,
) -> Result<models::BusinessAgentFaq, Error<CreateBusinessAgentFaqError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_business_agent_faq_input = business_agent_faq_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/faqs",
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_business_agent_faq_input);
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::BusinessAgentFaq`"))),
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::BusinessAgentFaq`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBusinessAgentFaqError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Behavioral instructions in the brand voice. Reads back `pending_review` until Meta content review passes it. Not idempotent.
pub async fn create_business_agent_skill(
configuration: &configuration::Configuration,
account_id: &str,
business_agent_skill_input: models::BusinessAgentSkillInput,
) -> Result<models::BusinessAgentSkill, Error<CreateBusinessAgentSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_business_agent_skill_input = business_agent_skill_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/skills",
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_business_agent_skill_input);
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::BusinessAgentSkill`"))),
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::BusinessAgentSkill`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBusinessAgentSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Tells the agent when to send a rich component (CTA URL button, image, carousel, list, reply buttons, location, Flow) and what to put in it. Not idempotent.
pub async fn create_business_agent_ui_skill(
configuration: &configuration::Configuration,
account_id: &str,
business_agent_ui_skill_input: models::BusinessAgentUiSkillInput,
) -> Result<models::BusinessAgentUiSkill, Error<CreateBusinessAgentUiSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_business_agent_ui_skill_input = business_agent_ui_skill_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/ui-skills",
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_business_agent_ui_skill_input);
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::BusinessAgentUiSkill`"))),
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::BusinessAgentUiSkill`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBusinessAgentUiSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_business_agent_connector(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
) -> Result<models::InlineObject, Error<DeleteBusinessAgentConnectorError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBusinessAgentConnectorError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_business_agent_connector_tool(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
tool_id: &str,
) -> Result<models::InlineObject, Error<DeleteBusinessAgentConnectorToolError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_path_tool_id = tool_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/tools/{toolId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_id),
toolId = crate::apis::urlencode(p_path_tool_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBusinessAgentConnectorToolError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_business_agent_faq(
configuration: &configuration::Configuration,
account_id: &str,
faq_id: &str,
) -> Result<models::InlineObject, Error<DeleteBusinessAgentFaqError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_faq_id = faq_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/faqs/{faqId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
faqId = crate::apis::urlencode(p_path_faq_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBusinessAgentFaqError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_business_agent_file(
configuration: &configuration::Configuration,
account_id: &str,
file_id: &str,
) -> Result<models::InlineObject, Error<DeleteBusinessAgentFileError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_file_id = file_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/files/{fileId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
fileId = crate::apis::urlencode(p_path_file_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBusinessAgentFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_business_agent_skill(
configuration: &configuration::Configuration,
account_id: &str,
skill_id: &str,
) -> Result<models::InlineObject, Error<DeleteBusinessAgentSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_skill_id = skill_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/skills/{skillId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
skillId = crate::apis::urlencode(p_path_skill_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBusinessAgentSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_business_agent_ui_skill(
configuration: &configuration::Configuration,
account_id: &str,
ui_skill_id: &str,
) -> Result<models::InlineObject, Error<DeleteBusinessAgentUiSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_ui_skill_id = ui_skill_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/ui-skills/{uiSkillId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
uiSkillId = crate::apis::urlencode(p_path_ui_skill_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBusinessAgentUiSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_business_agent_website(
configuration: &configuration::Configuration,
account_id: &str,
website_id: &str,
) -> Result<models::InlineObject, Error<DeleteBusinessAgentWebsiteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_website_id = website_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/websites/{websiteId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
websiteId = crate::apis::urlencode(p_path_website_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBusinessAgentWebsiteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Caps over rolling windows for the Business Manager that owns the number. An empty list means unlimited.
pub async fn get_business_agent_budget(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::GetBusinessAgentBudget200Response, Error<GetBusinessAgentBudgetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/budget",
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::GetBusinessAgentBudget200Response`"))),
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::GetBusinessAgentBudget200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentBudgetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Payment methods, return policy, how to buy, shipping, description and contact details the agent answers from. Empty values until configured.
pub async fn get_business_agent_business_information(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::BusinessAgentBusinessInformation, Error<GetBusinessAgentBusinessInformationError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/business-information",
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::BusinessAgentBusinessInformation`"))),
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::BusinessAgentBusinessInformation`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentBusinessInformationError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_connector(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
) -> Result<models::BusinessAgentConnector, Error<GetBusinessAgentConnectorError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_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::BusinessAgentConnector`"))),
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::BusinessAgentConnector`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentConnectorError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Third-party failures over the last 7 days (window at most 7 days, default the last 24 hours). Each entry carries `failure_code_name` and `error_message`.
pub async fn get_business_agent_connector_logs(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
start_time: Option<i32>,
end_time: Option<i32>,
limit: Option<i32>,
tool_id: Option<&str>,
include_stats: Option<bool>,
summary_only: Option<bool>,
top_n: Option<i32>,
) -> Result<
models::GetBusinessAgentConnectorLogs200Response,
Error<GetBusinessAgentConnectorLogsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_query_start_time = start_time;
let p_query_end_time = end_time;
let p_query_limit = limit;
let p_query_tool_id = tool_id;
let p_query_include_stats = include_stats;
let p_query_summary_only = summary_only;
let p_query_top_n = top_n;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/logs",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_start_time {
req_builder = req_builder.query(&[("startTime", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_end_time {
req_builder = req_builder.query(&[("endTime", ¶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 param_value) = p_query_tool_id {
req_builder = req_builder.query(&[("toolId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_stats {
req_builder = req_builder.query(&[("includeStats", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_summary_only {
req_builder = req_builder.query(&[("summaryOnly", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_top_n {
req_builder = req_builder.query(&[("topN", ¶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::GetBusinessAgentConnectorLogs200Response`"))),
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::GetBusinessAgentConnectorLogs200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentConnectorLogsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_connector_tool(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
tool_id: &str,
) -> Result<models::BusinessAgentConnectorTool, Error<GetBusinessAgentConnectorToolError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_path_tool_id = tool_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/tools/{toolId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_id),
toolId = crate::apis::urlencode(p_path_tool_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::BusinessAgentConnectorTool`"))),
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::BusinessAgentConnectorTool`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentConnectorToolError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_event(
configuration: &configuration::Configuration,
account_id: &str,
event_id: &str,
) -> Result<models::BusinessAgentEventStatus, Error<GetBusinessAgentEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_event_id = event_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/events/{eventId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
eventId = crate::apis::urlencode(p_path_event_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::BusinessAgentEventStatus`"))),
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::BusinessAgentEventStatus`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_faq(
configuration: &configuration::Configuration,
account_id: &str,
faq_id: &str,
) -> Result<models::BusinessAgentFaq, Error<GetBusinessAgentFaqError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_faq_id = faq_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/faqs/{faqId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
faqId = crate::apis::urlencode(p_path_faq_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::BusinessAgentFaq`"))),
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::BusinessAgentFaq`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentFaqError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_file(
configuration: &configuration::Configuration,
account_id: &str,
file_id: &str,
) -> Result<models::BusinessAgentKnowledgeFile, Error<GetBusinessAgentFileError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_file_id = file_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/files/{fileId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
fileId = crate::apis::urlencode(p_path_file_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::BusinessAgentKnowledgeFile`"))),
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::BusinessAgentKnowledgeFile`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_skill(
configuration: &configuration::Configuration,
account_id: &str,
skill_id: &str,
) -> Result<models::BusinessAgentSkill, Error<GetBusinessAgentSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_skill_id = skill_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/skills/{skillId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
skillId = crate::apis::urlencode(p_path_skill_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::BusinessAgentSkill`"))),
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::BusinessAgentSkill`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One read that says where the merchant is: whether the number is eligible, whether the Meta Business Agent terms are accepted, whether an agent exists, whether it is on, and its settings. `manualSteps` lists what Zernio can verify is still pending (accepting the terms in WhatsApp Manager); `unverifiedSteps` lists what Meta exposes no state for (the payment method in Billing Hub). Never fails for those pre-setup states; it reports them as flags.
pub async fn get_business_agent_status(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::BusinessAgentStatus, Error<GetBusinessAgentStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent",
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::BusinessAgentStatus`"))),
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::BusinessAgentStatus`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_ui_skill(
configuration: &configuration::Configuration,
account_id: &str,
ui_skill_id: &str,
) -> Result<models::BusinessAgentUiSkill, Error<GetBusinessAgentUiSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_ui_skill_id = ui_skill_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/ui-skills/{uiSkillId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
uiSkillId = crate::apis::urlencode(p_path_ui_skill_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::BusinessAgentUiSkill`"))),
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::BusinessAgentUiSkill`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentUiSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_business_agent_website(
configuration: &configuration::Configuration,
account_id: &str,
website_id: &str,
) -> Result<models::BusinessAgentWebsite, Error<GetBusinessAgentWebsiteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_website_id = website_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/websites/{websiteId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
websiteId = crate::apis::urlencode(p_path_website_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::BusinessAgentWebsite`"))),
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::BusinessAgentWebsite`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBusinessAgentWebsiteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Consumers the agent answers while `ai_audience` is ALLOWLISTED_ONLY.
pub async fn list_business_agent_allowlist(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListBusinessAgentAllowlist200Response, Error<ListBusinessAgentAllowlistError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/allowlist",
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::ListBusinessAgentAllowlist200Response`"))),
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::ListBusinessAgentAllowlist200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentAllowlistError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_business_agent_connector_tools(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
) -> Result<
models::ListBusinessAgentConnectorTools200Response,
Error<ListBusinessAgentConnectorToolsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/tools",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_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::ListBusinessAgentConnectorTools200Response`"))),
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::ListBusinessAgentConnectorTools200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentConnectorToolsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// External APIs the agent may call. `connection_status` says whether Meta can currently reach each one.
pub async fn list_business_agent_connectors(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListBusinessAgentConnectors200Response, Error<ListBusinessAgentConnectorsError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors",
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::ListBusinessAgentConnectors200Response`"))),
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::ListBusinessAgentConnectors200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentConnectorsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_business_agent_faqs(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListBusinessAgentFaqs200Response, Error<ListBusinessAgentFaqsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/faqs",
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::ListBusinessAgentFaqs200Response`"))),
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::ListBusinessAgentFaqs200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentFaqsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_business_agent_files(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListBusinessAgentFiles200Response, Error<ListBusinessAgentFilesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/files",
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::ListBusinessAgentFiles200Response`"))),
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::ListBusinessAgentFiles200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentFilesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Settings of every agent configured on the number (normally one). Pass `agentId` to read one.
pub async fn list_business_agent_settings(
configuration: &configuration::Configuration,
account_id: &str,
agent_id: Option<&str>,
) -> Result<models::ListBusinessAgentSettings200Response, Error<ListBusinessAgentSettingsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_query_agent_id = agent_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/settings",
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_agent_id {
req_builder = req_builder.query(&[("agentId", ¶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::ListBusinessAgentSettings200Response`"))),
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::ListBusinessAgentSettings200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentSettingsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_business_agent_skills(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListBusinessAgentSkills200Response, Error<ListBusinessAgentSkillsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/skills",
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::ListBusinessAgentSkills200Response`"))),
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::ListBusinessAgentSkills200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentSkillsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Cursor paged; follow `paging.cursors.after` until `paging.next` is absent.
pub async fn list_business_agent_ui_skills(
configuration: &configuration::Configuration,
account_id: &str,
before: Option<&str>,
after: Option<&str>,
limit: Option<i32>,
) -> Result<models::ListBusinessAgentUiSkills200Response, Error<ListBusinessAgentUiSkillsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_query_before = before;
let p_query_after = after;
let p_query_limit = limit;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/ui-skills",
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_before {
req_builder = req_builder.query(&[("before", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_after {
req_builder = req_builder.query(&[("after", ¶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::ListBusinessAgentUiSkills200Response`"))),
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::ListBusinessAgentUiSkills200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentUiSkillsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_business_agent_websites(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListBusinessAgentWebsites200Response, Error<ListBusinessAgentWebsitesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/websites",
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::ListBusinessAgentWebsites200Response`"))),
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::ListBusinessAgentWebsites200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBusinessAgentWebsitesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates the Meta Business Agent on the number and schedules Meta's data preparation. Requires the terms to be accepted; eligibility is checked first and an ineligible number answers 403 `business_agent_not_eligible`. Not idempotent: call it once, then configure knowledge and skills, then enable it through the settings. Configuration calls made in the first minute can still answer `business_agent_not_found` while Meta prepares the workspace.
pub async fn onboard_business_agent(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::OnboardBusinessAgent201Response, Error<OnboardBusinessAgentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/onboard",
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::OnboardBusinessAgent201Response`"))),
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::OnboardBusinessAgent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<OnboardBusinessAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Without query parameters, lists the evaluation scenarios (`eval_cases`). With `jobId`, polls a run started with POST. With `summaryIds`, returns the aggregated insight reports. With `evalIds`, returns per-conversation evaluation details. One of the three at a time.
pub async fn read_business_agent_evals(
configuration: &configuration::Configuration,
account_id: &str,
job_id: Option<&str>,
summary_ids: Option<&str>,
eval_ids: Option<&str>,
) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ReadBusinessAgentEvalsError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_query_job_id = job_id;
let p_query_summary_ids = summary_ids;
let p_query_eval_ids = eval_ids;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/evals",
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_job_id {
req_builder = req_builder.query(&[("jobId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_summary_ids {
req_builder = req_builder.query(&[("summaryIds", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_eval_ids {
req_builder = req_builder.query(&[("evalIds", ¶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 `std::collections::HashMap<String, serde_json::Value>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReadBusinessAgentEvalsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Re-discovers the tools of an MCP connector. A failed discovery keeps the previous tool set and reports an ERROR sync status inside a 200.
pub async fn refresh_business_agent_connector_tools(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
) -> Result<models::BusinessAgentConnector, Error<RefreshBusinessAgentConnectorToolsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/refresh-tools",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_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::BusinessAgentConnector`"))),
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::BusinessAgentConnector`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RefreshBusinessAgentConnectorToolsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn remove_business_agent_allowlist_entry(
configuration: &configuration::Configuration,
account_id: &str,
entry_id: &str,
) -> Result<models::InlineObject, Error<RemoveBusinessAgentAllowlistEntryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_entry_id = entry_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/allowlist/{entryId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
entryId = crate::apis::urlencode(p_path_entry_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveBusinessAgentAllowlistEntryError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The full desired set: budgets left out are removed, an empty list returns to unlimited. Pass `budget_id` to edit one in place. When a cap is hit the agent finishes its turn, stops answering and hands the thread to a human until the window rolls over.
pub async fn replace_business_agent_budget(
configuration: &configuration::Configuration,
account_id: &str,
get_business_agent_budget200_response: models::GetBusinessAgentBudget200Response,
) -> Result<models::GetBusinessAgentBudget200Response, Error<ReplaceBusinessAgentBudgetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_get_business_agent_budget200_response = get_business_agent_budget200_response;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/budget",
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_get_business_agent_budget200_response);
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::GetBusinessAgentBudget200Response`"))),
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::GetBusinessAgentBudget200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReplaceBusinessAgentBudgetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Full replacement: every field you send overwrites the stored value; fields you omit are cleared.
pub async fn replace_business_agent_business_information(
configuration: &configuration::Configuration,
account_id: &str,
business_agent_business_information: models::BusinessAgentBusinessInformation,
) -> Result<
models::BusinessAgentBusinessInformation,
Error<ReplaceBusinessAgentBusinessInformationError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_business_agent_business_information = business_agent_business_information;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/business-information",
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_business_agent_business_information);
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::BusinessAgentBusinessInformation`"))),
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::BusinessAgentBusinessInformation`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReplaceBusinessAgentBusinessInformationError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn reset_business_agent_business_information(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::InlineObject, Error<ResetBusinessAgentBusinessInformationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/business-information",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::InlineObject`"))),
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::InlineObject`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ResetBusinessAgentBusinessInformationError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Executes the tool against the merchant API and returns the raw upstream result, to check a connector before the agent relies on it.
pub async fn run_business_agent_connector_tool(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
tool_id: &str,
run_business_agent_connector_tool_request: models::RunBusinessAgentConnectorToolRequest,
) -> Result<
models::RunBusinessAgentConnectorTool200Response,
Error<RunBusinessAgentConnectorToolError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_path_tool_id = tool_id;
let p_body_run_business_agent_connector_tool_request =
run_business_agent_connector_tool_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/tools/{toolId}/run",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_id),
toolId = crate::apis::urlencode(p_path_tool_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_run_business_agent_connector_tool_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::RunBusinessAgentConnectorTool200Response`"))),
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::RunBusinessAgentConnectorTool200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RunBusinessAgentConnectorToolError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Tell the agent something happened in your systems (order shipped, document verified) so it messages the consumer about it. The consumer must already have a conversation with the number. Answers 202 with the event id; poll it for the outcome.
pub async fn send_business_agent_event(
configuration: &configuration::Configuration,
account_id: &str,
send_business_agent_event_request: models::SendBusinessAgentEventRequest,
) -> Result<models::SendBusinessAgentEvent202Response, Error<SendBusinessAgentEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_send_business_agent_event_request = send_business_agent_event_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/events",
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_send_business_agent_event_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::SendBusinessAgentEvent202Response`"))),
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::SendBusinessAgentEvent202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendBusinessAgentEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Runs the message through the full agent pipeline in Meta sandbox with no WhatsApp user and no token billing. Pass back `conversationId` to continue a thread. Meta rate-limits it per number per hour.
pub async fn send_business_agent_test_message(
configuration: &configuration::Configuration,
account_id: &str,
send_business_agent_test_message_request: models::SendBusinessAgentTestMessageRequest,
) -> Result<models::BusinessAgentTestMessageResponse, Error<SendBusinessAgentTestMessageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_send_business_agent_test_message_request = send_business_agent_test_message_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/test-messages",
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_send_business_agent_test_message_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::BusinessAgentTestMessageResponse`"))),
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::BusinessAgentTestMessageResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendBusinessAgentTestMessageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Set or rotate the connector's credentials in place: `kind: api_key`, `kind: oauth` (client credentials) or `kind: certificate` (mTLS client certificate). Meta has no call that removes a credential layer; change the connector's `auth_type` or delete it instead.
pub async fn set_business_agent_connector_credentials(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
set_business_agent_connector_credentials_request: models::SetBusinessAgentConnectorCredentialsRequest,
) -> Result<models::BusinessAgentConnector, Error<SetBusinessAgentConnectorCredentialsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_body_set_business_agent_connector_credentials_request =
set_business_agent_connector_credentials_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/credentials",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_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_business_agent_connector_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::BusinessAgentConnector`"))),
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::BusinessAgentConnector`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetBusinessAgentConnectorCredentialsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Simulates the given scenarios against the agent and scores them. Answers 202 with a `job_id` to poll with GET.
pub async fn start_business_agent_eval_run(
configuration: &configuration::Configuration,
account_id: &str,
start_business_agent_eval_run_request: models::StartBusinessAgentEvalRunRequest,
) -> Result<models::StartBusinessAgentEvalRun202Response, Error<StartBusinessAgentEvalRunError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_start_business_agent_eval_run_request = start_business_agent_eval_run_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/evals",
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_start_business_agent_eval_run_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::StartBusinessAgentEvalRun202Response`"))),
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::StartBusinessAgentEvalRun202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<StartBusinessAgentEvalRunError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_business_agent_connector(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
business_agent_connector_input: models::BusinessAgentConnectorInput,
) -> Result<models::BusinessAgentConnector, Error<UpdateBusinessAgentConnectorError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_body_business_agent_connector_input = business_agent_connector_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_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_business_agent_connector_input);
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::BusinessAgentConnector`"))),
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::BusinessAgentConnector`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBusinessAgentConnectorError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_business_agent_connector_tool(
configuration: &configuration::Configuration,
account_id: &str,
connector_id: &str,
tool_id: &str,
business_agent_connector_tool_input: models::BusinessAgentConnectorToolInput,
) -> Result<models::BusinessAgentConnectorTool, Error<UpdateBusinessAgentConnectorToolError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_connector_id = connector_id;
let p_path_tool_id = tool_id;
let p_body_business_agent_connector_tool_input = business_agent_connector_tool_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/connectors/{connectorId}/tools/{toolId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
connectorId = crate::apis::urlencode(p_path_connector_id),
toolId = crate::apis::urlencode(p_path_tool_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_business_agent_connector_tool_input);
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::BusinessAgentConnectorTool`"))),
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::BusinessAgentConnectorTool`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBusinessAgentConnectorToolError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_business_agent_faq(
configuration: &configuration::Configuration,
account_id: &str,
faq_id: &str,
business_agent_faq_input: models::BusinessAgentFaqInput,
) -> Result<models::BusinessAgentFaq, Error<UpdateBusinessAgentFaqError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_faq_id = faq_id;
let p_body_business_agent_faq_input = business_agent_faq_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/faqs/{faqId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
faqId = crate::apis::urlencode(p_path_faq_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_business_agent_faq_input);
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::BusinessAgentFaq`"))),
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::BusinessAgentFaq`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBusinessAgentFaqError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Partial update: fields you omit keep their value. `rollout.enabled: true` turns the agent on for new conversations; `false` stops it on every thread. Turning it on for `EVERYONE` needs a payment method on the Business Agent billable account (Meta accepts the call but delivers nothing without one); `ALLOWLISTED_ONLY` does not, which is how you test with a few numbers before billing. `never_say_phrases` replaces the whole list.
pub async fn update_business_agent_settings(
configuration: &configuration::Configuration,
account_id: &str,
update_business_agent_settings_request: models::UpdateBusinessAgentSettingsRequest,
agent_id: Option<&str>,
) -> Result<models::BusinessAgentSettings, Error<UpdateBusinessAgentSettingsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_update_business_agent_settings_request = update_business_agent_settings_request;
let p_query_agent_id = agent_id;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/settings",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref param_value) = p_query_agent_id {
req_builder = req_builder.query(&[("agentId", ¶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());
};
req_builder = req_builder.json(&p_body_update_business_agent_settings_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::BusinessAgentSettings`"))),
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::BusinessAgentSettings`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBusinessAgentSettingsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_business_agent_skill(
configuration: &configuration::Configuration,
account_id: &str,
skill_id: &str,
business_agent_skill_input: models::BusinessAgentSkillInput,
) -> Result<models::BusinessAgentSkill, Error<UpdateBusinessAgentSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_skill_id = skill_id;
let p_body_business_agent_skill_input = business_agent_skill_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/skills/{skillId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
skillId = crate::apis::urlencode(p_path_skill_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_business_agent_skill_input);
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::BusinessAgentSkill`"))),
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::BusinessAgentSkill`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBusinessAgentSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_business_agent_ui_skill(
configuration: &configuration::Configuration,
account_id: &str,
ui_skill_id: &str,
business_agent_ui_skill_input: models::BusinessAgentUiSkillInput,
) -> Result<models::BusinessAgentUiSkill, Error<UpdateBusinessAgentUiSkillError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_ui_skill_id = ui_skill_id;
let p_body_business_agent_ui_skill_input = business_agent_ui_skill_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/ui-skills/{uiSkillId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
uiSkillId = crate::apis::urlencode(p_path_ui_skill_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_business_agent_ui_skill_input);
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::BusinessAgentUiSkill`"))),
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::BusinessAgentUiSkill`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBusinessAgentUiSkillError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_business_agent_website(
configuration: &configuration::Configuration,
account_id: &str,
website_id: &str,
business_agent_website_input: models::BusinessAgentWebsiteInput,
) -> Result<models::BusinessAgentWebsite, Error<UpdateBusinessAgentWebsiteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_path_website_id = website_id;
let p_body_business_agent_website_input = business_agent_website_input;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/websites/{websiteId}",
configuration.base_path,
accountId = crate::apis::urlencode(p_path_account_id),
websiteId = crate::apis::urlencode(p_path_website_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_business_agent_website_input);
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::BusinessAgentWebsite`"))),
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::BusinessAgentWebsite`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBusinessAgentWebsiteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Accepted types: pdf, doc, docx, png, jpg, jpeg, plus csv and xlsx when Meta enabled extraction on the asset. Meta's limit is 100 MB. Two ways to send the file: - JSON `{ url, fileName }`: Zernio downloads the file (public https URL, no redirects, capped at 100 MB) and forwards it. Use this for anything above a few megabytes. - multipart form-data with a `file` part (and an optional `fileName`): bounded by the request body limit of about 4.5 MB; larger uploads must use the `url` form. Not idempotent.
pub async fn upload_business_agent_file(
configuration: &configuration::Configuration,
account_id: &str,
upload_business_agent_file_request: models::UploadBusinessAgentFileRequest,
) -> Result<models::BusinessAgentKnowledgeFile, Error<UploadBusinessAgentFileError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_account_id = account_id;
let p_body_upload_business_agent_file_request = upload_business_agent_file_request;
let uri_str = format!(
"{}/v1/accounts/{accountId}/business-agent/files",
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_upload_business_agent_file_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::BusinessAgentKnowledgeFile`"))),
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::BusinessAgentKnowledgeFile`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UploadBusinessAgentFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}