/*
* 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.71.0
* 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_imessage_group_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddImessageGroupParticipantError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`cancel_imessage_sender`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CancelImessageSenderError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_imessage_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateImessageGroupError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_imessage_opt_in_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateImessageOptInLinkError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_imessage_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetImessageGroupError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_imessage_sender`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetImessageSenderError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_imessage_audience`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListImessageAudienceError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_imessage_available_numbers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListImessageAvailableNumbersError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_imessage_sender_orders`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListImessageSenderOrdersError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_imessage_senders`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListImessageSendersError {
Status401(models::InlineObject1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`order_imessage_sender`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrderImessageSenderError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status402(),
Status403(),
Status404(),
Status409(),
Status422(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`register_imessage_sender`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RegisterImessageSenderError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status402(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_imessage_group_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveImessageGroupParticipantError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reserve_imessage_available_number`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReserveImessageAvailableNumberError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_imessage_subscription`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetImessageSubscriptionError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_imessage_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateImessageGroupError {
Status400(),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_imessage_sender`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateImessageSenderError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status404(),
UnknownValue(serde_json::Value),
}
/// Applied asynchronously by the provider; the participant list on the next group webhook reflects it.
pub async fn add_imessage_group_participant(
configuration: &configuration::Configuration,
conversation_id: &str,
add_imessage_group_participant_request: models::AddImessageGroupParticipantRequest,
) -> Result<models::AddImessageGroupParticipant200Response, Error<AddImessageGroupParticipantError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_conversation_id = conversation_id;
let p_body_add_imessage_group_participant_request = add_imessage_group_participant_request;
let uri_str = format!(
"{}/v1/imessage/groups/{conversationId}/participants",
configuration.base_path,
conversationId = crate::apis::urlencode(p_path_conversation_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_imessage_group_participant_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::AddImessageGroupParticipant200Response`"))),
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::AddImessageGroupParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddImessageGroupParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Cancels the sender at the provider and deactivates its messaging account. Billing stops with the current month (no proration or refunds, matching phone numbers).
pub async fn cancel_imessage_sender(
configuration: &configuration::Configuration,
sender_id: &str,
) -> Result<models::OrderImessageSender202Response, Error<CancelImessageSenderError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_sender_id = sender_id;
let uri_str = format!(
"{}/v1/imessage/senders/{senderId}",
configuration.base_path,
senderId = crate::apis::urlencode(p_path_sender_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::OrderImessageSender202Response`"))),
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::OrderImessageSender202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CancelImessageSenderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a group chat from one of your senders and sends its first message. The provider processes it asynchronously: the response carries the request id, and the thread appears in the inbox (with its group conversation id) on the first webhook. Starting a group counts as messaging new contacts, so the sender needs the provider's init-conversations add-on and the same sending intervals apply; without it the request fails with 409 `recipient_must_message_first`. WhatsApp groups need a `name`.
pub async fn create_imessage_group(
configuration: &configuration::Configuration,
create_imessage_group_request: models::CreateImessageGroupRequest,
) -> Result<models::CreateImessageGroup202Response, Error<CreateImessageGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_imessage_group_request = create_imessage_group_request;
let uri_str = format!("{}/v1/imessage/groups", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_imessage_group_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::CreateImessageGroup202Response`"))),
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::CreateImessageGroup202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateImessageGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Generates a per-campaign link that opens Messages on this sender with `body` prefilled. A thread the contact opens skips the pacing and the first-message content rule that apply when the sender writes first, and it is the only way in for senders without the add-on for new contacts (their sends to anyone else fail with `recipient_must_message_first`). Each link carries a unique code in place of the `[opt-in-code]` placeholder; when the contact sends it, the resulting `message.received` webhook (and the stored inbox message's `metadata`) has `optIn: true` and your `parameters` under `optInParameters`, so you can attribute the conversation to the campaign or lead that produced it. For an untracked link, use the sender's `optInLink` instead.
pub async fn create_imessage_opt_in_link(
configuration: &configuration::Configuration,
sender_id: &str,
create_imessage_opt_in_link_request: models::CreateImessageOptInLinkRequest,
) -> Result<models::CreateImessageOptInLink200Response, Error<CreateImessageOptInLinkError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_sender_id = sender_id;
let p_body_create_imessage_opt_in_link_request = create_imessage_opt_in_link_request;
let uri_str = format!(
"{}/v1/imessage/senders/{senderId}/opt-in-links",
configuration.base_path,
senderId = crate::apis::urlencode(p_path_sender_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_imessage_opt_in_link_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::CreateImessageOptInLink200Response`"))),
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::CreateImessageOptInLink200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateImessageOptInLinkError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The group's name, participants and channel as the provider currently sees them. The conversation must be a group thread of the given account.
pub async fn get_imessage_group(
configuration: &configuration::Configuration,
conversation_id: &str,
account_id: &str,
) -> Result<models::GetImessageGroup200Response, Error<GetImessageGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_conversation_id = conversation_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/imessage/groups/{conversationId}",
configuration.base_path,
conversationId = crate::apis::urlencode(p_path_conversation_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetImessageGroup200Response`"))),
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::GetImessageGroup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetImessageGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lifecycle status of an ordered or registered sender (poll while an order activates), plus the provider's live platform health for it.
pub async fn get_imessage_sender(
configuration: &configuration::Configuration,
sender_id: &str,
) -> Result<models::GetImessageSender200Response, Error<GetImessageSenderError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_sender_id = sender_id;
let uri_str = format!(
"{}/v1/imessage/senders/{senderId}",
configuration.base_path,
senderId = crate::apis::urlencode(p_path_sender_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::GetImessageSender200Response`"))),
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::GetImessageSender200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetImessageSenderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Contacts who have messaged your iMessage senders (1:1 threads), with subscription state and, for threads opened through a tracked opt-in link, the parameters that brought them in. Newest activity first.
pub async fn list_imessage_audience(
configuration: &configuration::Configuration,
account_id: Option<&str>,
status: Option<&str>,
search: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListImessageAudience200Response, Error<ListImessageAudienceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_status = status;
let p_query_search = search;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!("{}/v1/imessage/audience", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListImessageAudience200Response`"))),
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::ListImessageAudience200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListImessageAudienceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Phone numbers the provider has already registered and can assign on the spot. Order one by passing its `id` as `availableNumberId` to POST /v1/imessage/senders/order: the sender activates immediately instead of after the usual provisioning wait. Reserve it first with POST /v1/imessage/senders/available-numbers/{numberId}/reserve while the buyer decides. The list is a snapshot; a number can be taken between listing and ordering.
pub async fn list_imessage_available_numbers(
configuration: &configuration::Configuration,
region: Option<&str>,
) -> Result<models::ListImessageAvailableNumbers200Response, Error<ListImessageAvailableNumbersError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_query_region = region;
let uri_str = format!(
"{}/v1/imessage/senders/available-numbers",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_region {
req_builder = req_builder.query(&[("region", ¶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::ListImessageAvailableNumbers200Response`"))),
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::ListImessageAvailableNumbers200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListImessageAvailableNumbersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Every sender lifecycle doc your team owns (ordered or registered), across statuses. Canceled senders are omitted unless `includeCanceled=true`.
pub async fn list_imessage_sender_orders(
configuration: &configuration::Configuration,
include_canceled: Option<bool>,
) -> Result<models::ListImessageSenderOrders200Response, Error<ListImessageSenderOrdersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_include_canceled = include_canceled;
let uri_str = format!("{}/v1/imessage/senders/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_include_canceled {
req_builder = req_builder.query(&[("includeCanceled", ¶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::ListImessageSenderOrders200Response`"))),
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::ListImessageSenderOrders200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListImessageSenderOrdersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the iMessage senders registered across your accessible profiles.
pub async fn list_imessage_senders(
configuration: &configuration::Configuration,
) -> Result<models::ListImessageSenders200Response, Error<ListImessageSendersError>> {
let uri_str = format!("{}/v1/imessage/senders", 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::ListImessageSenders200Response`"))),
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::ListImessageSenders200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListImessageSendersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Orders a NEW dedicated iMessage sender from the delivery provider (compare with POST /v1/imessage/senders, which registers a sender you already own). Activation is asynchronous (minutes to a few hours): the response is 202 with the lifecycle object; poll GET /v1/imessage/senders/{senderId} or subscribe to the account.connected webhook. Billing starts at activation (monthly per sender, no proration). Requires usage-based billing and a valid payment method. Pass purchaseIntentId to make retries idempotent — the provider-side order is never retried automatically. Ordered phone senders include SMS/RCS fallback with call forwarding and the ability to message contacts who have not written first (sending intervals still apply).
pub async fn order_imessage_sender(
configuration: &configuration::Configuration,
order_imessage_sender_request: models::OrderImessageSenderRequest,
) -> Result<models::OrderImessageSender202Response, Error<OrderImessageSenderError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_order_imessage_sender_request = order_imessage_sender_request;
let uri_str = format!("{}/v1/imessage/senders/order", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_order_imessage_sender_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::OrderImessageSender202Response`"))),
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::OrderImessageSender202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<OrderImessageSenderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Registers a provider-provisioned iMessage sender (a phone number or an email handle) that YOU already own on a profile, creating an `imessage` account that sends and receives through the inbox conversation endpoints. To have Zernio order a new sender for you, use POST /v1/imessage/senders/order instead. Registration attaches the monthly sender fee (billed while active) and requires a payment method (402 without one). One sender per profile: re-registering the SAME handle refreshes it; a different handle returns 409 until the existing sender is canceled.
pub async fn register_imessage_sender(
configuration: &configuration::Configuration,
register_imessage_sender_request: models::RegisterImessageSenderRequest,
) -> Result<models::RegisterImessageSender200Response, Error<RegisterImessageSenderError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_register_imessage_sender_request = register_imessage_sender_request;
let uri_str = format!("{}/v1/imessage/senders", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_register_imessage_sender_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::RegisterImessageSender200Response`"))),
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::RegisterImessageSender200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RegisterImessageSenderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Applied asynchronously by the provider.
pub async fn remove_imessage_group_participant(
configuration: &configuration::Configuration,
conversation_id: &str,
account_id: &str,
contact: &str,
) -> Result<
models::AddImessageGroupParticipant200Response,
Error<RemoveImessageGroupParticipantError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_conversation_id = conversation_id;
let p_query_account_id = account_id;
let p_query_contact = contact;
let uri_str = format!(
"{}/v1/imessage/groups/{conversationId}/participants",
configuration.base_path,
conversationId = crate::apis::urlencode(p_path_conversation_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
req_builder = req_builder.query(&[("contact", &p_query_contact.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::AddImessageGroupParticipant200Response`"))),
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::AddImessageGroupParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveImessageGroupParticipantError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Holds the number for 3 minutes so nobody else can order it while the buyer decides. Place the order (POST /v1/imessage/senders/order with availableNumberId) before the hold expires. No request body.
pub async fn reserve_imessage_available_number(
configuration: &configuration::Configuration,
number_id: &str,
) -> Result<
models::ReserveImessageAvailableNumber200Response,
Error<ReserveImessageAvailableNumberError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_number_id = number_id;
let uri_str = format!(
"{}/v1/imessage/senders/available-numbers/{numberId}/reserve",
configuration.base_path,
numberId = crate::apis::urlencode(p_path_number_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::ReserveImessageAvailableNumber200Response`"))),
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::ReserveImessageAvailableNumber200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReserveImessageAvailableNumberError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Opted-out contacts are refused at send time (409 recipient_opted_out) until re-subscribed. Their inbound messages still arrive. Scoped to your account: it does not change the contact's state with other businesses.
pub async fn set_imessage_subscription(
configuration: &configuration::Configuration,
set_imessage_subscription_request: models::SetImessageSubscriptionRequest,
) -> Result<models::SetImessageSubscription200Response, Error<SetImessageSubscriptionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_set_imessage_subscription_request = set_imessage_subscription_request;
let uri_str = format!(
"{}/v1/imessage/audience/subscription",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_set_imessage_subscription_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::SetImessageSubscription200Response`"))),
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::SetImessageSubscription200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetImessageSubscriptionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One change per call: either `name` or `photoUrl` (an empty `photoUrl` removes the photo). Applied asynchronously by the provider; a rename is mirrored on the inbox conversation right away.
pub async fn update_imessage_group(
configuration: &configuration::Configuration,
conversation_id: &str,
update_imessage_group_request: models::UpdateImessageGroupRequest,
) -> Result<models::UpdateImessageGroup200Response, Error<UpdateImessageGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_conversation_id = conversation_id;
let p_body_update_imessage_group_request = update_imessage_group_request;
let uri_str = format!(
"{}/v1/imessage/groups/{conversationId}",
configuration.base_path,
conversationId = crate::apis::urlencode(p_path_conversation_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_imessage_group_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::UpdateImessageGroup200Response`"))),
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::UpdateImessageGroup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateImessageGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Display name (inbox and API responses) and the contact card (vCard) recipients see when they save the sender. The contact card is what a contactCard send shares.
pub async fn update_imessage_sender(
configuration: &configuration::Configuration,
sender_id: &str,
update_imessage_sender_request: models::UpdateImessageSenderRequest,
) -> Result<models::OrderImessageSender202Response, Error<UpdateImessageSenderError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_sender_id = sender_id;
let p_body_update_imessage_sender_request = update_imessage_sender_request;
let uri_str = format!(
"{}/v1/imessage/senders/{senderId}",
configuration.base_path,
senderId = crate::apis::urlencode(p_path_sender_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_imessage_sender_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::OrderImessageSender202Response`"))),
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::OrderImessageSender202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateImessageSenderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}