/*
* 1MSG WhatsApp Business API (Public)
*
* Public client API for sending messages, managing groups, flows, and templates. This is the API exposed to end customers via platform.1msg.io **Authentication:** Pass the channel token in **one** place. The API checks JSON body (`token`), then query string (`?token=`), then `Authorization: Bearer` header (preferred in production). **Documentation:** https://help.1msg.io/platform-1msg/getting-start/quick-start **API Docs:** https://docs.1msg.io/
*
* The version of the OpenAPI document: 2.0.0
* Contact: support@1msg.io
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`create_read_message`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateReadMessageError {
Status401(models::CreateReadMessage401Response),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_upload_media`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUploadMediaError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_media`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteMediaError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_media_legacy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteMediaLegacyError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_mm_lite_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMmLiteStatusError {
Status401(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_messages`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListMessagesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`retrieve_media`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveMediaError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_address_message`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendAddressMessageError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_button`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendButtonError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_carousel`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendCarouselError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_contact`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendContactError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_contact_info`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendContactInfoError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_cta_url`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendCtaUrlError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendFileError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_flow`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendFlowError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_list`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendListError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_location`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendLocationError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_location_request`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendLocationRequestError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_message`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendMessageError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_order_details`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendOrderDetailsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_payment_request`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendPaymentRequestError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendProductError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_reaction`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendReactionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_sticker`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendStickerError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status429(models::ErrorResponse),
Status500(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
pub async fn create_read_message(configuration: &configuration::Configuration, token: &str, message_id: Option<&str>, msg_id: Option<&str>, typing_indicator: Option<bool>) -> Result<models::CreateReadMessage200Response, Error<CreateReadMessageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_form_message_id = message_id;
let p_form_msg_id = msg_id;
let p_form_typing_indicator = typing_indicator;
let uri_str = format!("{}/readMessage", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form_params = std::collections::HashMap::new();
if let Some(param_value) = p_form_message_id {
multipart_form_params.insert("messageId", param_value.to_string());
}
if let Some(param_value) = p_form_msg_id {
multipart_form_params.insert("msgId", param_value.to_string());
}
if let Some(param_value) = p_form_typing_indicator {
multipart_form_params.insert("typingIndicator", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
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::CreateReadMessage200Response`"))),
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::CreateReadMessage200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateReadMessageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Upload a file to WhatsApp media storage and get a numeric `mediaId` for later use with `send_file` / `send_sticker` (`mediaId` field, not `body`). Pass the file as `body` **or** `url` — an HTTP(S) URL or a base64 data URI. The `mediaId` in the response is a numeric string (keep it as a string).
pub async fn create_upload_media(configuration: &configuration::Configuration, token: &str, create_upload_media_request: models::CreateUploadMediaRequest) -> Result<models::CreateUploadMedia200Response, Error<CreateUploadMediaError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_create_upload_media_request = create_upload_media_request;
let uri_str = format!("{}/uploadMedia", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_create_upload_media_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::CreateUploadMedia200Response`"))),
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::CreateUploadMedia200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateUploadMediaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete previously uploaded media by numeric `mediaId` (from `/uploadMedia`). This is the canonical deletion endpoint and uses the REST `DELETE` verb on the media resource path. The older `POST /deleteMedia` is a deprecated alias.
pub async fn delete_media(configuration: &configuration::Configuration, token: &str, media_id: &str) -> Result<models::SuccessResponse, Error<DeleteMediaError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_path_media_id = media_id;
let uri_str = format!("{}/media/{mediaId}", configuration.base_path, mediaId=crate::apis::urlencode(p_path_media_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
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::SuccessResponse`"))),
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::SuccessResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteMediaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// **Deprecated.** Use `DELETE /media/{mediaId}` instead. This POST alias is kept for backward compatibility with earlier integrations. New integrations should call `DELETE /media/{mediaId}`: 1msg follows REST conventions for resource deletion going forward (delete a resource with the `DELETE` verb on its resource path).
#[deprecated]
pub async fn delete_media_legacy(configuration: &configuration::Configuration, token: &str, delete_media_legacy_request: models::DeleteMediaLegacyRequest) -> Result<models::SuccessResponse, Error<DeleteMediaLegacyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_delete_media_legacy_request = delete_media_legacy_request;
let uri_str = format!("{}/deleteMedia", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_delete_media_legacy_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::SuccessResponse`"))),
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::SuccessResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteMediaLegacyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mm_lite_status(configuration: &configuration::Configuration, token: &str) -> Result<models::GetMmLiteStatus200Response, Error<GetMmLiteStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let uri_str = format!("{}/mmLiteStatus", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
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::GetMmLiteStatus200Response`"))),
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::GetMmLiteStatus200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMmLiteStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List stored chat history for this channel (requires history storage). Filter with `chatId`, `limit`, `last`, message numbers, or time bounds.
pub async fn list_messages(configuration: &configuration::Configuration, token: &str, chat_id: Option<&str>, limit: Option<i32>, last: Option<bool>, last_message_number: Option<i32>, first_message_number: Option<i32>, min_time: Option<i32>, max_time: Option<i32>, msg_id: Option<&str>) -> Result<models::ListMessages200Response, Error<ListMessagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_query_chat_id = chat_id;
let p_query_limit = limit;
let p_query_last = last;
let p_query_last_message_number = last_message_number;
let p_query_first_message_number = first_message_number;
let p_query_min_time = min_time;
let p_query_max_time = max_time;
let p_query_msg_id = msg_id;
let uri_str = format!("{}/messages", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref param_value) = p_query_chat_id {
req_builder = req_builder.query(&[("chatId", ¶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_last {
req_builder = req_builder.query(&[("last", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_last_message_number {
req_builder = req_builder.query(&[("lastMessageNumber", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_first_message_number {
req_builder = req_builder.query(&[("firstMessageNumber", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_time {
req_builder = req_builder.query(&[("min_time", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_time {
req_builder = req_builder.query(&[("max_time", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_msg_id {
req_builder = req_builder.query(&[("msgId", ¶m_value.to_string())]);
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
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::ListMessages200Response`"))),
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::ListMessages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListMessagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get WABA media URL and metadata by mediaId (from uploadMedia). The returned `url` is temporary and typically expires within ~5 minutes.
pub async fn retrieve_media(configuration: &configuration::Configuration, token: &str, media_id: &str) -> Result<models::RetrieveMedia200Response, Error<RetrieveMediaError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_query_media_id = media_id;
let uri_str = format!("{}/retrieveMedia", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
req_builder = req_builder.query(&[("mediaId", &p_query_media_id.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
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::RetrieveMedia200Response`"))),
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::RetrieveMedia200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveMediaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Request shipping address from the user (WhatsApp interactive `address_message`). **India and Singapore only.** Requires: - Business WhatsApp number registered in that country - Recipient phone matching the country (`+91` ↔ `IN`, `+65` ↔ `SG`) Pass `country: \"IN\"` or `country: \"SG\"`. Eligibility is validated upstream; mismatches (e.g. Singapore phone with `country: \"IN\"`) return errors such as `Unsupported Interactive Message type` (HTTP 200 with `sent: false`). Optional action parameters: `values`, `saved_addresses`, `validation_errors`.
pub async fn send_address_message(configuration: &configuration::Configuration, token: &str, send_address_message_request: models::SendAddressMessageRequest) -> Result<models::MessageSentResponse, Error<SendAddressMessageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_address_message_request = send_address_message_request;
let uri_str = format!("{}/sendAddressMessage", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_address_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendAddressMessageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn send_button(configuration: &configuration::Configuration, token: &str, send_button_request: Option<models::SendButtonRequest>) -> Result<models::MessageSentResponse, Error<SendButtonError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_button_request = send_button_request;
let uri_str = format!("{}/sendButton", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_button_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendButtonError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// You can send product cards via Carousel in two ways: Template messages: do not require a 24-hour customer service window between you and the recipient. Use sendTemplate. Free-form messages: can be sent only when a customer service window is open between you and the recipient. Use sendCarousel. The message structure in /sendCarousel is largely similar to sending a template. However, in this case you must explicitly specify all elements that are created in advance when working with templates. This is because the message is sent without using a template. In /sendCarousel, for a Catalog Carousel there can be either 1 URL button or one or more quick reply buttons. Prefer the simple `cards` array (2–10 cards). Each card needs a header media/product plus a CTA URL or quick-reply buttons. Example: ```json { \"phone\": \"79001234567\", \"body\": \"Pick a product\", \"cards\": [ { \"header\": { \"type\": \"image\", \"image\": { \"link\": \"https://example.com/1.jpg\" } }, \"body\": { \"text\": \"Card one\" }, \"type\": \"cta_url\", \"action\": { \"name\": \"cta_url\", \"parameters\": { \"url\": \"https://example.com/p1\", \"display_text\": \"Open\" } } }, { \"header\": { \"type\": \"image\", \"image\": { \"link\": \"https://example.com/2.jpg\" } }, \"body\": { \"text\": \"Card two\" }, \"type\": \"cta_url\", \"action\": { \"name\": \"cta_url\", \"parameters\": { \"url\": \"https://example.com/p2\", \"display_text\": \"Open\" } } } ] } ``` `params` with a `CAROUSEL` component is the template-like alternative.
pub async fn send_carousel(configuration: &configuration::Configuration, token: &str, body: Option<&str>, cards: Option<Vec<std::collections::HashMap<String, serde_json::Value>>>, params: Option<Vec<serde_json::Value>>, quoted_msg_id: Option<&str>, chat_id: Option<&str>, phone: Option<i32>) -> Result<models::MessageSentResponse, Error<SendCarouselError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_form_body = body;
let p_form_cards = cards;
let p_form_params = params;
let p_form_quoted_msg_id = quoted_msg_id;
let p_form_chat_id = chat_id;
let p_form_phone = phone;
let uri_str = format!("{}/sendCarousel", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form_params = std::collections::HashMap::new();
if let Some(param_value) = p_form_body {
multipart_form_params.insert("body", param_value.to_string());
}
if let Some(param_value) = p_form_cards {
multipart_form_params.insert("cards", param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
}
if let Some(param_value) = p_form_params {
multipart_form_params.insert("params", param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
}
if let Some(param_value) = p_form_quoted_msg_id {
multipart_form_params.insert("quotedMsgId", param_value.to_string());
}
if let Some(param_value) = p_form_chat_id {
multipart_form_params.insert("chatId", param_value.to_string());
}
if let Some(param_value) = p_form_phone {
multipart_form_params.insert("phone", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendCarouselError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a WhatsApp contact card. Preferred simple body (legacy-compatible): ```json { \"phone\": \"79001234567\", \"contact\": { \"name\": \"Lida\", \"phone\": \"+79181976551\" } } ``` Cloud API shape also works: `contacts` is an array of objects with `name.formatted_name` and `phones[].phone` (E.164 string, **not** a timestamp).
pub async fn send_contact(configuration: &configuration::Configuration, token: &str, send_contact_request: Option<models::SendContactRequest>) -> Result<models::MessageSentResponse, Error<SendContactError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_contact_request = send_contact_request;
let uri_str = format!("{}/sendContact", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_contact_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendContactError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a service-window interactive message that asks the WhatsApp user to share their phone number (`request_contact_info`). Use this when you only know the user by BSUID (WhatsApp username) and the 24-hour customer service window is open. Outside that window, create a UTILITY or MARKETING template with a `REQUEST_CONTACT_INFO` button (`POST /addTemplate`) and send it with `POST /sendTemplate`. `body` is the text shown above the button (1–1024 characters). WhatsApp chooses the button label. This method has no button-text field — do not send one. ```json { \"bsuid\": \"US.13491208655302741918\", \"body\": \"Please share your phone number so we can reach you.\" } ``` `phone`, `chatId` (`…@c.us`, `…@lid`, `…@username`), or `bsuid` identifies the recipient. One of them is enough. After Meta accepts the send, the outgoing webhook and stored history message use this same text as `messages[].body` (`type: interactive`). When the user taps the button, Meta sends an inbound `contacts` message. The sender stays the BSUID. The shared number is on the card with `origin: contact_request`. We write that phone onto the existing BSUID contact automatically — there is no separate “link phone” call. ```json { \"contacts\": [ { \"profile\": { \"name\": \"Ada\", \"username\": \"ada\" }, \"user_id\": \"US.13491208655302741918\" } ], \"messages\": [ { \"from_user_id\": \"US.13491208655302741918\", \"type\": \"contacts\", \"contacts\": [ { \"origin\": \"contact_request\", \"phones\": [{ \"phone\": \"+1 202-555-0123\", \"wa_id\": \"12025550123\" }] } ] } ] } ``` The stored inbound message body is the digits (`12025550123`). If Meta later includes a phone on an ordinary message or status for that same BSUID (`wa_id`, `from`, or `recipient_id`, together with `user_id` / `recipient_user_id`), that phone is merged onto the same contact. A contact card the user forwards (`origin` other than `contact_request`) is someone else's number and is not stored as this sender's phone.
pub async fn send_contact_info(configuration: &configuration::Configuration, token: &str, send_contact_info_request: Option<models::SendContactInfoRequest>) -> Result<models::MessageSentResponse, Error<SendContactInfoError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_contact_info_request = send_contact_info_request;
let uri_str = format!("{}/sendContactInfo", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_contact_info_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendContactInfoError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send an interactive message with a single call-to-action URL button.
pub async fn send_cta_url(configuration: &configuration::Configuration, token: &str, send_cta_url_request: models::SendCtaUrlRequest) -> Result<models::MessageSentResponse, Error<SendCtaUrlError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_cta_url_request = send_cta_url_request;
let uri_str = format!("{}/sendCtaUrl", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_cta_url_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendCtaUrlError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a file to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone.
pub async fn send_file(configuration: &configuration::Configuration, token: &str, body: Option<&str>, filename: Option<&str>, media_id: Option<&str>, media_type: Option<&str>, voice: Option<bool>, caption: Option<&str>, quoted_msg_id: Option<&str>, chat_id: Option<&str>, phone: Option<i32>) -> Result<models::MessageSentResponse, Error<SendFileError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_form_body = body;
let p_form_filename = filename;
let p_form_media_id = media_id;
let p_form_media_type = media_type;
let p_form_voice = voice;
let p_form_caption = caption;
let p_form_quoted_msg_id = quoted_msg_id;
let p_form_chat_id = chat_id;
let p_form_phone = phone;
let uri_str = format!("{}/sendFile", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form_params = std::collections::HashMap::new();
if let Some(param_value) = p_form_body {
multipart_form_params.insert("body", param_value.to_string());
}
if let Some(param_value) = p_form_filename {
multipart_form_params.insert("filename", param_value.to_string());
}
if let Some(param_value) = p_form_media_id {
multipart_form_params.insert("mediaId", param_value.to_string());
}
if let Some(param_value) = p_form_media_type {
multipart_form_params.insert("mediaType", param_value.to_string());
}
if let Some(param_value) = p_form_voice {
multipart_form_params.insert("voice", param_value.to_string());
}
if let Some(param_value) = p_form_caption {
multipart_form_params.insert("caption", param_value.to_string());
}
if let Some(param_value) = p_form_quoted_msg_id {
multipart_form_params.insert("quotedMsgId", param_value.to_string());
}
if let Some(param_value) = p_form_chat_id {
multipart_form_params.insert("chatId", param_value.to_string());
}
if let Some(param_value) = p_form_phone {
multipart_form_params.insert("phone", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send Interactive WhatsApp Flow message to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone. Use this method to send a published WhatsApp Flow as a service (interactive) message. If the 24-hour window is closed, send a template with a FLOW button via /sendTemplate.
pub async fn send_flow(configuration: &configuration::Configuration, token: &str, body: &str, flow_id: &str, flow_token: &str, flow_cta: &str, header: Option<models::models::SendFlowRequestHeader>, footer: Option<&str>, flow_action: Option<&str>, flow_action_payload: Option<models::serde_json::Value>, flow_message_version: Option<&str>, mode: Option<&str>, flow_action_data: Option<models::serde_json::Value>, flow_action_screen: Option<&str>, quoted_msg_id: Option<&str>, chat_id: Option<&str>, phone: Option<i32>) -> Result<models::MessageSentResponse, Error<SendFlowError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_form_body = body;
let p_form_flow_id = flow_id;
let p_form_flow_token = flow_token;
let p_form_flow_cta = flow_cta;
let p_form_header = header;
let p_form_footer = footer;
let p_form_flow_action = flow_action;
let p_form_flow_action_payload = flow_action_payload;
let p_form_flow_message_version = flow_message_version;
let p_form_mode = mode;
let p_form_flow_action_data = flow_action_data;
let p_form_flow_action_screen = flow_action_screen;
let p_form_quoted_msg_id = quoted_msg_id;
let p_form_chat_id = chat_id;
let p_form_phone = phone;
let uri_str = format!("{}/sendFlow", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("body", p_form_body.to_string());
if let Some(param_value) = p_form_header {
multipart_form_params.insert("header", param_value.to_string());
}
if let Some(param_value) = p_form_footer {
multipart_form_params.insert("footer", param_value.to_string());
}
multipart_form_params.insert("flowId", p_form_flow_id.to_string());
multipart_form_params.insert("flowToken", p_form_flow_token.to_string());
multipart_form_params.insert("flowCta", p_form_flow_cta.to_string());
if let Some(param_value) = p_form_flow_action {
multipart_form_params.insert("flowAction", param_value.to_string());
}
if let Some(param_value) = p_form_flow_action_payload {
multipart_form_params.insert("flowActionPayload", param_value.to_string());
}
if let Some(param_value) = p_form_flow_message_version {
multipart_form_params.insert("flowMessageVersion", param_value.to_string());
}
if let Some(param_value) = p_form_mode {
multipart_form_params.insert("mode", param_value.to_string());
}
if let Some(param_value) = p_form_flow_action_data {
multipart_form_params.insert("flowActionData", param_value.to_string());
}
if let Some(param_value) = p_form_flow_action_screen {
multipart_form_params.insert("flowActionScreen", param_value.to_string());
}
if let Some(param_value) = p_form_quoted_msg_id {
multipart_form_params.insert("quotedMsgId", param_value.to_string());
}
if let Some(param_value) = p_form_chat_id {
multipart_form_params.insert("chatId", param_value.to_string());
}
if let Some(param_value) = p_form_phone {
multipart_form_params.insert("phone", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendFlowError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn send_list(configuration: &configuration::Configuration, token: &str, send_list_request: Option<models::SendListRequest>) -> Result<models::MessageSentResponse, Error<SendListError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_list_request = send_list_request;
let uri_str = format!("{}/sendList", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_list_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendListError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a location to an existing chat. (Only if the dialogue has an Open Session). Only one of two parameters is needed to determine the destination - chatId or phone.
pub async fn send_location(configuration: &configuration::Configuration, token: &str, lat: &str, lng: &str, address: Option<&str>, name: Option<&str>, quoted_msg_id: Option<&str>, chat_id: Option<&str>, phone: Option<i32>) -> Result<models::MessageSentResponse, Error<SendLocationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_form_lat = lat;
let p_form_lng = lng;
let p_form_address = address;
let p_form_name = name;
let p_form_quoted_msg_id = quoted_msg_id;
let p_form_chat_id = chat_id;
let p_form_phone = phone;
let uri_str = format!("{}/sendLocation", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("lat", p_form_lat.to_string());
multipart_form_params.insert("lng", p_form_lng.to_string());
if let Some(param_value) = p_form_address {
multipart_form_params.insert("address", param_value.to_string());
}
if let Some(param_value) = p_form_name {
multipart_form_params.insert("name", param_value.to_string());
}
if let Some(param_value) = p_form_quoted_msg_id {
multipart_form_params.insert("quotedMsgId", param_value.to_string());
}
if let Some(param_value) = p_form_chat_id {
multipart_form_params.insert("chatId", param_value.to_string());
}
if let Some(param_value) = p_form_phone {
multipart_form_params.insert("phone", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendLocationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn send_location_request(configuration: &configuration::Configuration, token: &str, send_location_request_request: Option<models::SendLocationRequestRequest>) -> Result<models::MessageSentResponse, Error<SendLocationRequestError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_location_request_request = send_location_request_request;
let uri_str = format!("{}/sendLocationRequest", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_location_request_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendLocationRequestError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a message to an existing chat. (Only if the dialogue has an Open Session). The message will be added to the queue for sending and delivered even if the phone is disconnected from the Internet or authorization is not passed. Only one of two parameters is needed to determine the destination - chatId or phone. Direct Send is in beta. Meta has not enabled it on every business portfolio, so `category` and `directSend` are a beta option: watch delivery errors before relying on them. Set `category` to `utility` or `authentication` to send outside the 24-hour window as a Meta Direct Send template instead of the 1MSG marketing auto-template. `authentication` is part of that beta and is not recommended. `directSend.serviceFirst: true` tries a free service message first and uses Direct Send only when Meta rejects it because the window is closed (131047). `directSend.templateName` is only valid with `utility` (`^[a-z0-9_]+$`, max 512). Direct Send text is limited to 1024 characters. Without `templateName`, the first unseen phrase may be delivered as Meta's onboarding template. A named template does not guarantee delivery — wait for webhook errors 131000 or 132021. An open 24-hour window is still billed as utility when `category` is set and `serviceFirst` is not true.
pub async fn send_message(configuration: &configuration::Configuration, token: &str, body: &str, quoted_msg_id: Option<&str>, chat_id: Option<&str>, phone: Option<i32>, category: Option<&str>, direct_send: Option<models::models::SendMessageRequestDirectSend>) -> Result<models::MessageSentResponse, Error<SendMessageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_form_body = body;
let p_form_quoted_msg_id = quoted_msg_id;
let p_form_chat_id = chat_id;
let p_form_phone = phone;
let p_form_category = category;
let p_form_direct_send = direct_send;
let uri_str = format!("{}/sendMessage", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("body", p_form_body.to_string());
if let Some(param_value) = p_form_quoted_msg_id {
multipart_form_params.insert("quotedMsgId", param_value.to_string());
}
if let Some(param_value) = p_form_chat_id {
multipart_form_params.insert("chatId", param_value.to_string());
}
if let Some(param_value) = p_form_phone {
multipart_form_params.insert("phone", param_value.to_string());
}
if let Some(param_value) = p_form_category {
multipart_form_params.insert("category", param_value.to_string());
}
if let Some(param_value) = p_form_direct_send {
multipart_form_params.insert("directSend", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendMessageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a WhatsApp **order details** payment / invoice message using a pre-approved **Utility** template that has an `ORDER_DETAILS` button. **India only** (WhatsApp Payments India). Requires: - India WhatsApp Business number - Commerce enabled on the channel (`GET`/`POST /commerce`) - Approved template with an `ORDER_DETAILS` button Use this method when you need structured fields (`order`, `referenceId`, `currency`, `paymentSettings`). The API appends a template button `sub_type: order_details` and sends via the same path as `POST /sendTemplate`. Works **outside the 24-hour session window** (template message). You can also send the same payload yourself with `POST /sendTemplate` by including a button component in `params`: ```json { \"type\": \"button\", \"sub_type\": \"order_details\", \"index\": 0, \"parameters\": [{ \"type\": \"action\", \"action\": { \"order_details\": { \"reference_id\": \"order-123\", \"currency\": \"INR\", \"order\": { \"status\": \"pending\", \"items\": [], \"subtotal\": { \"offset\": 100, \"value\": 50000 } } } } }] } ```
pub async fn send_order_details(configuration: &configuration::Configuration, token: &str, send_order_details_request: models::SendOrderDetailsRequest) -> Result<models::MessageSentResponse, Error<SendOrderDetailsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_order_details_request = send_order_details_request;
let uri_str = format!("{}/sendOrderDetails", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_order_details_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendOrderDetailsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a regional payment request interactive message (beta scaffold). `region` must be IN, SG, or BR. Payload shape follows Meta regional payments docs; verify on stage before production use. Full regional builders are not implemented yet.
pub async fn send_payment_request(configuration: &configuration::Configuration, token: &str, send_payment_request_request: models::SendPaymentRequestRequest) -> Result<models::MessageSentResponse, Error<SendPaymentRequestError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_payment_request_request = send_payment_request_request;
let uri_str = format!("{}/sendPaymentRequest", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_payment_request_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendPaymentRequestError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a single catalog product or a product list. Destination is `chatId` or `phone`. `action` is required: - single product: `{ \"catalog_id\": \"...\", \"product_retailer_id\": \"...\" }` - product list: `{ \"catalog_id\": \"...\", \"sections\": [{ \"title\": \"...\", \"product_items\": [{ \"product_retailer_id\": \"...\" }] }] }`
pub async fn send_product(configuration: &configuration::Configuration, token: &str, send_product_request: models::SendProductRequest) -> Result<models::MessageSentResponse, Error<SendProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_product_request = send_product_request;
let uri_str = format!("{}/sendProduct", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_product_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn send_reaction(configuration: &configuration::Configuration, token: &str, send_reaction_request: Option<models::SendReactionRequest>) -> Result<models::MessageSentResponse, Error<SendReactionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_reaction_request = send_reaction_request;
let uri_str = format!("{}/sendReaction", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_reaction_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendReactionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a WhatsApp sticker by mediaId or link URL.
pub async fn send_sticker(configuration: &configuration::Configuration, token: &str, send_sticker_request: models::SendStickerRequest) -> Result<models::MessageSentResponse, Error<SendStickerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_body_send_sticker_request = send_sticker_request;
let uri_str = format!("{}/sendSticker", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.query(&[("token", value)]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_send_sticker_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::MessageSentResponse`"))),
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::MessageSentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SendStickerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}