/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.162.2
* 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};
use tokio::fs::File as TokioFile;
use tokio_util::codec::{BytesCodec, FramedRead};
/// struct for typed errors of method [`add_rcs_test_device`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddRcsTestDeviceError {
Status400(),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_rcs_agent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateRcsAgentError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status402(),
Status403(),
Status404(),
Status409(),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`deactivate_rcs_agent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeactivateRcsAgentError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_rcs_agent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRcsAgentError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_rcs_capabilities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRcsCapabilitiesError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_rcs_agents`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListRcsAgentsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_rcs_brands`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListRcsBrandsError {
Status401(models::InlineObject1),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_rcs_test_devices`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListRcsTestDevicesError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_rcs_test_device`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveRcsTestDeviceError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`request_rcs_agent_launch`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RequestRcsAgentLaunchError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_rcs_message`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendRcsMessageError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
Status422(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_rcs_agent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateRcsAgentError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`upload_rcs_asset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UploadRcsAssetError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(),
Status422(),
UnknownValue(serde_json::Value),
}
/// Invites a phone to try the agent before launch. It must accept the invite in its messaging app. Available once the agent exists with the carriers (after brand vetting). T-Mobile and AT&T numbers cannot be test phones.
pub async fn add_rcs_test_device(
configuration: &configuration::Configuration,
agent_id: &str,
add_rcs_test_device_request: models::AddRcsTestDeviceRequest,
) -> Result<models::AddRcsTestDevice201Response, Error<AddRcsTestDeviceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_agent_id = agent_id;
let p_body_add_rcs_test_device_request = add_rcs_test_device_request;
let uri_str = format!(
"{}/v1/rcs/agents/{agentId}/test-devices",
configuration.base_path,
agentId = crate::apis::urlencode(p_path_agent_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_rcs_test_device_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::AddRcsTestDevice201Response`"))),
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::AddRcsTestDevice201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddRcsTestDeviceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Requests a new agent for a profile, with a new company (`brand`) or an existing one (`brandId`, skips vetting when it is already verified). The request lands in our review: nothing is filed with the carriers or billed until we submit it. One open agent per profile. Requires usage-based billing and a card on file. Send an `Idempotency-Key` header to make retries safe.
pub async fn create_rcs_agent(
configuration: &configuration::Configuration,
create_rcs_agent_request: models::CreateRcsAgentRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateRcsAgent201Response, Error<CreateRcsAgentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_rcs_agent_request = create_rcs_agent_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/v1/rcs/agents", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_rcs_agent_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::CreateRcsAgent201Response`"))),
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::CreateRcsAgent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateRcsAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Stops sending, disconnects its inbox account and stops monthly billing. Fees already charged are not refunded.
pub async fn deactivate_rcs_agent(
configuration: &configuration::Configuration,
agent_id: &str,
) -> Result<models::CreateRcsAgent201Response, Error<DeactivateRcsAgentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_agent_id = agent_id;
let uri_str = format!(
"{}/v1/rcs/agents/{agentId}",
configuration.base_path,
agentId = crate::apis::urlencode(p_path_agent_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::CreateRcsAgent201Response`"))),
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::CreateRcsAgent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeactivateRcsAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_rcs_agent(
configuration: &configuration::Configuration,
agent_id: &str,
) -> Result<models::CreateRcsAgent201Response, Error<GetRcsAgentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_agent_id = agent_id;
let uri_str = format!(
"{}/v1/rcs/agents/{agentId}",
configuration.base_path,
agentId = crate::apis::urlencode(p_path_agent_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::CreateRcsAgent201Response`"))),
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::CreateRcsAgent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRcsAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Which recipients can receive RCS from the agent and which rich features their phones support. Up to 100 numbers.
pub async fn get_rcs_capabilities(
configuration: &configuration::Configuration,
agent_id: &str,
numbers: &str,
) -> Result<models::GetRcsCapabilities200Response, Error<GetRcsCapabilitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_agent_id = agent_id;
let p_query_numbers = numbers;
let uri_str = format!("{}/v1/rcs/capabilities", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("agentId", &p_query_agent_id.to_string())]);
req_builder = req_builder.query(&[("numbers", &p_query_numbers.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::GetRcsCapabilities200Response`"))),
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::GetRcsCapabilities200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRcsCapabilitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_rcs_agents(
configuration: &configuration::Configuration,
include_closed: Option<bool>,
) -> Result<models::ListRcsAgents200Response, Error<ListRcsAgentsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_include_closed = include_closed;
let uri_str = format!("{}/v1/rcs/agents", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_include_closed {
req_builder = req_builder.query(&[("includeClosed", ¶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::ListRcsAgents200Response`"))),
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::ListRcsAgents200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListRcsAgentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The team's RCS brands (vetted companies), to reuse one for another agent with `brandId`.
pub async fn list_rcs_brands(
configuration: &configuration::Configuration,
) -> Result<models::ListRcsBrands200Response, Error<ListRcsBrandsError>> {
let uri_str = format!("{}/v1/rcs/brands", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(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::ListRcsBrands200Response`"))),
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::ListRcsBrands200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListRcsBrandsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_rcs_test_devices(
configuration: &configuration::Configuration,
agent_id: &str,
) -> Result<models::ListRcsTestDevices200Response, Error<ListRcsTestDevicesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_agent_id = agent_id;
let uri_str = format!(
"{}/v1/rcs/agents/{agentId}/test-devices",
configuration.base_path,
agentId = crate::apis::urlencode(p_path_agent_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::ListRcsTestDevices200Response`"))),
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::ListRcsTestDevices200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListRcsTestDevicesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn remove_rcs_test_device(
configuration: &configuration::Configuration,
agent_id: &str,
test_device_id: &str,
) -> Result<models::UpdateYoutubeDefaultPlaylist200Response, Error<RemoveRcsTestDeviceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_agent_id = agent_id;
let p_path_test_device_id = test_device_id;
let uri_str = format!(
"{}/v1/rcs/agents/{agentId}/test-devices/{testDeviceId}",
configuration.base_path,
agentId = crate::apis::urlencode(p_path_agent_id),
testDeviceId = crate::apis::urlencode(p_path_test_device_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::UpdateYoutubeDefaultPlaylist200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateYoutubeDefaultPlaylist200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveRcsTestDeviceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sends the launch details the carriers review (campaign, consent and a public test video). US agents send them once they are in `testing`; we review them before they reach the carriers. Agents in other markets send them while still in review (`requested`, `changes_requested` or `brand_vetting`), because we file everything with the carriers at once; this saves the details without changing the status.
pub async fn request_rcs_agent_launch(
configuration: &configuration::Configuration,
agent_id: &str,
rcs_launch_request: models::RcsLaunchRequest,
) -> Result<models::CreateRcsAgent201Response, Error<RequestRcsAgentLaunchError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_agent_id = agent_id;
let p_body_rcs_launch_request = rcs_launch_request;
let uri_str = format!(
"{}/v1/rcs/agents/{agentId}/launch-request",
configuration.base_path,
agentId = crate::apis::urlencode(p_path_agent_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_rcs_launch_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::CreateRcsAgent201Response`"))),
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::CreateRcsAgent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RequestRcsAgentLaunchError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sends from one of your agents. Use `text` for a plain message or `content` for rich content (card, carousel, media, suggestion chips). Before launch an agent only reaches test phones that accepted the invite. With the agent's `smsFallbackFrom` set, phones without RCS get `fallbackText` (default: the message's readable text) as SMS. Replies and status arrive as webhooks with `platform: \"rcs\"`: `message.received` (a tapped chip carries its postback in `metadata.postbackPayload`), `message.delivered`, `message.read` and `message.failed`. Send an `Idempotency-Key` header to make retries safe.
pub async fn send_rcs_message(
configuration: &configuration::Configuration,
send_rcs_message_request: models::SendRcsMessageRequest,
idempotency_key: Option<&str>,
) -> Result<models::SendRcsMessage200Response, Error<SendRcsMessageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_send_rcs_message_request = send_rcs_message_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/v1/rcs/messages", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_send_rcs_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::SendRcsMessage200Response`"))),
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::SendRcsMessage200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendRcsMessageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Edits the filing while the agent is `requested` or `changes_requested`; answering a change request puts it back in our review. The company can only change until it is filed. `smsFallbackFrom` stays editable in any status (null removes it).
pub async fn update_rcs_agent(
configuration: &configuration::Configuration,
agent_id: &str,
update_rcs_agent_request: models::UpdateRcsAgentRequest,
) -> Result<models::CreateRcsAgent201Response, Error<UpdateRcsAgentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_agent_id = agent_id;
let p_body_update_rcs_agent_request = update_rcs_agent_request;
let uri_str = format!(
"{}/v1/rcs/agents/{agentId}",
configuration.base_path,
agentId = crate::apis::urlencode(p_path_agent_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_rcs_agent_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::CreateRcsAgent201Response`"))),
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::CreateRcsAgent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateRcsAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Uploads an image and returns a public URL for `profile.logoUrl` or `profile.heroUrl`. The image is cropped and compressed to the carriers' exact rules (logo 224x224 under 50 KB, banner 1440x448 under 200 KB).
pub async fn upload_rcs_asset(
configuration: &configuration::Configuration,
file: std::path::PathBuf,
kind: &str,
) -> Result<models::ListInboxReviews200ResponseDataInnerPhotosInner, Error<UploadRcsAssetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_form_file = file;
let p_form_kind = kind;
let uri_str = format!("{}/v1/rcs/assets", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let mut multipart_form = reqwest::multipart::Form::new();
let file = TokioFile::open(&p_form_file).await?;
let stream = FramedRead::new(file, BytesCodec::new());
let file_name = p_form_file
.file_name()
.map(|n| n.to_string_lossy().to_string())
.unwrap_or_default();
let file_part =
reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name);
multipart_form = multipart_form.part("file", file_part);
multipart_form = multipart_form.text("kind", p_form_kind.to_string());
req_builder = req_builder.multipart(multipart_form);
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::ListInboxReviews200ResponseDataInnerPhotosInner`"))),
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::ListInboxReviews200ResponseDataInnerPhotosInner`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UploadRcsAssetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}