// Generated by wuapi-codegen from the OpenAPI spec. Do not edit: run `bun run codegen`.
//! The API's types: every schema of the spec, and the params of every method.
//!
//! Optional fields are `Option`s and are left out of requests when `None`.
//! A field that may be absent or `null` is an `Option<Option<T>>`:
//! `None` leaves it out, `Some(None)` sends `null`.
//! Enums and unions keep values this version of the SDK does not know in
//! an `Unknown` variant instead of failing to parse.
#![allow(clippy::large_enum_variant, clippy::too_many_arguments, unused_imports)]
use crate::macros::{integer_enum, string_enum};
/// Every error response has this shape.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ApiError {
/// Machine-readable error code (see the list in the API description).
pub code: String,
/// Human-readable explanation.
pub message: String,
/// Extra context. `field` names the offending field.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub details: Option<std::collections::BTreeMap<String, serde_json::Value>>,
}
/// Where the account's residential proxy exits. The supported pairs are listed by `GET /v1/proxy-locations`. The city is preferred unless `strictCity` is `true`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProxyLocationResource {
/// ISO 3166-1 alpha-2, uppercase.
pub country: String,
/// City code from `GET /v1/proxy-locations`: lowercase, one word, accents kept (`newyorkcity`, `bogotá`, `sãopaulo`). The unaccented form is accepted on input and stored with its accents.
pub city: String,
/// `false` (the default): the city is preferred. If no residential IP is free in that city when the number needs a new exit, it may get an exit in another city of the same country instead of staying offline, and it stays on that exit while the exit is healthy. `true`: the exact city is required, and the number may stay offline longer while no residential IP is free there. The country is always exact. Always present in responses.
///
/// Default: `false`.
#[serde(rename = "strictCity")]
pub strict_city: bool,
}
/// Where the account's residential proxy should exit, on create. The supported pairs are listed by `GET /v1/proxy-locations`. The city is preferred unless `strictCity` is `true`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProxyLocationInput {
/// ISO 3166-1 alpha-2, uppercase.
pub country: String,
/// City code from `GET /v1/proxy-locations`: lowercase, one word, accents kept (`newyorkcity`, `bogotá`, `sãopaulo`). The unaccented form is accepted on input and stored with its accents.
pub city: String,
/// `false` (the default): the city is preferred. If no residential IP is free in that city when the number needs a new exit, it may get an exit in another city of the same country instead of staying offline, and it stays on that exit while the exit is healthy. `true`: the exact city is required, and the number may stay offline longer while no residential IP is free there. The country is always exact.
///
/// Default: `false`.
#[serde(rename = "strictCity", default, skip_serializing_if = "Option::is_none")]
pub strict_city: Option<bool>,
}
impl ProxyLocationInput {
/// A `ProxyLocationInput` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(country: impl Into<String>, city: impl Into<String>) -> Self {
Self {
country: country.into(),
city: city.into(),
strict_city: None,
}
}
}
/// A change to an account's proxy location: `{country, city}` moves it, `{strictCity}` alone switches whether its city is exact, both do both. An omitted `strictCity` keeps the current one. Any change gives the number a new exit IP and reconnects its session; WhatsApp may ask the phone to confirm the link again. `country` and `city` go together.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ProxyLocationUpdate {
ProxyLocationInput(ProxyLocationInput),
ProxyLocationStrictCityUpdate(ProxyLocationStrictCityUpdate),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<ProxyLocationInput> for ProxyLocationUpdate {
fn from(value: ProxyLocationInput) -> Self {
Self::ProxyLocationInput(value)
}
}
impl From<ProxyLocationStrictCityUpdate> for ProxyLocationUpdate {
fn from(value: ProxyLocationStrictCityUpdate) -> Self {
Self::ProxyLocationStrictCityUpdate(value)
}
}
/// Switches whether the account's city is exact, keeping its country and city.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProxyLocationStrictCityUpdate {
/// Require the exact city (`true`) or prefer it (`false`).
#[serde(rename = "strictCity")]
pub strict_city: bool,
}
impl ProxyLocationStrictCityUpdate {
/// A `ProxyLocationStrictCityUpdate` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(strict_city: bool) -> Self {
Self {
strict_city,
}
}
}
/// A supported `{country, city}` pair for `proxyLocation`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProxyLocationItem {
/// Always `proxy_location`.
pub object: String,
/// ISO 3166-1 alpha-2, uppercase. Use it in `proxyLocation.country`.
pub country: String,
/// The country's English name.
#[serde(rename = "countryName")]
pub country_name: String,
/// City code: lowercase, one word, accents kept (`newyorkcity`, `bogotá`). Use it in `proxyLocation.city`.
pub city: String,
/// The city's display name.
#[serde(rename = "cityName")]
pub city_name: String,
}
/// A page of `ProxyLocationItem` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProxyLocationItemList {
/// Always `list`.
pub object: String,
pub items: Vec<ProxyLocationItem>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
string_enum! {
/// Lifecycle of an account.
/// - `initializing`: The session is starting.
/// - `qr_ready`: Scan `qrCodeUrl`, or type `pairingCode`, on the phone.
/// - `authenticating`: The phone accepted; the session is finishing linking.
/// - `ready`: Linked and connected. Sends and live calls work.
/// - `disconnected`: Not connected. `POST .../reconnect` to try again.
/// - `failed`: The session gave up. `POST .../reconnect` to start over.
pub enum AccountStatus {
/// `initializing`
Initializing = "initializing",
/// `qr_ready`
QrReady = "qr_ready",
/// `authenticating`
Authenticating = "authenticating",
/// `ready`
Ready = "ready",
/// `disconnected`
Disconnected = "disconnected",
/// `failed`
Failed = "failed",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AccountPacingTyping {
/// Show "typing..." in the chat before each message. Default `false`; recommended `true` for bulk, cold or marketing sends.
pub enabled: bool,
/// Shortest typing time, in milliseconds. Default 800.
#[serde(rename = "minMs")]
pub min_ms: i64,
/// Longest typing time, in milliseconds. At least `minMs`. Default 6000.
#[serde(rename = "maxMs")]
pub max_ms: i64,
/// Typing speed: the time shown is the text length divided by this, clamped to `minMs`..`maxMs`. Default 25.
#[serde(rename = "charsPerSecond")]
pub chars_per_second: i64,
}
/// The pacing this account sends with: its own values over the defaults. The anti-ban protections are off by default (no per-minute cap, no first-contact cap, no typing), so messages go out one after another as fast as WhatsApp accepts them. Turn them on with `PATCH /v1/accounts/{accountId}`; recommended for bulk, cold or marketing sends: `messagesPerMinute` 12, `firstContactPerMinute` 5, `typing.enabled` true.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AccountPacing {
/// Sends per minute from this number, with a random 1 to 3 second gap between them. `0` (the default) means no cap and no gap. Recommended 12.
#[serde(rename = "messagesPerMinute")]
pub messages_per_minute: i64,
/// Sends per minute to people who never wrote to this number. `0` (the default) means no cap. At most `messagesPerMinute` when that is set, otherwise at most 30. Recommended 5.
#[serde(rename = "firstContactPerMinute")]
pub first_contact_per_minute: i64,
pub typing: AccountPacingTyping,
/// How long a paced message waits in the queue before it fails with `rate_limited`. Default 60.
#[serde(rename = "queueTimeoutMinutes")]
pub queue_timeout_minutes: i64,
/// `true` when any value differs from the defaults (every protection off, a 60 minute queue timeout).
pub custom: bool,
}
/// A WhatsApp number linked as a device.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Account {
/// Always `account`.
pub object: String,
pub id: String,
/// Project the resource belongs to, `null` when it is in no project. Set at creation and never changes.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
/// Your label for the account.
pub name: Option<String>,
pub status: AccountStatus,
/// `true` while the account, after being `ready`, is reconnecting on its own (`status` `disconnected`, `initializing` or `authenticating`) within the offline tolerance (currently 3 minutes): messages sent meanwhile wait for it. `false` when `ready`, when it is down for a reason it does not recover from, and once the tolerance runs out. Drops shorter than the reconnect grace (currently 20 seconds) fire no webhook.
pub reconnecting: bool,
/// Linked number in E.164, once known.
pub phone: Option<String>,
/// The linked number's WhatsApp display name.
#[serde(rename = "profileName")]
pub profile_name: Option<String>,
/// Where the account's residential proxy exits. `null` only on accounts linked before proxy locations existed.
#[serde(rename = "proxyLocation")]
pub proxy_location: Option<ProxyLocationResource>,
/// PNG data URL of the QR code to scan. Set only while `status` is `qr_ready` and the account does not link by pairing code.
#[serde(rename = "qrCodeUrl")]
pub qr_code_url: Option<String>,
/// Pairing code (`XXXX-XXXX`) to type on the phone, for accounts linking by phone number. `null` once `ready`.
#[serde(rename = "pairingCode")]
pub pairing_code: Option<String>,
/// When `pairingCode` stops working, about 160 seconds after it was issued.
#[serde(rename = "pairingCodeExpiresAt")]
pub pairing_code_expires_at: Option<String>,
/// Billable from the moment linking finished (`linkedAt` set) until the account is deleted or logged out.
pub billable: bool,
/// Why the account left `ready`, for example `logged_out` or `session_not_found`. On the Free plan: `link_timeout` (not linked within 15 minutes; reconnect for a new QR code) or `free_limit_reached` (the month's Free limit was reached; the device stays linked and the account reconnects on its own when the month ends, UTC, or when the organization upgrades). While proxy traffic is paused (an unpaid invoice, or the monthly proxy spend cap): `proxy_paused` (the device stays linked and the account reconnects on its own when the pause lifts).
#[serde(rename = "disconnectReason")]
pub disconnect_reason: Option<String>,
/// The last error the session reported.
#[serde(rename = "lastError")]
pub last_error: Option<String>,
/// Reject incoming calls automatically.
#[serde(rename = "rejectCalls")]
pub reject_calls: bool,
/// Message sent to the caller after an automatic reject.
#[serde(rename = "rejectCallsMessage")]
pub reject_calls_message: Option<String>,
pub pacing: AccountPacing,
/// Whether the recent chats the phone sends right after linking are imported. `none` by default. WhatsApp sends this history once, right after the number links, so a change applies to the next link. A number that is already linked gets no new history, not even after a reconnect.
#[serde(rename = "historySync")]
pub history_sync: HistorySyncSetting,
/// Which received media is downloaded right away; the rest on demand. `none` for new accounts.
#[serde(rename = "mediaAutoDownload")]
pub media_auto_download: MediaAutoDownloadSetting,
/// What this account's image messages are re-encoded to before their upload. `standard` by default. A send can name its own with `media.quality`.
#[serde(rename = "imageQuality")]
pub image_quality: ImageQualitySetting,
/// Your labels. Set from an invitation's `metadata` when the invitee links the number.
pub metadata: std::collections::BTreeMap<String, String>,
/// When linking first finished.
#[serde(rename = "linkedAt")]
pub linked_at: Option<String>,
#[serde(rename = "lastConnectedAt")]
pub last_connected_at: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "updatedAt")]
pub updated_at: String,
}
/// A page of `Account` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AccountList {
/// Always `list`.
pub object: String,
pub items: Vec<Account>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// Merged over the stored pacing; omitted fields keep their value. `pacing: null` resets everything to the defaults, with every protection off. `0` turns a cap off. Out-of-range values answer `400 invalid_request` with `details: {field, min, max}`. Recommended for bulk, cold or marketing sends: `{"messagesPerMinute": 12, "firstContactPerMinute": 5, "typing": {"enabled": true}}`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct AccountPacingUpdate {
/// 0 to 30. `0` turns the per-minute cap and its gap off. `null` resets it to the default (off).
#[serde(rename = "messagesPerMinute", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub messages_per_minute: Option<Option<i64>>,
/// 0 to `messagesPerMinute` (0 to 30 while that is off). `0` turns the first-contact cap off. `null` resets it to the default (off).
#[serde(rename = "firstContactPerMinute", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub first_contact_per_minute: Option<Option<i64>>,
/// Fields you send are merged over the stored ones. `null` on a field, or on `typing`, resets it.
#[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub typing: Option<Option<AccountPacingUpdateTyping>>,
/// 1 to 1440. `null` resets it to 60.
#[serde(rename = "queueTimeoutMinutes", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub queue_timeout_minutes: Option<Option<i64>>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct AccountPacingUpdateTyping {
/// Turn the typing indicator before each message on or off. `null` resets it to the default (off).
#[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub enabled: Option<Option<bool>>,
/// 0 to 10000.
#[serde(rename = "minMs", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub min_ms: Option<Option<i64>>,
/// `minMs` to 20000.
#[serde(rename = "maxMs", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub max_ms: Option<Option<i64>>,
/// 5 to 100.
#[serde(rename = "charsPerSecond", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub chars_per_second: Option<Option<i64>>,
}
string_enum! {
/// - `none`: Do not import chat history. Only messages sent and received after linking are stored.
/// - `recent`: Import the recent chats the phone sends right after linking. They are stored with `source: history` and `history.synced` fires.
pub enum HistorySyncSetting {
/// `none`
None = "none",
/// `recent`
Recent = "recent",
@unknown Unknown,
}
}
/// Which received media is downloaded as soon as it arrives, through the number's proxy (proxy traffic). The rest stays on WhatsApp until requested (`media.url`, `GET /v1/messages/{messageId}/media`).
/// - `none`: nothing up front; every file on demand. The default for accounts created since on-demand media.
/// - `all`: every file up front. Accounts created before on-demand media keep this.
/// - `{maxBytes, types}`: only files of those types up to `maxBytes` bytes up front; the rest on demand.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum MediaAutoDownloadSetting {
MediaAutoDownloadSettingVariant1(MediaAutoDownloadSettingVariant1),
MediaAutoDownloadSettingVariant2(MediaAutoDownloadSettingVariant2),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<MediaAutoDownloadSettingVariant1> for MediaAutoDownloadSetting {
fn from(value: MediaAutoDownloadSettingVariant1) -> Self {
Self::MediaAutoDownloadSettingVariant1(value)
}
}
impl From<MediaAutoDownloadSettingVariant2> for MediaAutoDownloadSetting {
fn from(value: MediaAutoDownloadSettingVariant2) -> Self {
Self::MediaAutoDownloadSettingVariant2(value)
}
}
string_enum! {
pub enum MediaAutoDownloadSettingVariant1 {
/// `none`
None = "none",
/// `all`
All = "all",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MediaAutoDownloadSettingVariant2 {
/// Largest file downloaded up front, in bytes.
#[serde(rename = "maxBytes")]
pub max_bytes: i64,
/// Media types downloaded up front.
pub types: Vec<MediaAutoDownloadSettingVariant2TypesItem>,
}
impl MediaAutoDownloadSettingVariant2 {
/// A `MediaAutoDownloadSettingVariant2` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(max_bytes: i64, types: Vec<MediaAutoDownloadSettingVariant2TypesItem>) -> Self {
Self {
max_bytes,
types,
}
}
}
string_enum! {
pub enum MediaAutoDownloadSettingVariant2TypesItem {
/// `image`
Image = "image",
/// `video`
Video = "video",
/// `audio`
Audio = "audio",
/// `document`
Document = "document",
/// `sticker`
Sticker = "sticker",
@unknown Unknown,
}
}
string_enum! {
/// What an image message is re-encoded to before it is uploaded through the number's proxy (proxy traffic), the way the WhatsApp apps do when a photo is sent. Only image messages: stickers, documents (an image sent as a document included), video and audio always go up as the file they are. An image is left as it is when re-encoding would not make it clearly smaller, and a PNG with transparency stays a PNG.
/// - `standard`: longest side at most 1600 px, JPEG quality 80. What the WhatsApp apps send by default, and the smallest upload.
/// - `hd`: longest side at most 4096 px, JPEG quality 90, like the apps' HD switch.
/// - `original`: the file is not re-encoded. Only lossless steps apply (metadata such as Exif and GPS is removed; the pixels are the same).
pub enum ImageQualitySetting {
/// `standard`
Standard = "standard",
/// `hd`
Hd = "hd",
/// `original`
Original = "original",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AccountCreateRequest {
/// Label, at most 100 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// Required. Where the account's residential proxy exits: a pair from `GET /v1/proxy-locations`, ideally the number's own country. Missing: `400 invalid_request`; not in the catalog: `400 unsupported_proxy_location`.
#[serde(rename = "proxyLocation")]
pub proxy_location: ProxyLocationInput,
/// Link by pairing code instead of QR code: the number to link, E.164 or digits. The code appears as `pairingCode` (and the `account.pairing_code_issued` event) once the session is up; `qrCodeUrl` stays `null`.
#[serde(rename = "pairingPhone", default, skip_serializing_if = "Option::is_none")]
pub pairing_phone: Option<String>,
/// Organization keys only: create the account in this project (id or `ext:<externalId>`). A project scope uses its own project; naming another answers `403 forbidden`.
#[serde(rename = "projectId", default, skip_serializing_if = "Option::is_none")]
pub project_id: Option<String>,
/// Import the recent chats the phone sends when the number links: `recent`. Default `none`, no history. WhatsApp sends this history once, right after linking.
#[serde(rename = "historySync", default, skip_serializing_if = "Option::is_none")]
pub history_sync: Option<HistorySyncSetting>,
}
impl AccountCreateRequest {
/// A `AccountCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(proxy_location: ProxyLocationInput) -> Self {
Self {
name: None,
proxy_location,
pairing_phone: None,
project_id: None,
history_sync: None,
}
}
}
/// Provide at least one field. Call settings go to the live session, so the engine must know the account (any status). Pacing, `historySync` and `mediaAutoDownload` are stored even before the account has a session. A `proxyLocation` change moves a live session to the new exit.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct AccountUpdateRequest {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// Reject incoming calls automatically.
#[serde(rename = "rejectCalls", default, skip_serializing_if = "Option::is_none")]
pub reject_calls: Option<bool>,
/// Sent to the caller after an automatic reject (not for group calls). At most 1000 characters.
#[serde(rename = "rejectCallsMessage", default, skip_serializing_if = "Option::is_none")]
pub reject_calls_message: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub pacing: Option<Option<AccountPacingUpdate>>,
/// Import history at the next link, or not. WhatsApp sends this history once, right after the number links, so a change applies to the next link. A number that is already linked gets no new history, not even after a reconnect.
#[serde(rename = "historySync", default, skip_serializing_if = "Option::is_none")]
pub history_sync: Option<HistorySyncSetting>,
/// Which received media is downloaded right away. Applies to messages received from then on; files already received keep what they had.
#[serde(rename = "mediaAutoDownload", default, skip_serializing_if = "Option::is_none")]
pub media_auto_download: Option<MediaAutoDownloadSetting>,
/// What this account's image messages are re-encoded to before their upload. Applies to images sent from then on; a send that names `media.quality` keeps its own.
#[serde(rename = "imageQuality", default, skip_serializing_if = "Option::is_none")]
pub image_quality: Option<ImageQualitySetting>,
/// Move the number, or switch whether its city is exact. A location change: the number gets a new exit IP and its session reconnects.
#[serde(rename = "proxyLocation", default, skip_serializing_if = "Option::is_none")]
pub proxy_location: Option<ProxyLocationUpdate>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PairingCodeRequest {
/// The number to link, E.164 (`+584121234567`) or digits.
pub phone: String,
}
impl PairingCodeRequest {
/// A `PairingCodeRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(phone: impl Into<String>) -> Self {
Self {
phone: phone.into(),
}
}
}
/// A pairing code.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PairingCode {
/// Always `pairing_code`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// Type this on the phone: WhatsApp > Linked devices > Link a device > Link with phone number instead.
pub code: String,
/// About 160 seconds after it was issued.
#[serde(rename = "expiresAt")]
pub expires_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AccountPresenceRequest {
/// - `online`: Contacts see the account online.
/// - `offline`: Contacts see it offline.
pub state: AccountPresenceRequestState,
}
impl AccountPresenceRequest {
/// A `AccountPresenceRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(state: AccountPresenceRequestState) -> Self {
Self {
state,
}
}
}
string_enum! {
pub enum AccountPresenceRequestState {
/// `online`
Online = "online",
/// `offline`
Offline = "offline",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct DisappearingTimerRequest {
/// 0 turns it off; otherwise 24 hours, 7 days or 90 days.
#[serde(rename = "durationSeconds")]
pub duration_seconds: DisappearingTimerRequestDurationSeconds,
}
impl DisappearingTimerRequest {
/// A `DisappearingTimerRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(duration_seconds: DisappearingTimerRequestDurationSeconds) -> Self {
Self {
duration_seconds,
}
}
}
integer_enum! {
pub enum DisappearingTimerRequestDurationSeconds {
/// `0`
Value0 = 0,
/// `86400`
Value86400 = 86400,
/// `604800`
Value604800 = 604800,
/// `7776000`
Value7776000 = 7776000,
@unknown Unknown,
}
}
string_enum! {
/// - `inbound`: Sent by a contact to the account.
/// - `outbound`: Sent by the account.
pub enum MessageDirection {
/// `inbound`
Inbound = "inbound",
/// `outbound`
Outbound = "outbound",
@unknown Unknown,
}
}
string_enum! {
/// - `api`: Sent through wuapi.
/// - `phone`: Sent from the phone itself.
/// - `contact`: Received from a contact.
/// - `history`: Imported from the phone's history sync. Fires no per-message events.
pub enum MessageSource {
/// `api`
Api = "api",
/// `phone`
Phone = "phone",
/// `contact`
Contact = "contact",
/// `history`
History = "history",
@unknown Unknown,
}
}
string_enum! {
/// - `text`: Text.
/// - `image`: Image, with an optional caption in `text`.
/// - `video`: Video.
/// - `audio`: Audio file.
/// - `voice`: Audio sent or received as a voice note.
/// - `document`: Document.
/// - `sticker`: Sticker.
/// - `location`: A location.
/// - `contact`: One contact card.
/// - `contacts`: Several contact cards.
/// - `poll`: A poll.
/// - `reaction`: A reaction: `text` is the emoji (empty when removed), `replyToMessageId` the message reacted to.
/// - `calendar_event`: A WhatsApp calendar event.
/// - `unknown`: A type wuapi does not model.
pub enum MessageType {
/// `text`
Text = "text",
/// `image`
Image = "image",
/// `video`
Video = "video",
/// `audio`
Audio = "audio",
/// `voice`
Voice = "voice",
/// `document`
Document = "document",
/// `sticker`
Sticker = "sticker",
/// `location`
Location = "location",
/// `contact`
Contact = "contact",
/// `contacts`
Contacts = "contacts",
/// `poll`
Poll = "poll",
/// `reaction`
Reaction = "reaction",
/// `calendar_event`
CalendarEvent = "calendar_event",
/// `unknown`
Unknown = "unknown",
@unknown UnknownValue,
}
}
string_enum! {
/// - `queued`: Waiting to be sent (paced or retrying).
/// - `sent`: WhatsApp accepted it.
/// - `delivered`: It reached the phone.
/// - `read`: The recipient read it.
/// - `failed`: It was not sent. See `error`.
/// - `received`: An inbound message.
pub enum MessageStatus {
/// `queued`
Queued = "queued",
/// `sent`
Sent = "sent",
/// `delivered`
Delivered = "delivered",
/// `read`
Read = "read",
/// `failed`
Failed = "failed",
/// `received`
Received = "received",
@unknown Unknown,
}
}
string_enum! {
/// - `direct`: A chat with one contact. `chatId` is the contact id.
/// - `group`: A group. `chatId` is the group id.
/// - `channel`: A channel. `chatId` is the channel id.
/// - `story`: The account's stories. `chatId` is `stories`.
pub enum ChatType {
/// `direct`
Direct = "direct",
/// `group`
Group = "group",
/// `channel`
Channel = "channel",
/// `story`
Story = "story",
@unknown Unknown,
}
}
/// A message's file. Received media is downloaded on demand by default (an account's `mediaAutoDownload`): until someone asks for it, the file stays on WhatsApp, `downloaded` is `false` and `url` is `https://api.wuapi.dev/v1/messages/{messageId}/media`, which needs your API key, downloads the file once through the number's proxy and redirects to it. Once stored, `downloaded` is `true` and `url` is the file itself. Tools that fetch `url` without headers (no-code automations) must send the API key (`Authorization: Bearer`) when `downloaded` is `false`, or call the endpoint with `redirect=false` and use the `url` it returns, which needs no key.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageMedia {
/// `downloaded: true`: the file itself. Received: stored by wuapi; the URL does not expire and needs no API key, so anyone who has it can download the file: treat it as a secret. It stops working when the message is deleted. Sent: the URL you gave, or, for a file sent with `media.uploadId`, the stored file (the same kind of URL as a received file's, working until the message is deleted). `downloaded: false`: `GET /v1/messages/{messageId}/media` on api.wuapi.dev, which needs the API key (`Authorization: Bearer`) and answers a redirect to the file. A file sent from the phone itself (`source: phone`) is handled like a received one. `null` when wuapi has nothing to fetch the file with. Messages imported by history sync (`source: history`) have no `media` at all: the import carries what a message was, not its file.
pub url: Option<String>,
#[serde(rename = "mimeType")]
pub mime_type: Option<String>,
pub filename: Option<String>,
/// Bytes, when known: what WhatsApp declared for a received file, the stored file's size, or what was uploaded for a message sent through the API (known at once for a file sent with `media.uploadId`, once `sent` for a URL).
pub size: Option<i64>,
/// Pixels, for images, video and stickers. Today only for an image sent through the API (JPEG, PNG or GIF), once it is `sent`; `null` otherwise, including every received file: the WhatsApp engine does not report the dimensions of received media yet.
pub width: Option<i64>,
/// Pixels. Set and `null` together with `width`.
pub height: Option<i64>,
/// Length of an audio, voice note or video, in seconds. `null` when unknown, which today is always: the WhatsApp engine does not report it yet.
#[serde(rename = "durationSeconds")]
pub duration_seconds: Option<i64>,
/// `true`: `url` is the file. `false`: the file is still on WhatsApp; `url` fetches it on first use.
pub downloaded: bool,
}
/// A message's stored file, from `GET /v1/messages/{messageId}/media` asked for JSON.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageMediaFile {
/// Always `media`.
pub object: String,
#[serde(rename = "messageId")]
pub message_id: String,
/// The file. No API key needed.
pub url: String,
#[serde(rename = "mimeType")]
pub mime_type: Option<String>,
pub filename: Option<String>,
/// Bytes, when known.
pub size: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageLocation {
pub latitude: f64,
pub longitude: f64,
pub name: Option<String>,
pub address: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageContact {
pub name: String,
/// E.164.
pub phone: String,
}
/// The poll and its current tally. Votes arrive as `poll.voted` events.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessagePoll {
pub name: String,
pub options: Vec<MessagePollOptionsItem>,
/// How many options a voter may pick; 0 means any number.
#[serde(rename = "selectableCount")]
pub selectable_count: i64,
/// People who voted.
#[serde(rename = "voterCount")]
pub voter_count: i64,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessagePollOptionsItem {
pub name: String,
#[serde(rename = "voteCount")]
pub vote_count: i64,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageCalendarEvent {
pub name: String,
pub description: Option<String>,
#[serde(rename = "startsAt")]
pub starts_at: Option<String>,
#[serde(rename = "endsAt")]
pub ends_at: Option<String>,
pub location: Option<MessageCalendarEventLocation>,
/// Set when the calendar event is a scheduled WhatsApp call.
/// - `audio`: A scheduled voice call.
/// - `video`: A scheduled video call.
#[serde(rename = "callType")]
pub call_type: Option<MessageCalendarEventCallType>,
/// The call link WhatsApp generated, on received calendar events. wuapi never generates one.
#[serde(rename = "joinUrl")]
pub join_url: Option<String>,
#[serde(rename = "allowExtraGuests")]
pub allow_extra_guests: bool,
pub cancelled: bool,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageCalendarEventLocation {
pub name: Option<String>,
pub address: Option<String>,
pub latitude: Option<f64>,
pub longitude: Option<f64>,
}
string_enum! {
pub enum MessageCalendarEventCallType {
/// `audio`
Audio = "audio",
/// `video`
Video = "video",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageError {
/// - `not_on_whatsapp`: The recipient has no WhatsApp.
/// - `rate_limited`: Still paced after `pacing.queueTimeoutMinutes`.
/// - `send_failed`: WhatsApp or the engine refused it, or its `media.url` could not be downloaded (the message names the host and its answer).
/// - `account_offline`: The account was reconnecting for longer than the offline tolerance, or went down for good, while the message waited for it.
/// - `cancelled`: Deleted with `DELETE /v1/messages/{messageId}` while it was still queued; it was never sent.
/// - `payment_required`: It was queued before proxy traffic paused for an unpaid invoice, and the pause lasted more than 24 hours.
/// - `proxy_spend_cap_reached`: It was queued before proxy traffic paused at the monthly proxy spend cap, and the pause lasted more than 24 hours.
pub code: MessageErrorCode,
pub message: String,
}
string_enum! {
pub enum MessageErrorCode {
/// `not_on_whatsapp`
NotOnWhatsapp = "not_on_whatsapp",
/// `rate_limited`
RateLimited = "rate_limited",
/// `send_failed`
SendFailed = "send_failed",
/// `account_offline`
AccountOffline = "account_offline",
/// `cancelled`
Cancelled = "cancelled",
/// `payment_required`
PaymentRequired = "payment_required",
/// `proxy_spend_cap_reached`
ProxySpendCapReached = "proxy_spend_cap_reached",
@unknown Unknown,
}
}
/// A message in a chat, stored by wuapi.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Message {
/// Always `message`.
pub object: String,
pub id: String,
/// Project the resource belongs to, `null` when it is in no project. Set at creation and never changes.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// The chat: the contact id for a direct chat, the group id, the channel id, or `stories`.
#[serde(rename = "chatId")]
pub chat_id: String,
#[serde(rename = "chatType")]
pub chat_type: ChatType,
pub direction: MessageDirection,
pub source: MessageSource,
/// Sender: a contact id, or the account's own number on outbound messages.
pub from: String,
/// Recipient: a contact id, the group id, the channel id, or `stories`.
pub to: String,
/// The sender's WhatsApp display name, on inbound messages.
#[serde(rename = "profileName")]
pub profile_name: Option<String>,
/// The sender's WhatsApp username (lowercase, without the `@`), on inbound messages when WhatsApp shared it. A contact who hides their number (`from` is `lid:<digits>`) is often only recognizable by it.
pub username: Option<String>,
pub r#type: MessageType,
/// Text, or the caption of media.
pub text: Option<String>,
pub media: Option<MessageMedia>,
pub location: Option<MessageLocation>,
/// The contact card (the first one when several were sent).
pub contact: Option<MessageContact>,
/// Every card of a `contacts` message.
pub contacts: Option<Vec<MessageContact>>,
pub poll: Option<MessagePoll>,
#[serde(rename = "calendarEvent")]
pub calendar_event: Option<MessageCalendarEvent>,
/// Mentioned contact ids.
pub mentions: Vec<String>,
pub forwarded: bool,
#[serde(rename = "viewOnce")]
pub view_once: bool,
pub starred: bool,
/// The wuapi id of the quoted (or reacted-to) message.
#[serde(rename = "replyToMessageId")]
pub reply_to_message_id: Option<String>,
pub status: MessageStatus,
/// Why it failed, when `status` is `failed`.
pub error: Option<MessageError>,
/// Your metadata, as sent.
pub metadata: std::collections::BTreeMap<String, String>,
/// WhatsApp's own timestamp of the message.
#[serde(rename = "sentAt")]
pub sent_at: Option<String>,
/// Set when the text was edited (`message.edited`).
#[serde(rename = "editedAt")]
pub edited_at: Option<String>,
/// Set when it was deleted for everyone (`message.deleted`); the content is cleared.
#[serde(rename = "deletedAt")]
pub deleted_at: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "updatedAt")]
pub updated_at: String,
}
/// A page of `Message` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageList {
/// Always `list`.
pub object: String,
pub items: Vec<Message>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
integer_enum! {
/// A disappearing-messages timer: 0 (off), 24 hours, 7 days or 90 days.
pub enum DisappearingSeconds {
/// `0`
Value0 = 0,
/// `86400`
Value86400 = 86400,
/// `604800`
Value604800 = 604800,
/// `7776000`
Value7776000 = 7776000,
@unknown Unknown,
}
}
/// A file to send: exactly one of `url` (a public URL our servers download) or `uploadId` (a file uploaded with `POST /v1/uploads`).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum SendMedia {
SendMediaUrl(SendMediaUrl),
SendMediaUpload(SendMediaUpload),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<SendMediaUrl> for SendMedia {
fn from(value: SendMediaUrl) -> Self {
Self::SendMediaUrl(value)
}
}
impl From<SendMediaUpload> for SendMedia {
fn from(value: SendMediaUpload) -> Self {
Self::SendMediaUpload(value)
}
}
/// A file to send, fetched by our servers from a URL.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendMediaUrl {
/// Public `http(s)` URL our servers download (up to 5 redirects, 60 seconds, 100 MB), as `wuapi-media-fetcher/1.0 (+https://wuapi.dev)`. Private and internal addresses are refused; hosts with hotlink protection may refuse the download, which fails the message with a message naming the host and its answer (`fetch media from upload.wikimedia.org: HTTP 403`).
pub url: String,
/// Guessed from the URL extension when omitted. Voice notes: send ogg/opus, nothing is transcoded.
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
}
impl SendMediaUrl {
/// A `SendMediaUrl` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
mime_type: None,
filename: None,
}
}
}
/// A file to send, uploaded before with `POST /v1/uploads`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendMediaUpload {
/// The id of a `ready` upload (`POST /v1/uploads`). Nothing is downloaded from outside: the file is already stored. The upload can be sent again until it expires.
#[serde(rename = "uploadId")]
pub upload_id: String,
/// Defaults to the upload's `mimeType`. Voice notes: upload ogg/opus, nothing is transcoded.
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
/// Defaults to the upload's `filename`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
}
impl SendMediaUpload {
/// A `SendMediaUpload` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(upload_id: impl Into<String>) -> Self {
Self {
upload_id: upload_id.into(),
mime_type: None,
filename: None,
}
}
}
/// An image to send: exactly one of `url` (a public URL our servers download) or `uploadId` (a file uploaded with `POST /v1/uploads`).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum SendImageMedia {
SendImageMediaUrl(SendImageMediaUrl),
SendImageMediaUpload(SendImageMediaUpload),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<SendImageMediaUrl> for SendImageMedia {
fn from(value: SendImageMediaUrl) -> Self {
Self::SendImageMediaUrl(value)
}
}
impl From<SendImageMediaUpload> for SendImageMedia {
fn from(value: SendImageMediaUpload) -> Self {
Self::SendImageMediaUpload(value)
}
}
/// An image to send, fetched by our servers from a URL.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendImageMediaUrl {
/// Public `http(s)` URL our servers download (up to 5 redirects, 60 seconds, 100 MB), as `wuapi-media-fetcher/1.0 (+https://wuapi.dev)`. Private and internal addresses are refused; hosts with hotlink protection may refuse the download, which fails the message with a message naming the host and its answer (`fetch media from upload.wikimedia.org: HTTP 403`).
pub url: String,
/// Guessed from the URL extension when omitted. Voice notes: send ogg/opus, nothing is transcoded.
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
/// The quality of this image, instead of the account's `imageQuality`. `hd` is WhatsApp's HD photo; `original` sends the file without re-encoding it.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub quality: Option<ImageQualitySetting>,
}
impl SendImageMediaUrl {
/// A `SendImageMediaUrl` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
mime_type: None,
filename: None,
quality: None,
}
}
}
/// An image to send, uploaded before with `POST /v1/uploads`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendImageMediaUpload {
/// The id of a `ready` upload (`POST /v1/uploads`). Nothing is downloaded from outside: the file is already stored. The upload can be sent again until it expires.
#[serde(rename = "uploadId")]
pub upload_id: String,
/// Defaults to the upload's `mimeType`. Voice notes: upload ogg/opus, nothing is transcoded.
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
/// Defaults to the upload's `filename`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
/// The quality of this image, instead of the account's `imageQuality`. `hd` is WhatsApp's HD photo; `original` sends the file without re-encoding it.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub quality: Option<ImageQualitySetting>,
}
impl SendImageMediaUpload {
/// A `SendImageMediaUpload` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(upload_id: impl Into<String>) -> Self {
Self {
upload_id: upload_id.into(),
mime_type: None,
filename: None,
quality: None,
}
}
}
/// A video to send: exactly one of `url` (a public URL our servers download) or `uploadId` (a file uploaded with `POST /v1/uploads`).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum SendVideoMedia {
SendVideoMediaUrl(SendVideoMediaUrl),
SendVideoMediaUpload(SendVideoMediaUpload),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<SendVideoMediaUrl> for SendVideoMedia {
fn from(value: SendVideoMediaUrl) -> Self {
Self::SendVideoMediaUrl(value)
}
}
impl From<SendVideoMediaUpload> for SendVideoMedia {
fn from(value: SendVideoMediaUpload) -> Self {
Self::SendVideoMediaUpload(value)
}
}
/// A video to send, fetched by our servers from a URL.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendVideoMediaUrl {
/// Public `http(s)` URL our servers download (up to 5 redirects, 60 seconds, 100 MB), as `wuapi-media-fetcher/1.0 (+https://wuapi.dev)`. Private and internal addresses are refused; hosts with hotlink protection may refuse the download, which fails the message with a message naming the host and its answer (`fetch media from upload.wikimedia.org: HTTP 403`).
pub url: String,
/// Guessed from the URL extension when omitted. Voice notes: send ogg/opus, nothing is transcoded.
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
/// Play it as a GIF.
#[serde(rename = "gifPlayback", default, skip_serializing_if = "Option::is_none")]
pub gif_playback: Option<bool>,
}
impl SendVideoMediaUrl {
/// A `SendVideoMediaUrl` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
mime_type: None,
filename: None,
gif_playback: None,
}
}
}
/// A video to send, uploaded before with `POST /v1/uploads`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendVideoMediaUpload {
/// The id of a `ready` upload (`POST /v1/uploads`). Nothing is downloaded from outside: the file is already stored. The upload can be sent again until it expires.
#[serde(rename = "uploadId")]
pub upload_id: String,
/// Defaults to the upload's `mimeType`. Voice notes: upload ogg/opus, nothing is transcoded.
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
/// Defaults to the upload's `filename`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
/// Play it as a GIF.
#[serde(rename = "gifPlayback", default, skip_serializing_if = "Option::is_none")]
pub gif_playback: Option<bool>,
}
impl SendVideoMediaUpload {
/// A `SendVideoMediaUpload` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(upload_id: impl Into<String>) -> Self {
Self {
upload_id: upload_id.into(),
mime_type: None,
filename: None,
gif_playback: None,
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendContact {
pub name: String,
/// E.164 or digits.
pub phone: String,
}
impl SendContact {
/// A `SendContact` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>, phone: impl Into<String>) -> Self {
Self {
name: name.into(),
phone: phone.into(),
}
}
}
/// A pin on the map.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendLocation {
pub latitude: f64,
pub longitude: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
}
impl SendLocation {
/// A `SendLocation` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(latitude: f64, longitude: f64) -> Self {
Self {
latitude,
longitude,
name: None,
address: None,
}
}
}
/// A poll.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendPoll {
pub name: String,
/// 2 to 12 unique, non-blank options of at most 100 characters.
pub options: Vec<String>,
/// How many options a voter may pick. 0 (default) means any number; at most the number of options.
#[serde(rename = "selectableCount", default, skip_serializing_if = "Option::is_none")]
pub selectable_count: Option<i64>,
}
impl SendPoll {
/// A `SendPoll` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>, options: Vec<String>) -> Self {
Self {
name: name.into(),
options,
selectable_count: None,
}
}
}
/// A calendar event.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendCalendarEvent {
pub name: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// ISO 8601.
#[serde(rename = "startsAt")]
pub starts_at: String,
/// Not before `startsAt`.
#[serde(rename = "endsAt", default, skip_serializing_if = "Option::is_none")]
pub ends_at: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub location: Option<SendCalendarEventLocation>,
/// Make it a scheduled WhatsApp call. WhatsApp generates the call link, not wuapi.
#[serde(rename = "callType", default, skip_serializing_if = "Option::is_none")]
pub call_type: Option<SendCalendarEventCallType>,
#[serde(rename = "allowExtraGuests", default, skip_serializing_if = "Option::is_none")]
pub allow_extra_guests: Option<bool>,
}
impl SendCalendarEvent {
/// A `SendCalendarEvent` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>, starts_at: impl Into<String>) -> Self {
Self {
name: name.into(),
description: None,
starts_at: starts_at.into(),
ends_at: None,
location: None,
call_type: None,
allow_extra_guests: None,
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendCalendarEventLocation {
pub name: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub latitude: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub longitude: Option<f64>,
}
impl SendCalendarEventLocation {
/// A `SendCalendarEventLocation` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
latitude: None,
longitude: None,
}
}
}
string_enum! {
pub enum SendCalendarEventCallType {
/// `audio`
Audio = "audio",
/// `video`
Video = "video",
@unknown Unknown,
}
}
/// Text only. wuapi does not fetch previews; you provide them.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendLinkPreview {
pub url: String,
pub title: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// JPEG, base64.
#[serde(rename = "thumbnailBase64", default, skip_serializing_if = "Option::is_none")]
pub thumbnail_base64: Option<String>,
}
impl SendLinkPreview {
/// A `SendLinkPreview` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(url: impl Into<String>, title: impl Into<String>) -> Self {
Self {
url: url.into(),
title: title.into(),
description: None,
thumbnail_base64: None,
}
}
}
/// A text message, with an optional link preview.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendTextMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`), a WhatsApp username (`@handle`) of a contact this account already chats with, a group id, or a channel id (to post in a channel the account administers). WhatsApp does not let a linked device look up other usernames: those answer `400 username_not_supported`.
pub to: String,
/// `text`. A body without `type` is also sent as text.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub r#type: Option<String>,
/// The message. Not blank; at most 4096 characters.
pub text: String,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
#[serde(rename = "linkPreview", default, skip_serializing_if = "Option::is_none")]
pub link_preview: Option<SendLinkPreview>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendTextMessageRequest {
/// A `SendTextMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(
account_id: impl Into<String>,
to: impl Into<String>,
text: impl Into<String>,
) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: None,
text: text.into(),
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
link_preview: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// An image, with an optional caption.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendImageMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`), a WhatsApp username (`@handle`) of a contact this account already chats with, a group id, or a channel id (to post in a channel the account administers). WhatsApp does not let a linked device look up other usernames: those answer `400 username_not_supported`.
pub to: String,
/// `image`.
pub r#type: String,
pub media: SendImageMedia,
/// Caption. At most 4096 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// The recipient can open it once.
#[serde(rename = "viewOnce", default, skip_serializing_if = "Option::is_none")]
pub view_once: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendImageMessageRequest {
/// A `SendImageMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(
account_id: impl Into<String>,
to: impl Into<String>,
media: SendImageMedia,
) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "image".to_owned(),
media,
text: None,
mentions: None,
mention_all: None,
forwarded: None,
view_once: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// A video, with an optional caption.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendVideoMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`), a WhatsApp username (`@handle`) of a contact this account already chats with, a group id, or a channel id (to post in a channel the account administers). WhatsApp does not let a linked device look up other usernames: those answer `400 username_not_supported`.
pub to: String,
/// `video`.
pub r#type: String,
pub media: SendVideoMedia,
/// Caption. At most 4096 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// The recipient can open it once.
#[serde(rename = "viewOnce", default, skip_serializing_if = "Option::is_none")]
pub view_once: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendVideoMessageRequest {
/// A `SendVideoMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(
account_id: impl Into<String>,
to: impl Into<String>,
media: SendVideoMedia,
) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "video".to_owned(),
media,
text: None,
mentions: None,
mention_all: None,
forwarded: None,
view_once: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// An audio file.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendAudioMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `audio`.
pub r#type: String,
pub media: SendMedia,
/// Caption. At most 4096 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// The recipient can open it once.
#[serde(rename = "viewOnce", default, skip_serializing_if = "Option::is_none")]
pub view_once: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendAudioMessageRequest {
/// A `SendAudioMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(account_id: impl Into<String>, to: impl Into<String>, media: SendMedia) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "audio".to_owned(),
media,
text: None,
mentions: None,
mention_all: None,
forwarded: None,
view_once: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// An audio sent as a voice note. Send ogg/opus: nothing is transcoded.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendVoiceMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `voice`.
pub r#type: String,
pub media: SendMedia,
/// Caption. At most 4096 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// The recipient can open it once.
#[serde(rename = "viewOnce", default, skip_serializing_if = "Option::is_none")]
pub view_once: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendVoiceMessageRequest {
/// A `SendVoiceMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(account_id: impl Into<String>, to: impl Into<String>, media: SendMedia) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "voice".to_owned(),
media,
text: None,
mentions: None,
mention_all: None,
forwarded: None,
view_once: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// A document, with an optional caption.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendDocumentMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`), a WhatsApp username (`@handle`) of a contact this account already chats with, a group id, or a channel id (to post in a channel the account administers). WhatsApp does not let a linked device look up other usernames: those answer `400 username_not_supported`.
pub to: String,
/// `document`.
pub r#type: String,
pub media: SendMedia,
/// Caption. At most 4096 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendDocumentMessageRequest {
/// A `SendDocumentMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(account_id: impl Into<String>, to: impl Into<String>, media: SendMedia) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "document".to_owned(),
media,
text: None,
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// A sticker.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendStickerMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `sticker`.
pub r#type: String,
pub media: SendMedia,
/// Caption. At most 4096 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendStickerMessageRequest {
/// A `SendStickerMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(account_id: impl Into<String>, to: impl Into<String>, media: SendMedia) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "sticker".to_owned(),
media,
text: None,
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// A location pin.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendLocationMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `location`.
pub r#type: String,
pub location: SendLocation,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendLocationMessageRequest {
/// A `SendLocationMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(
account_id: impl Into<String>,
to: impl Into<String>,
location: SendLocation,
) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "location".to_owned(),
location,
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// One contact card.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendContactMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `contact`.
pub r#type: String,
pub contact: SendContact,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendContactMessageRequest {
/// A `SendContactMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(account_id: impl Into<String>, to: impl Into<String>, contact: SendContact) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "contact".to_owned(),
contact,
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// 2 to 20 contact cards in one message. Use `contact` for one.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendContactsMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `contacts`.
pub r#type: String,
/// 2 to 20 cards.
pub contacts: Vec<SendContact>,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendContactsMessageRequest {
/// A `SendContactsMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(
account_id: impl Into<String>,
to: impl Into<String>,
contacts: Vec<SendContact>,
) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "contacts".to_owned(),
contacts,
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// A poll.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendPollMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `poll`.
pub r#type: String,
pub poll: SendPoll,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendPollMessageRequest {
/// A `SendPollMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(account_id: impl Into<String>, to: impl Into<String>, poll: SendPoll) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "poll".to_owned(),
poll,
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// A calendar event, optionally a scheduled WhatsApp call.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SendCalendarEventMessageRequest {
/// The account to send from. It must be `ready`.
#[serde(rename = "accountId")]
pub account_id: String,
/// A contact id (E.164, digits or `lid:<digits>`) or a group id. Channels take only `text`, `image`, `video` and `document`.
pub to: String,
/// `calendar_event`.
pub r#type: String,
#[serde(rename = "calendarEvent")]
pub calendar_event: SendCalendarEvent,
/// Contact ids to mention. At most 256. Not for channel posts.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mentions: Option<Vec<String>>,
/// Groups only: mention every participant.
#[serde(rename = "mentionAll", default, skip_serializing_if = "Option::is_none")]
pub mention_all: Option<bool>,
/// Mark as forwarded.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forwarded: Option<bool>,
/// Match the chat's disappearing timer.
#[serde(rename = "disappearingSeconds", default, skip_serializing_if = "Option::is_none")]
pub disappearing_seconds: Option<DisappearingSeconds>,
/// A wuapi message id in the same chat to quote. Any type. Not for channel posts.
#[serde(rename = "replyToMessageId", default, skip_serializing_if = "Option::is_none")]
pub reply_to_message_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
impl SendCalendarEventMessageRequest {
/// A `SendCalendarEventMessageRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(
account_id: impl Into<String>,
to: impl Into<String>,
calendar_event: SendCalendarEvent,
) -> Self {
Self {
account_id: account_id.into(),
to: to.into(),
r#type: "calendar_event".to_owned(),
calendar_event,
mentions: None,
mention_all: None,
forwarded: None,
disappearing_seconds: None,
reply_to_message_id: None,
metadata: None,
}
}
}
/// One schema per `type`; each requires its own field (`text`, `media`, `location`, `contact`, `contacts`, `poll` or `calendarEvent`). A body without `type` is sent as `text`. To a channel: `text`, `image`, `video` or `document`, with no `replyToMessageId`, `mentions` or `mentionAll`.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum SendMessageRequest {
/// type: `text`
Text(SendTextMessageRequest),
/// type: `image`
Image(SendImageMessageRequest),
/// type: `video`
Video(SendVideoMessageRequest),
/// type: `audio`
Audio(SendAudioMessageRequest),
/// type: `voice`
Voice(SendVoiceMessageRequest),
/// type: `document`
Document(SendDocumentMessageRequest),
/// type: `sticker`
Sticker(SendStickerMessageRequest),
/// type: `location`
Location(SendLocationMessageRequest),
/// type: `contact`
Contact(SendContactMessageRequest),
/// type: `contacts`
Contacts(SendContactsMessageRequest),
/// type: `poll`
Poll(SendPollMessageRequest),
/// type: `calendar_event`
CalendarEvent(SendCalendarEventMessageRequest),
/// A `type` this version of the SDK does not know, as raw JSON.
Unknown(serde_json::Value),
}
impl serde::Serialize for SendMessageRequest {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
match self {
Self::Text(value) => value.serialize(serializer),
Self::Image(value) => value.serialize(serializer),
Self::Video(value) => value.serialize(serializer),
Self::Audio(value) => value.serialize(serializer),
Self::Voice(value) => value.serialize(serializer),
Self::Document(value) => value.serialize(serializer),
Self::Sticker(value) => value.serialize(serializer),
Self::Location(value) => value.serialize(serializer),
Self::Contact(value) => value.serialize(serializer),
Self::Contacts(value) => value.serialize(serializer),
Self::Poll(value) => value.serialize(serializer),
Self::CalendarEvent(value) => value.serialize(serializer),
Self::Unknown(value) => value.serialize(serializer),
}
}
}
impl<'de> serde::Deserialize<'de> for SendMessageRequest {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <serde_json::Value as serde::Deserialize>::deserialize(deserializer)?;
let tag = value.get("type").and_then(serde_json::Value::as_str);
match tag {
Some("text") => crate::serde_helpers::from_value(value).map(Self::Text),
Some("image") => crate::serde_helpers::from_value(value).map(Self::Image),
Some("video") => crate::serde_helpers::from_value(value).map(Self::Video),
Some("audio") => crate::serde_helpers::from_value(value).map(Self::Audio),
Some("voice") => crate::serde_helpers::from_value(value).map(Self::Voice),
Some("document") => crate::serde_helpers::from_value(value).map(Self::Document),
Some("sticker") => crate::serde_helpers::from_value(value).map(Self::Sticker),
Some("location") => crate::serde_helpers::from_value(value).map(Self::Location),
Some("contact") => crate::serde_helpers::from_value(value).map(Self::Contact),
Some("contacts") => crate::serde_helpers::from_value(value).map(Self::Contacts),
Some("poll") => crate::serde_helpers::from_value(value).map(Self::Poll),
Some("calendar_event") => {
crate::serde_helpers::from_value(value).map(Self::CalendarEvent)
}
// Without `type`, the value is the default variant.
None => crate::serde_helpers::from_value(value).map(Self::Text),
_ => Ok(Self::Unknown(value)),
}
}
}
impl From<SendTextMessageRequest> for SendMessageRequest {
fn from(value: SendTextMessageRequest) -> Self {
Self::Text(value)
}
}
impl From<SendImageMessageRequest> for SendMessageRequest {
fn from(value: SendImageMessageRequest) -> Self {
Self::Image(value)
}
}
impl From<SendVideoMessageRequest> for SendMessageRequest {
fn from(value: SendVideoMessageRequest) -> Self {
Self::Video(value)
}
}
impl From<SendAudioMessageRequest> for SendMessageRequest {
fn from(value: SendAudioMessageRequest) -> Self {
Self::Audio(value)
}
}
impl From<SendVoiceMessageRequest> for SendMessageRequest {
fn from(value: SendVoiceMessageRequest) -> Self {
Self::Voice(value)
}
}
impl From<SendDocumentMessageRequest> for SendMessageRequest {
fn from(value: SendDocumentMessageRequest) -> Self {
Self::Document(value)
}
}
impl From<SendStickerMessageRequest> for SendMessageRequest {
fn from(value: SendStickerMessageRequest) -> Self {
Self::Sticker(value)
}
}
impl From<SendLocationMessageRequest> for SendMessageRequest {
fn from(value: SendLocationMessageRequest) -> Self {
Self::Location(value)
}
}
impl From<SendContactMessageRequest> for SendMessageRequest {
fn from(value: SendContactMessageRequest) -> Self {
Self::Contact(value)
}
}
impl From<SendContactsMessageRequest> for SendMessageRequest {
fn from(value: SendContactsMessageRequest) -> Self {
Self::Contacts(value)
}
}
impl From<SendPollMessageRequest> for SendMessageRequest {
fn from(value: SendPollMessageRequest) -> Self {
Self::Poll(value)
}
}
impl From<SendCalendarEventMessageRequest> for SendMessageRequest {
fn from(value: SendCalendarEventMessageRequest) -> Self {
Self::CalendarEvent(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageEditRequest {
/// The new text.
pub text: String,
}
impl MessageEditRequest {
/// A `MessageEditRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(text: impl Into<String>) -> Self {
Self {
text: text.into(),
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct VoteRequest {
/// Names of this poll's options. `[]` retracts the vote.
pub options: Vec<String>,
}
impl VoteRequest {
/// A `VoteRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(options: Vec<String>) -> Self {
Self {
options,
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ReactRequest {
/// One emoji. An empty string removes the reaction.
pub emoji: String,
}
impl ReactRequest {
/// A `ReactRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(emoji: impl Into<String>) -> Self {
Self {
emoji: emoji.into(),
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct LabelAssignRequest {
#[serde(rename = "labelId")]
pub label_id: String,
}
impl LabelAssignRequest {
/// A `LabelAssignRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(label_id: impl Into<String>) -> Self {
Self {
label_id: label_id.into(),
}
}
}
/// An image or video for a story: exactly one of `url` (a public URL our servers download) or `uploadId` (a file uploaded with `POST /v1/uploads`).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum StoryMedia {
StoryMediaUrl(StoryMediaUrl),
StoryMediaUpload(StoryMediaUpload),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<StoryMediaUrl> for StoryMedia {
fn from(value: StoryMediaUrl) -> Self {
Self::StoryMediaUrl(value)
}
}
impl From<StoryMediaUpload> for StoryMedia {
fn from(value: StoryMediaUpload) -> Self {
Self::StoryMediaUpload(value)
}
}
/// An image or video for a story, fetched by our servers from a URL.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct StoryMediaUrl {
/// Public `http(s)` URL our servers download (up to 5 redirects, 60 seconds, 100 MB), as `wuapi-media-fetcher/1.0 (+https://wuapi.dev)`. Private and internal addresses are refused; hosts with hotlink protection may refuse the download, which fails the message with a message naming the host and its answer (`fetch media from upload.wikimedia.org: HTTP 403`).
pub url: String,
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
/// Images only: the quality of this image, instead of the account's `imageQuality`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub quality: Option<ImageQualitySetting>,
}
impl StoryMediaUrl {
/// A `StoryMediaUrl` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
mime_type: None,
quality: None,
}
}
}
/// An image or video for a story, uploaded before with `POST /v1/uploads`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct StoryMediaUpload {
/// The id of a `ready` upload (`POST /v1/uploads`). Nothing is downloaded from outside: the file is already stored. The upload can be sent again until it expires.
#[serde(rename = "uploadId")]
pub upload_id: String,
/// Defaults to the upload's `mimeType`. Voice notes: upload ogg/opus, nothing is transcoded.
#[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
/// Images only: the quality of this image, instead of the account's `imageQuality`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub quality: Option<ImageQualitySetting>,
}
impl StoryMediaUpload {
/// A `StoryMediaUpload` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(upload_id: impl Into<String>) -> Self {
Self {
upload_id: upload_id.into(),
mime_type: None,
quality: None,
}
}
}
/// A text story.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct TextStoryCreateRequest {
/// `text`. A body without `type` is also posted as text.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub r#type: Option<String>,
/// The story. Not blank; at most 4096 characters.
pub text: String,
/// `#RRGGBB`.
#[serde(rename = "backgroundColor", default, skip_serializing_if = "Option::is_none")]
pub background_color: Option<String>,
/// WhatsApp's font.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub font: Option<TextStoryCreateRequestFont>,
}
impl TextStoryCreateRequest {
/// A `TextStoryCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(text: impl Into<String>) -> Self {
Self {
r#type: None,
text: text.into(),
background_color: None,
font: None,
}
}
}
integer_enum! {
pub enum TextStoryCreateRequestFont {
/// `0`
Value0 = 0,
/// `1`
Value1 = 1,
/// `2`
Value2 = 2,
/// `6`
Value6 = 6,
/// `7`
Value7 = 7,
/// `8`
Value8 = 8,
/// `9`
Value9 = 9,
/// `10`
Value10 = 10,
@unknown Unknown,
}
}
/// An image or video story, with an optional caption.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MediaStoryCreateRequest {
pub r#type: MediaStoryCreateRequestType,
pub media: StoryMedia,
/// Caption. At most 4096 characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
}
impl MediaStoryCreateRequest {
/// A `MediaStoryCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(r#type: MediaStoryCreateRequestType, media: StoryMedia) -> Self {
Self {
r#type,
media,
text: None,
}
}
}
string_enum! {
pub enum MediaStoryCreateRequestType {
/// `image`
Image = "image",
/// `video`
Video = "video",
@unknown Unknown,
}
}
/// A text story (`type: text`, requires `text`) or a media story (`type: image` or `video`, requires `media`). A body without `type` is posted as `text`.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum StoryCreateRequest {
/// type: `text`
Text(TextStoryCreateRequest),
/// type: `image`, `video`
Media(MediaStoryCreateRequest),
/// A `type` this version of the SDK does not know, as raw JSON.
Unknown(serde_json::Value),
}
impl serde::Serialize for StoryCreateRequest {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
match self {
Self::Text(value) => value.serialize(serializer),
Self::Media(value) => value.serialize(serializer),
Self::Unknown(value) => value.serialize(serializer),
}
}
}
impl<'de> serde::Deserialize<'de> for StoryCreateRequest {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <serde_json::Value as serde::Deserialize>::deserialize(deserializer)?;
let tag = value.get("type").and_then(serde_json::Value::as_str);
match tag {
Some("text") => crate::serde_helpers::from_value(value).map(Self::Text),
Some("image" | "video") => crate::serde_helpers::from_value(value).map(Self::Media),
// Without `type`, the value is the default variant.
None => crate::serde_helpers::from_value(value).map(Self::Text),
_ => Ok(Self::Unknown(value)),
}
}
}
impl From<TextStoryCreateRequest> for StoryCreateRequest {
fn from(value: TextStoryCreateRequest) -> Self {
Self::Text(value)
}
}
impl From<MediaStoryCreateRequest> for StoryCreateRequest {
fn from(value: MediaStoryCreateRequest) -> Self {
Self::Media(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatPresenceRequest {
/// - `typing`: Show typing.
/// - `recording`: Show recording audio.
/// - `paused`: Clear the indicator.
pub state: ChatPresenceRequestState,
}
impl ChatPresenceRequest {
/// A `ChatPresenceRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(state: ChatPresenceRequestState) -> Self {
Self {
state,
}
}
}
string_enum! {
pub enum ChatPresenceRequestState {
/// `typing`
Typing = "typing",
/// `recording`
Recording = "recording",
/// `paused`
Paused = "paused",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct ReadReceiptsRequest {
/// wuapi ids of inbound messages in this chat. Default: every unread inbound message wuapi stores for the chat. At most 500.
#[serde(rename = "messageIds", default, skip_serializing_if = "Option::is_none")]
pub message_ids: Option<Vec<String>>,
}
/// A chat of an account: a conversation with a contact, a group or a channel that wuapi holds at least one message of. Its name and latest message come from what wuapi stored; `unread`, `unreadCount`, `pinned`, `archived` and `muted` are WhatsApp's state of the chat, the one the chat actions change and `chat.updated` reports. wuapi learns that state from live changes (made through the API, on the phone or on another device), not from the sync after linking, so a state it has never observed is `null`, not `false`. The account's stories are not a chat.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Chat {
/// Always `chat`.
pub object: String,
/// The chat id, as `chatId` on its messages: the contact id of a direct chat (`+584241112233` or `lid:<digits>`), the group id or the channel id.
pub id: String,
/// The project of the chat's account. `null` when it is in none.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
pub r#type: ChatType,
/// The name to show: `savedName` when there is one, else the group's name or the contact's `profileName`. `null` when none is known yet.
pub name: Option<String>,
/// Direct chats: the name the account saved the contact under in its phone's address book, else the contact's business name. `null` when it has neither, and for groups and channels.
#[serde(rename = "savedName")]
pub saved_name: Option<String>,
/// Direct chats: the contact's WhatsApp profile name, as it came with their messages. `null` when unknown, and for groups and channels.
#[serde(rename = "profileName")]
pub profile_name: Option<String>,
/// Direct chats: the contact's WhatsApp username (lowercase, without `@`), when WhatsApp shared one.
pub username: Option<String>,
/// The id of the chat's picture: the contact's profile picture, or the group's. It changes when the picture does, so a client can keep a downloaded picture until this differs, and ask `GET …/contacts/{contactId}/picture` (with this chat's id) only when it does. wuapi learns it from `contact.picture_updated`, from every picture read or set through the API and from contact lookups, never by asking WhatsApp while listing. `null` when unknown (never observed), when the chat has no picture or it is hidden from this account, and for channels (their picture is `pictureUrl` of the channel).
#[serde(rename = "pictureId")]
pub picture_id: Option<String>,
/// The chat's latest message. `null` when it is no longer stored.
#[serde(rename = "lastMessage")]
pub last_message: Option<Message>,
/// When the latest message was sent or received. Lists are ordered by it, newest first.
#[serde(rename = "lastMessageAt")]
pub last_message_at: String,
/// The chat has unread messages or was marked as unread on WhatsApp. `null` when unknown.
pub unread: Option<bool>,
/// Messages received and not read on WhatsApp yet: counted from the messages wuapi stored, and back to 0 when the account replies, sends read receipts, marks the chat as read or reads it on the phone. `0` with `unread: true` is a chat marked as unread. `null` when unknown: a chat that existed before wuapi kept this count or that only holds imported history, until it is read for the first time.
#[serde(rename = "unreadCount")]
pub unread_count: Option<i64>,
/// Pinned on WhatsApp. `null` when never observed.
pub pinned: Option<bool>,
/// Archived on WhatsApp. `null` when never observed.
pub archived: Option<bool>,
/// Muted on WhatsApp right now (a timed mute that ran out is `false`). `null` when never observed.
pub muted: Option<bool>,
/// When the mute ends. `null` when the chat is not muted, is muted with no end, or its mute was never observed.
#[serde(rename = "muteExpiresAt")]
pub mute_expires_at: Option<String>,
}
/// A page of `Chat` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatList {
/// Always `list`.
pub object: String,
pub items: Vec<Chat>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// Read receipts sent.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatRead {
/// Always `chat_read`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "chatId")]
pub chat_id: String,
/// Messages marked read.
#[serde(rename = "messageCount")]
pub message_count: i64,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct MuteRequest {
/// How long to mute. 0 or absent: until unmuted.
#[serde(rename = "durationSeconds", default, skip_serializing_if = "Option::is_none")]
pub duration_seconds: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct LabelUpsertRequest {
pub name: String,
/// WhatsApp's label color index.
///
/// Default: `0`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub color: Option<i64>,
}
impl LabelUpsertRequest {
/// A `LabelUpsertRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
color: None,
}
}
}
/// A WhatsApp Business label.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Label {
/// Always `label`.
pub object: String,
pub id: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
pub name: String,
pub color: i64,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactCheckRequest {
/// 1 to 50 phone numbers (E.164 or digits).
pub phones: Vec<String>,
}
impl ContactCheckRequest {
/// A `ContactCheckRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(phones: Vec<String>) -> Self {
Self {
phones,
}
}
}
/// Whether a number has WhatsApp.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactCheck {
/// Always `contact_check`.
pub object: String,
/// The number, in E.164.
pub phone: String,
#[serde(rename = "onWhatsApp")]
pub on_whats_app: bool,
/// A contact id: E.164 (`+584241112233`), or `lid:<digits>` when WhatsApp hides the number. `null` when not on WhatsApp.
#[serde(rename = "contactId")]
pub contact_id: Option<String>,
/// The verified business name, for business accounts.
#[serde(rename = "businessName")]
pub business_name: Option<String>,
/// The number's WhatsApp username (lowercase, without the `@`), when this account already learned it. A check never asks WhatsApp for it.
pub username: Option<String>,
}
/// A page of `ContactCheck` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactCheckList {
/// Always `list`.
pub object: String,
pub items: Vec<ContactCheck>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactLookupRequest {
/// 1 to 50 contact ids (E.164, digits or `lid:<digits>`).
#[serde(rename = "contactIds")]
pub contact_ids: Vec<String>,
}
impl ContactLookupRequest {
/// A `ContactLookupRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(contact_ids: Vec<String>) -> Self {
Self {
contact_ids,
}
}
}
/// A WhatsApp user, as this account sees it. The same object comes from three places, and each fills what it knows: the contact list and `GET …/contacts/{contactId}` read the account's address book as its phone synced it to wuapi (`savedName`, `profileName`, `businessName`, and the `username` and `pictureId` wuapi has seen; `about` and `deviceCount` are `null`); `POST …/contacts/lookup` asks WhatsApp (`about`, `pictureId`, `businessName`, `deviceCount`, `username`; `savedName` and `profileName` are `null`); `contact.updated` carries the field that changed. A field that source does not know is `null`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Contact {
/// Always `contact`.
pub object: String,
/// A contact id: E.164 (`+584241112233`), or `lid:<digits>` when WhatsApp hides the number.
pub id: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// The contact's number in E.164 (`+584241112233`). `null` when WhatsApp hides it and the contact is known only by `lid`.
pub phone: Option<String>,
/// The contact's `lid:<digits>` id, when WhatsApp gave one.
pub lid: Option<String>,
/// The name the account saved the contact under in its phone's address book, else the contact's business name: the same value as `savedName` of its chat. Set by the contact list and `GET …/contacts/{contactId}`; `null` from a lookup and in `contact.updated`.
#[serde(rename = "savedName")]
pub saved_name: Option<String>,
/// The contact's WhatsApp profile name, as the account's phone last saw it. `null` when unknown, from a lookup and in `contact.updated`.
#[serde(rename = "profileName")]
pub profile_name: Option<String>,
/// The contact's WhatsApp username (lowercase, without the `@`), when they set one and WhatsApp shared it with this account.
pub username: Option<String>,
/// About text. Only a lookup and `contact.updated` set it.
pub about: Option<String>,
/// The id of the contact's profile picture. It changes when the picture does, so a client can keep a downloaded picture until this differs. From a lookup: what WhatsApp answered. From the contact list: the id wuapi last saw (a `contact.picture_updated` event, a lookup, or `GET …/contacts/{contactId}/picture`). `null` when unknown, when the contact has no picture or when it is hidden from this account.
#[serde(rename = "pictureId")]
pub picture_id: Option<String>,
/// Verified business name.
#[serde(rename = "businessName")]
pub business_name: Option<String>,
/// Devices linked to the contact. Only a lookup sets it.
#[serde(rename = "deviceCount")]
pub device_count: Option<i64>,
}
/// A page of `Contact` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactList {
/// Always `list`.
pub object: String,
pub items: Vec<Contact>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// A profile or group picture.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Picture {
/// Always `picture`.
pub object: String,
/// Picture id. It changes when the picture does: the same value as `pictureId` on the chat and the contact.
pub id: Option<String>,
/// Download URL. `null` right after an upload.
pub url: Option<String>,
/// `true` for the small preview.
pub preview: bool,
}
/// A WhatsApp Business profile.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BusinessProfile {
/// Always `business_profile`.
pub object: String,
#[serde(rename = "contactId")]
pub contact_id: String,
pub address: Option<String>,
pub email: Option<String>,
pub categories: Vec<BusinessProfileCategoriesItem>,
#[serde(rename = "profileOptions")]
pub profile_options: std::collections::BTreeMap<String, String>,
#[serde(rename = "timeZone")]
pub time_zone: Option<String>,
#[serde(rename = "businessHours")]
pub business_hours: Vec<BusinessProfileBusinessHoursItem>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BusinessProfileCategoriesItem {
pub id: String,
pub name: String,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BusinessProfileBusinessHoursItem {
#[serde(rename = "dayOfWeek")]
pub day_of_week: String,
pub mode: String,
/// Time of day.
#[serde(rename = "openTime")]
pub open_time: Option<String>,
/// Time of day.
#[serde(rename = "closeTime")]
pub close_time: Option<String>,
}
/// A blocked contact.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BlockedContact {
/// Always `blocked_contact`.
pub object: String,
/// The contact as WhatsApp keeps it in the blocklist: E.164 (`+584241112233`), or `lid:<digits>` when WhatsApp lists it by LID (more and more common).
#[serde(rename = "contactId")]
pub contact_id: String,
/// The contact's number (E.164) when the account knows it, the LID resolved. `null` otherwise.
pub phone: Option<String>,
/// The contact's LID (`lid:<digits>`) when the account knows it. `null` otherwise.
pub lid: Option<String>,
}
/// A page of `BlockedContact` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BlockedContactList {
/// Always `list`.
pub object: String,
pub items: Vec<BlockedContact>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// The account's own contact QR link.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactLink {
/// Always `contact_link`.
pub object: String,
pub url: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct LinkResolveRequest {
/// - `contact`: A contact QR link.
/// - `business`: A business message link.
pub kind: LinkResolveRequestKind,
/// The code or the full link.
pub code: String,
}
impl LinkResolveRequest {
/// A `LinkResolveRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(kind: LinkResolveRequestKind, code: impl Into<String>) -> Self {
Self {
kind,
code: code.into(),
}
}
}
string_enum! {
pub enum LinkResolveRequestKind {
/// `contact`
Contact = "contact",
/// `business`
Business = "business",
@unknown Unknown,
}
}
/// Who a link points to.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ResolvedLink {
/// Always `resolved_link`.
pub object: String,
pub kind: ResolvedLinkKind,
#[serde(rename = "contactId")]
pub contact_id: Option<String>,
/// Contact links: the contact type.
pub r#type: Option<String>,
#[serde(rename = "profileName")]
pub profile_name: Option<String>,
/// Business links.
#[serde(rename = "businessName")]
pub business_name: Option<String>,
/// Business links.
#[serde(rename = "verifiedLevel")]
pub verified_level: Option<String>,
/// Business links: the prefilled message.
#[serde(rename = "prefilledText")]
pub prefilled_text: Option<String>,
}
string_enum! {
pub enum ResolvedLinkKind {
/// `contact`
Contact = "contact",
/// `business`
Business = "business",
@unknown Unknown,
}
}
/// A WhatsApp AI bot.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Bot {
/// Always `bot`.
pub object: String,
pub id: String,
#[serde(rename = "personaId")]
pub persona_id: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
pub category: Option<String>,
pub default: bool,
pub prompts: Vec<String>,
pub commands: Vec<BotCommandsItem>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BotCommandsItem {
pub name: String,
pub description: Option<String>,
}
/// A page of `Bot` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BotList {
/// Always `list`.
pub object: String,
pub items: Vec<Bot>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// Provide `about`, `name` or both.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct ProfileUpdateRequest {
/// The About text.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub about: Option<String>,
/// Display name.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
/// Exactly one of `url` (https, fetched by our servers) or `base64` (JPEG).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum PictureUploadRequest {
PictureUploadRequestVariant1(PictureUploadRequestVariant1),
PictureUploadRequestVariant2(PictureUploadRequestVariant2),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<PictureUploadRequestVariant1> for PictureUploadRequest {
fn from(value: PictureUploadRequestVariant1) -> Self {
Self::PictureUploadRequestVariant1(value)
}
}
impl From<PictureUploadRequestVariant2> for PictureUploadRequest {
fn from(value: PictureUploadRequestVariant2) -> Self {
Self::PictureUploadRequestVariant2(value)
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PictureUploadRequestVariant1 {
pub url: String,
}
impl PictureUploadRequestVariant1 {
/// A `PictureUploadRequestVariant1` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PictureUploadRequestVariant2 {
pub base64: String,
}
impl PictureUploadRequestVariant2 {
/// A `PictureUploadRequestVariant2` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(base64: impl Into<String>) -> Self {
Self {
base64: base64.into(),
}
}
}
/// The account's privacy settings, with WhatsApp's values (`all`, `contacts`, `contact_blacklist`, `none`, ...).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PrivacySettings {
/// Always `privacy_settings`.
pub object: String,
/// Who can add the account to groups.
#[serde(rename = "groupAdd")]
pub group_add: Option<String>,
#[serde(rename = "lastSeen")]
pub last_seen: Option<String>,
/// Who sees the account's stories.
pub stories: Option<String>,
/// Who sees the profile picture.
pub profile: Option<String>,
#[serde(rename = "readReceipts")]
pub read_receipts: Option<String>,
pub online: Option<String>,
#[serde(rename = "callAdd")]
pub call_add: Option<String>,
pub messages: Option<String>,
pub defense: Option<String>,
pub stickers: Option<String>,
}
/// Any of the settings, with WhatsApp's values (`readReceipts`: `all` or `none`). Each setting is one change on WhatsApp.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct PrivacyUpdateRequest {
#[serde(rename = "groupAdd", default, skip_serializing_if = "Option::is_none")]
pub group_add: Option<String>,
#[serde(rename = "lastSeen", default, skip_serializing_if = "Option::is_none")]
pub last_seen: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub stories: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub profile: Option<String>,
#[serde(rename = "readReceipts", default, skip_serializing_if = "Option::is_none")]
pub read_receipts: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub online: Option<String>,
#[serde(rename = "callAdd", default, skip_serializing_if = "Option::is_none")]
pub call_add: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub messages: Option<String>,
}
/// Who sees the account's stories.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct StoryPrivacy {
/// Always `story_privacy`.
pub object: String,
pub lists: Vec<StoryPrivacyListsItem>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct StoryPrivacyListsItem {
/// - `contacts`: All contacts.
/// - `blacklist`: All contacts except `contactIds`.
/// - `whitelist`: Only `contactIds`.
pub r#type: StoryPrivacyListsItemType,
#[serde(rename = "contactIds")]
pub contact_ids: Vec<String>,
/// The list in use.
pub default: bool,
}
string_enum! {
pub enum StoryPrivacyListsItemType {
/// `contacts`
Contacts = "contacts",
/// `blacklist`
Blacklist = "blacklist",
/// `whitelist`
Whitelist = "whitelist",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CallRejectRequest {
/// The caller, as in the `call.received` event (`data.object.from`).
pub from: String,
}
impl CallRejectRequest {
/// A `CallRejectRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(from: impl Into<String>) -> Self {
Self {
from: from.into(),
}
}
}
/// A sticker pack.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct StickerPack {
/// Always `sticker_pack`.
pub object: String,
pub id: String,
pub name: String,
pub publisher: String,
pub description: Option<String>,
pub animated: bool,
#[serde(rename = "trayImageId")]
pub tray_image_id: Option<String>,
pub stickers: Vec<StickerPackStickersItem>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct StickerPackStickersItem {
pub url: Option<String>,
#[serde(rename = "directPath")]
pub direct_path: Option<String>,
#[serde(rename = "sizeBytes")]
pub size_bytes: i64,
#[serde(rename = "mimeType")]
pub mime_type: Option<String>,
pub width: i64,
pub height: i64,
pub emojis: Vec<String>,
}
/// A catalog order.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Order {
/// Always `order`.
pub object: String,
pub id: String,
/// Lowercase ISO 4217.
pub currency: String,
/// In cents (minor units).
#[serde(rename = "subtotalCents")]
pub subtotal_cents: i64,
#[serde(rename = "totalCents")]
pub total_cents: i64,
pub products: Vec<OrderProductsItem>,
#[serde(rename = "createdAt")]
pub created_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct OrderProductsItem {
pub id: String,
pub name: String,
pub quantity: i64,
#[serde(rename = "priceCents")]
pub price_cents: i64,
pub currency: String,
#[serde(rename = "imageUrl")]
pub image_url: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupParticipant {
/// A contact id: E.164 (`+584241112233`), or `lid:<digits>` when WhatsApp hides the number.
#[serde(rename = "contactId")]
pub contact_id: String,
/// The member's name as this account knows it.
pub name: Option<String>,
/// - `member`: A member.
/// - `admin`: An admin.
/// - `owner`: The creator (super admin).
pub role: GroupParticipantRole,
}
string_enum! {
pub enum GroupParticipantRole {
/// `member`
Member = "member",
/// `admin`
Admin = "admin",
/// `owner`
Owner = "owner",
@unknown Unknown,
}
}
/// A WhatsApp group, read live from WhatsApp.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Group {
/// Always `group`.
pub object: String,
/// Group id (`...@g.us`).
pub id: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
pub name: String,
pub description: Option<String>,
/// The creator's contact id.
#[serde(rename = "ownerId")]
pub owner_id: Option<String>,
/// A community: it links other groups (its subgroups).
pub community: bool,
/// Only admins can edit the group info.
pub locked: bool,
/// Only admins can send.
pub announce: bool,
pub participants: Vec<GroupParticipant>,
#[serde(rename = "createdAt")]
pub created_at: Option<String>,
}
/// A page of `Group` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupList {
/// Always `list`.
pub object: String,
pub items: Vec<Group>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupCreateRequest {
pub name: String,
/// Contact ids. Required and non-empty unless `community` is true.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub participants: Option<Vec<String>>,
/// Create a community instead of a group; `participants` may be empty.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub community: Option<bool>,
}
impl GroupCreateRequest {
/// A `GroupCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
participants: None,
community: None,
}
}
}
/// Provide at least one field.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct GroupUpdateRequest {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// Only admins can send.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub announce: Option<bool>,
/// Only admins can edit the group info.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub locked: Option<bool>,
/// New members need admin approval.
#[serde(rename = "joinApproval", default, skip_serializing_if = "Option::is_none")]
pub join_approval: Option<bool>,
/// - `admins`: Only admins add members.
/// - `all_members`: Any member adds members.
#[serde(rename = "memberAddMode", default, skip_serializing_if = "Option::is_none")]
pub member_add_mode: Option<GroupUpdateRequestMemberAddMode>,
}
string_enum! {
pub enum GroupUpdateRequestMemberAddMode {
/// `admins`
Admins = "admins",
/// `all_members`
AllMembers = "all_members",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactIdsRequest {
/// 1 to 256 contact ids.
#[serde(rename = "contactIds")]
pub contact_ids: Vec<String>,
}
impl ContactIdsRequest {
/// A `ContactIdsRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(contact_ids: Vec<String>) -> Self {
Self {
contact_ids,
}
}
}
/// The outcome for one contact.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ParticipantResult {
/// Always `participant_result`.
pub object: String,
#[serde(rename = "contactId")]
pub contact_id: String,
/// Why this contact failed, for example `privacy_restricted`, `already_member`, `not_on_whatsapp`. `null` when it worked.
pub error: Option<String>,
/// Returned instead of an add when the person must be invited.
#[serde(rename = "inviteCode")]
pub invite_code: Option<String>,
}
/// A page of `ParticipantResult` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ParticipantResultList {
/// Always `list`.
pub object: String,
pub items: Vec<ParticipantResult>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// A group's invite link.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupInviteLink {
/// Always `group_invite_link`.
pub object: String,
#[serde(rename = "groupId")]
pub group_id: String,
pub url: String,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct JoinGroupRequest {
/// The invite code or the full `https://chat.whatsapp.com/...` link.
pub code: String,
}
impl JoinGroupRequest {
/// A `JoinGroupRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(code: impl Into<String>) -> Self {
Self {
code: code.into(),
}
}
}
/// The group the account joined.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupJoin {
/// Always `group_join`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// The group joined.
#[serde(rename = "groupId")]
pub group_id: Option<String>,
}
/// A request to join a group that needs approval.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupJoinRequest {
/// Always `group_join_request`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "groupId")]
pub group_id: String,
/// A contact id: E.164 (`+584241112233`), or `lid:<digits>` when WhatsApp hides the number.
#[serde(rename = "contactId")]
pub contact_id: String,
#[serde(rename = "requestedAt")]
pub requested_at: Option<String>,
}
/// A page of `GroupJoinRequestItem` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupJoinRequestList {
/// Always `list`.
pub object: String,
pub items: Vec<GroupJoinRequest>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// A group linked to a community.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Subgroup {
/// Always `subgroup`.
pub object: String,
pub id: String,
pub name: String,
/// The community's announcement group.
pub default: bool,
}
/// A page of `Subgroup` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SubgroupList {
/// Always `list`.
pub object: String,
pub items: Vec<Subgroup>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct SubgroupLinkRequest {
/// The group to link into the community (`...@g.us`).
#[serde(rename = "groupId")]
pub group_id: String,
}
impl SubgroupLinkRequest {
/// A `SubgroupLinkRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(group_id: impl Into<String>) -> Self {
Self {
group_id: group_id.into(),
}
}
}
/// A member of a community's linked groups.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CommunityParticipant {
/// Always `community_participant`.
pub object: String,
/// A contact id: E.164 (`+584241112233`), or `lid:<digits>` when WhatsApp hides the number.
#[serde(rename = "contactId")]
pub contact_id: String,
}
/// A page of `CommunityParticipant` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CommunityParticipantList {
/// Always `list`.
pub object: String,
pub items: Vec<CommunityParticipant>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// A WhatsApp channel.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Channel {
/// Always `channel`.
pub object: String,
/// Channel id (`...@newsletter`).
pub id: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
pub name: String,
pub description: Option<String>,
#[serde(rename = "inviteCode")]
pub invite_code: Option<String>,
#[serde(rename = "subscriberCount")]
pub subscriber_count: i64,
pub verified: bool,
/// WhatsApp's state of the channel, for example `active`.
pub status: Option<String>,
/// The account's role: `owner`, `admin`, `subscriber`, ...
pub role: Option<String>,
pub muted: bool,
#[serde(rename = "pictureUrl")]
pub picture_url: Option<String>,
#[serde(rename = "previewUrl")]
pub preview_url: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: Option<String>,
}
/// A page of `Channel` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelList {
/// Always `list`.
pub object: String,
pub items: Vec<Channel>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelCreateRequest {
pub name: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// JPEG, base64.
#[serde(rename = "pictureBase64", default, skip_serializing_if = "Option::is_none")]
pub picture_base64: Option<String>,
}
impl ChannelCreateRequest {
/// A `ChannelCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
description: None,
picture_base64: None,
}
}
}
/// A message in a channel, read live from WhatsApp.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelMessage {
/// Always `channel_message`.
pub object: String,
/// WhatsApp's server id of the message in the channel.
pub id: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "channelId")]
pub channel_id: String,
pub r#type: String,
pub text: Option<String>,
#[serde(rename = "viewCount")]
pub view_count: Option<i64>,
/// Count per emoji.
pub reactions: std::collections::BTreeMap<String, i64>,
#[serde(rename = "sentAt")]
pub sent_at: Option<String>,
}
/// A page of `ChannelMessage` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelMessageList {
/// Always `list`.
pub object: String,
pub items: Vec<ChannelMessage>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MarkViewedRequest {
/// 1 to 100 channel message ids.
#[serde(rename = "channelMessageIds")]
pub channel_message_ids: Vec<String>,
}
impl MarkViewedRequest {
/// A `MarkViewedRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(channel_message_ids: Vec<String>) -> Self {
Self {
channel_message_ids,
}
}
}
string_enum! {
/// Event types. See the Webhooks tag for when each fires.
pub enum WebhookEventType {
/// `account.qr_code_issued`
AccountQrCodeIssued = "account.qr_code_issued",
/// `account.pairing_code_issued`
AccountPairingCodeIssued = "account.pairing_code_issued",
/// `account.connected`
AccountConnected = "account.connected",
/// `account.disconnected`
AccountDisconnected = "account.disconnected",
/// `account.failed`
AccountFailed = "account.failed",
/// `message.received`
MessageReceived = "message.received",
/// `message.sent`
MessageSent = "message.sent",
/// `message.delivered`
MessageDelivered = "message.delivered",
/// `message.read`
MessageRead = "message.read",
/// `message.failed`
MessageFailed = "message.failed",
/// `message.edited`
MessageEdited = "message.edited",
/// `message.deleted`
MessageDeleted = "message.deleted",
/// `message.media_downloaded`
MessageMediaDownloaded = "message.media_downloaded",
/// `poll.voted`
PollVoted = "poll.voted",
/// `group.joined`
GroupJoined = "group.joined",
/// `group.updated`
GroupUpdated = "group.updated",
/// `group.join_requested`
GroupJoinRequested = "group.join_requested",
/// `group.join_request_revoked`
GroupJoinRequestRevoked = "group.join_request_revoked",
/// `chat.updated`
ChatUpdated = "chat.updated",
/// `chat.presence_updated`
ChatPresenceUpdated = "chat.presence_updated",
/// `contact.presence_updated`
ContactPresenceUpdated = "contact.presence_updated",
/// `contact.picture_updated`
ContactPictureUpdated = "contact.picture_updated",
/// `contact.updated`
ContactUpdated = "contact.updated",
/// `blocklist.updated`
BlocklistUpdated = "blocklist.updated",
/// `label.updated`
LabelUpdated = "label.updated",
/// `call.received`
CallReceived = "call.received",
/// `call.ended`
CallEnded = "call.ended",
/// `channel.message_received`
ChannelMessageReceived = "channel.message_received",
/// `channel.message_updated`
ChannelMessageUpdated = "channel.message_updated",
/// `channel.updated`
ChannelUpdated = "channel.updated",
/// `history.synced`
HistorySynced = "history.synced",
/// `project.created`
ProjectCreated = "project.created",
/// `project.updated`
ProjectUpdated = "project.updated",
/// `project.deleted`
ProjectDeleted = "project.deleted",
/// `invitation.status_changed`
InvitationStatusChanged = "invitation.status_changed",
/// `webhook.test`
WebhookTest = "webhook.test",
@unknown Unknown,
}
}
/// A URL that receives events.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct WebhookEndpoint {
/// Always `webhook_endpoint`.
pub object: String,
pub id: String,
/// `null`: an organization endpoint, which receives every project's events. Set: a project endpoint, which receives only that project's events.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub url: String,
pub events: Vec<WebhookEventType>,
/// Inactive endpoints receive nothing.
pub active: bool,
/// Signing secret (`whsec_...`). Returned only by create and rotate-secret.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub secret: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "updatedAt")]
pub updated_at: String,
}
/// A page of `WebhookEndpoint` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct WebhookEndpointList {
/// Always `list`.
pub object: String,
pub items: Vec<WebhookEndpoint>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct WebhookEndpointCreateRequest {
/// Public https URL.
pub url: String,
pub events: Vec<WebhookEventType>,
/// Organization keys only: make it a project endpoint (id or `ext:<externalId>`). Implied by a project scope.
#[serde(rename = "projectId", default, skip_serializing_if = "Option::is_none")]
pub project_id: Option<String>,
}
impl WebhookEndpointCreateRequest {
/// A `WebhookEndpointCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(url: impl Into<String>, events: Vec<WebhookEventType>) -> Self {
Self {
url: url.into(),
events,
project_id: None,
}
}
}
/// Provide at least one field.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct WebhookEndpointUpdateRequest {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<WebhookEventType>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub active: Option<bool>,
}
/// A calendar month in UTC.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Period {
#[serde(rename = "startsAt")]
pub starts_at: String,
#[serde(rename = "endsAt")]
pub ends_at: String,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct UsageLine {
/// Accounts billable right now.
#[serde(rename = "billableAccountCount")]
pub billable_account_count: i64,
/// Accounts that are not deleted, right now.
#[serde(rename = "accountCount")]
pub account_count: i64,
/// Proxy traffic in the month, in bytes.
#[serde(rename = "proxyBytes")]
pub proxy_bytes: i64,
/// API sends WhatsApp accepted, plus messages sent from the phone and seen live, in the month.
#[serde(rename = "sentMessageCount")]
pub sent_message_count: i64,
/// Contacts' messages seen live in the month. History imports count for neither.
#[serde(rename = "receivedMessageCount")]
pub received_message_count: i64,
}
/// Billable usage for the current calendar month (UTC).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Usage {
/// Always `usage`.
pub object: String,
pub period: Period,
/// Always `usd`.
pub currency: String,
/// Accounts billable right now.
#[serde(rename = "billableAccountCount")]
pub billable_account_count: i64,
/// Price of the band the last billable account falls in: 600 for account 1, 450 each for 2-50, 350 each from the 51st. Bands are graduated: each account is billed at its own band's price.
#[serde(rename = "accountUnitPriceCents")]
pub account_unit_price_cents: i64,
/// The graduated total for `billableAccountCount` accounts: 600 for account 1, 450 each for 2-50, 350 each from the 51st.
#[serde(rename = "accountFeeCents")]
pub account_fee_cents: i64,
/// Every byte of residential proxy traffic this month, included or not, traffic used on the Free plan included.
#[serde(rename = "proxyBytes")]
pub proxy_bytes: i64,
/// This month's pooled proxy allowance: 0.5 GB (536870912 bytes) per billable account, counted at the most accounts billable this month.
#[serde(rename = "includedProxyBytes")]
pub included_proxy_bytes: i64,
/// Proxy bytes past `includedProxyBytes`, leaving out traffic used on the Free plan (or during a legacy free trial). `proxyFeeCents` bills these only.
#[serde(rename = "billableProxyBytes")]
pub billable_proxy_bytes: i64,
/// `billableProxyBytes` at $0.99 per GB (1 GB = 1024^3 bytes), rounded to the cent. Traffic within the allowance costs nothing.
#[serde(rename = "proxyFeeCents")]
pub proxy_fee_cents: i64,
/// `accountFeeCents` + `proxyFeeCents`.
#[serde(rename = "totalCents")]
pub total_cents: i64,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct UsageReportProject {
#[serde(rename = "projectId")]
pub project_id: String,
#[serde(rename = "externalId")]
pub external_id: Option<String>,
pub name: String,
/// Accounts billable right now.
#[serde(rename = "billableAccountCount")]
pub billable_account_count: i64,
/// Accounts that are not deleted, right now.
#[serde(rename = "accountCount")]
pub account_count: i64,
/// Proxy traffic in the month, in bytes.
#[serde(rename = "proxyBytes")]
pub proxy_bytes: i64,
/// API sends WhatsApp accepted, plus messages sent from the phone and seen live, in the month.
#[serde(rename = "sentMessageCount")]
pub sent_message_count: i64,
/// Contacts' messages seen live in the month. History imports count for neither.
#[serde(rename = "receivedMessageCount")]
pub received_message_count: i64,
}
/// The rebilling export: one line per project, plus unassigned resources and totals.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct UsageReport {
/// Always `usage_report`.
pub object: String,
pub period: Period,
/// Every live project, plus deleted projects that used something in the month.
pub projects: Vec<UsageReportProject>,
pub unassigned: UsageLine,
pub totals: UsageLine,
}
/// A project's usage.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProjectUsage {
/// Always `project_usage`.
pub object: String,
#[serde(rename = "projectId")]
pub project_id: String,
pub period: Period,
/// Accounts billable right now.
#[serde(rename = "billableAccountCount")]
pub billable_account_count: i64,
/// Accounts that are not deleted, right now.
#[serde(rename = "accountCount")]
pub account_count: i64,
/// Proxy traffic in the month, in bytes.
#[serde(rename = "proxyBytes")]
pub proxy_bytes: i64,
/// API sends WhatsApp accepted, plus messages sent from the phone and seen live, in the month.
#[serde(rename = "sentMessageCount")]
pub sent_message_count: i64,
/// Contacts' messages seen live in the month. History imports count for neither.
#[serde(rename = "receivedMessageCount")]
pub received_message_count: i64,
}
string_enum! {
/// - `active`: Normal.
/// - `suspended`: Accounts stay linked and keep receiving; every send and write answers `403 project_suspended`.
pub enum ProjectStatus {
/// `active`
Active = "active",
/// `suspended`
Suspended = "suspended",
@unknown Unknown,
}
}
/// A customer of your platform, or an environment.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Project {
/// Always `project`.
pub object: String,
pub id: String,
pub name: String,
/// Your own id for this customer, unique among live projects.
#[serde(rename = "externalId")]
pub external_id: Option<String>,
pub metadata: std::collections::BTreeMap<String, String>,
pub status: ProjectStatus,
/// Account limit. `null` means no limit.
#[serde(rename = "maxAccounts")]
pub max_accounts: Option<i64>,
/// Accounts that are not deleted.
#[serde(rename = "accountCount")]
pub account_count: i64,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "updatedAt")]
pub updated_at: String,
}
/// A page of `Project` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProjectList {
/// Always `list`.
pub object: String,
pub items: Vec<Project>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProjectCreateRequest {
pub name: String,
/// 1 to 128 characters: letters, digits and `. _ : @ -`.
#[serde(rename = "externalId", default, skip_serializing_if = "Option::is_none")]
pub external_id: Option<String>,
/// Up to 50 string values; keys 1-64 printable ASCII characters not starting with `$` or `_`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
#[serde(rename = "maxAccounts", default, skip_serializing_if = "Option::is_none")]
pub max_accounts: Option<i64>,
}
impl ProjectCreateRequest {
/// A `ProjectCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
external_id: None,
metadata: None,
max_accounts: None,
}
}
}
/// Provide at least one field.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct ProjectUpdateRequest {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// `null` clears it.
#[serde(rename = "externalId", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub external_id: Option<Option<String>>,
/// Replaces the whole metadata object.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
/// `null` removes the limit.
#[serde(rename = "maxAccounts", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub max_accounts: Option<Option<i64>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub status: Option<ProjectStatus>,
}
/// An API key. The key itself is shown once.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ApiKey {
/// Always `api_key`.
pub object: String,
pub id: String,
pub name: String,
/// Set for a project key, which reaches only that project.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
#[serde(rename = "keyPrefix")]
pub key_prefix: String,
pub last4: String,
/// The key itself. Returned only when it is created.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub key: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "lastUsedAt")]
pub last_used_at: Option<String>,
#[serde(rename = "revokedAt")]
pub revoked_at: Option<String>,
}
/// A page of `ApiKey` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ApiKeyList {
/// Always `list`.
pub object: String,
pub items: Vec<ApiKey>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ApiKeyCreateRequest {
pub name: String,
}
impl ApiKeyCreateRequest {
/// A `ApiKeyCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
}
}
}
string_enum! {
/// - `pending`: Created or resent.
/// - `in_progress`: The invitee started linking and the account exists.
/// - `completed`: The account reached `ready`.
/// - `failed`: Linking stopped (`failureReason`); the link keeps working and a retry reuses the account.
/// - `cancelled`: Cancelled by you.
/// - `expired`: Pending or failed past `expiresAt`. Computed on read, never stored.
pub enum InvitationStatus {
/// `pending`
Pending = "pending",
/// `in_progress`
InProgress = "in_progress",
/// `completed`
Completed = "completed",
/// `failed`
Failed = "failed",
/// `cancelled`
Cancelled = "cancelled",
/// `expired`
Expired = "expired",
@unknown Unknown,
}
}
string_enum! {
/// - `qr_code`: Scan a live QR code.
/// - `pairing_code`: Type an 8-character pairing code on the phone.
pub enum InvitationMethod {
/// `qr_code`
QrCode = "qr_code",
/// `pairing_code`
PairingCode = "pairing_code",
@unknown Unknown,
}
}
/// A hosted page someone else opens to link their own number into a project.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Invitation {
/// Always `invitation`.
pub object: String,
pub id: String,
/// Project the resource belongs to, `null` when it is in no project. Set at creation and never changes.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub status: InvitationStatus,
/// The page to send. Returned only by create and resend: the token is stored hashed and cannot be shown again.
pub url: Option<String>,
/// Shown on the page as "Setting up for ...".
#[serde(rename = "inviteeName")]
pub invitee_name: Option<String>,
/// Where the invitation email goes.
#[serde(rename = "inviteeEmail")]
pub invitee_email: Option<String>,
/// E.164. Preselects the country and prefills the pairing code form.
#[serde(rename = "inviteePhone")]
pub invitee_phone: Option<String>,
/// ISO 3166-1 alpha-2 preselected on the page.
#[serde(rename = "suggestedCountry")]
pub suggested_country: Option<String>,
/// Where the account's residential proxy will exit: set on create, or picked by the invitee on the page before the QR code or pairing code is shown. `null` until then.
#[serde(rename = "proxyLocation")]
pub proxy_location: Option<ProxyLocationResource>,
/// Linking methods the page offers.
pub methods: Vec<InvitationMethod>,
/// The `historySync` of the account the invitee links.
#[serde(rename = "historySync")]
pub history_sync: HistorySyncSetting,
/// Name the account gets. Default: `inviteeName`, else the WhatsApp profile name.
#[serde(rename = "accountName")]
pub account_name: Option<String>,
/// The account created for the invitee. Set once `status` is `completed`.
#[serde(rename = "accountId")]
pub account_id: Option<String>,
/// Why linking stopped, while `status` is `failed`: `abandoned` (in progress for 1 hour without linking), `qr_timeout`, `logged_out`, `temporary_ban`, `connect_failed` or `account_deleted`.
#[serde(rename = "failureReason")]
pub failure_reason: Option<String>,
/// After linking, the page links back here with `?invitation_id=...&account_id=...`.
#[serde(rename = "returnUrl")]
pub return_url: Option<String>,
/// Copied onto the account on completion.
pub metadata: std::collections::BTreeMap<String, String>,
/// When the invitation email was last queued. `null` without an email, or when email is not enabled: send `url` yourself.
#[serde(rename = "emailSentAt")]
pub email_sent_at: Option<String>,
#[serde(rename = "expiresAt")]
pub expires_at: String,
/// First time the page was opened.
#[serde(rename = "viewedAt")]
pub viewed_at: Option<String>,
/// Last time the invitee started linking.
#[serde(rename = "startedAt")]
pub started_at: Option<String>,
#[serde(rename = "completedAt")]
pub completed_at: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "updatedAt")]
pub updated_at: String,
}
/// A page of `Invitation` objects.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct InvitationList {
/// Always `list`.
pub object: String,
pub items: Vec<Invitation>,
/// Pass as `cursor` to get the next page. `null` on the last page.
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
}
/// Every field is optional. The subscription gate, suspension and the project's `maxAccounts` are checked now and again when the invitee starts.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct InvitationCreateRequest {
/// Organization keys: the project the account lands in (id or `ext:<externalId>`). A project key invites into its own project.
#[serde(rename = "projectId", default, skip_serializing_if = "Option::is_none")]
pub project_id: Option<String>,
/// Name of the account created on completion.
#[serde(rename = "accountName", default, skip_serializing_if = "Option::is_none")]
pub account_name: Option<String>,
#[serde(rename = "inviteeName", default, skip_serializing_if = "Option::is_none")]
pub invitee_name: Option<String>,
/// With an email, the invitation is emailed when email is enabled (see `emailSentAt`).
#[serde(rename = "inviteeEmail", default, skip_serializing_if = "Option::is_none")]
pub invitee_email: Option<String>,
/// E.164.
#[serde(rename = "inviteePhone", default, skip_serializing_if = "Option::is_none")]
pub invitee_phone: Option<String>,
/// ISO 3166-1 alpha-2 preselected on the page when `proxyLocation` is not set. Derived from `inviteePhone` when absent.
#[serde(rename = "suggestedCountry", default, skip_serializing_if = "Option::is_none")]
pub suggested_country: Option<String>,
/// Preset where the account's proxy exits: a pair from `GET /v1/proxy-locations`. Without it the invitee picks the country and city on the page. Not in the catalog: `400 unsupported_proxy_location`.
#[serde(rename = "proxyLocation", default, skip_serializing_if = "Option::is_none")]
pub proxy_location: Option<ProxyLocationInput>,
/// Default both.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub methods: Option<Vec<InvitationMethod>>,
/// Import the recent chats the invitee's phone sends when the number links: `recent`. Default `none`.
#[serde(rename = "historySync", default, skip_serializing_if = "Option::is_none")]
pub history_sync: Option<HistorySyncSetting>,
/// https.
#[serde(rename = "returnUrl", default, skip_serializing_if = "Option::is_none")]
pub return_url: Option<String>,
/// Default: `7`.
#[serde(rename = "expiresInDays", default, skip_serializing_if = "Option::is_none")]
pub expires_in_days: Option<i64>,
/// Up to 20 string values, keys 1 to 40 characters. Copied onto the account on completion.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::BTreeMap<String, String>>,
}
/// What the invitation page and email show.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Branding {
/// Always `branding`.
pub object: String,
/// Shown on the invitation page and email. `null` until set.
#[serde(rename = "displayName")]
pub display_name: Option<String>,
/// The logo the page and email show: a file uploaded in the dashboard when there is one, else the https URL you set.
#[serde(rename = "logoUrl")]
pub logo_url: Option<String>,
/// `#RRGGBB`.
#[serde(rename = "accentColor")]
pub accent_color: Option<String>,
#[serde(rename = "supportUrl")]
pub support_url: Option<String>,
/// Whether the "Powered by wuapi" footer is hidden right now: your setting, and only while the White label add-on is active.
#[serde(rename = "hideWuapiBranding")]
pub hide_wuapi_branding: bool,
}
/// Provide at least one field.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
pub struct BrandingUpdateRequest {
/// 1 to 60 characters after trimming. It cannot be cleared. Required while the organization has no branding yet: the first update without it answers `400 invalid_request` with `details.field: displayName`.
#[serde(rename = "displayName", default, skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
/// https URL; `null` clears it. Either one replaces a logo uploaded in the dashboard.
#[serde(rename = "logoUrl", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub logo_url: Option<Option<String>>,
/// `#RRGGBB`; `null` clears it.
#[serde(rename = "accentColor", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub accent_color: Option<Option<String>>,
/// https URL; `null` clears it.
#[serde(rename = "supportUrl", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub support_url: Option<Option<String>>,
/// Hide the "Powered by wuapi" footer on the page and the email line. `true` needs the White label add-on (`402 addon_required` without it); `false` always works.
#[serde(rename = "hideWuapiBranding", default, skip_serializing_if = "Option::is_none")]
pub hide_wuapi_branding: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Organization {
pub object: String,
pub id: String,
pub name: String,
}
/// The organization, API key and project behind the current request.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AuthContext {
/// Always `auth_context`.
pub object: String,
pub organization: Organization,
#[serde(rename = "apiKey")]
pub api_key: ApiKey,
/// The project this request is scoped to (from the key or `Wuapi-Project`). `null` for the whole organization.
pub project: Option<Project>,
}
/// A vote in a poll.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PollVote {
/// Always `poll_vote`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "chatId")]
pub chat_id: Option<String>,
/// The poll's wuapi id, when wuapi stores it.
#[serde(rename = "messageId")]
pub message_id: Option<String>,
/// A contact id: E.164 (`+584241112233`), or `lid:<digits>` when WhatsApp hides the number.
#[serde(rename = "voterId")]
pub voter_id: String,
/// Option names; empty when the vote was retracted or the poll is unknown to the engine.
pub options: Vec<String>,
#[serde(rename = "votedAt")]
pub voted_at: String,
/// The poll with its new tally, when wuapi stores it.
pub poll: Option<Message>,
}
/// A change to a group. Fields that did not change are `null` or empty.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupChange {
/// Always `group_change`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "groupId")]
pub group_id: String,
/// Who made the change, when WhatsApp says.
#[serde(rename = "actorId")]
pub actor_id: Option<String>,
pub added: Vec<String>,
pub removed: Vec<String>,
pub promoted: Vec<String>,
pub demoted: Vec<String>,
/// The new name, when it changed.
pub name: Option<String>,
/// The new description, when it changed.
pub description: Option<String>,
pub locked: Option<bool>,
pub announce: Option<bool>,
/// What moved.
pub changes: Vec<GroupChangeChangesItem>,
#[serde(rename = "changedAt")]
pub changed_at: Option<String>,
}
string_enum! {
pub enum GroupChangeChangesItem {
/// `participants_added`
ParticipantsAdded = "participants_added",
/// `participants_removed`
ParticipantsRemoved = "participants_removed",
/// `admins_changed`
AdminsChanged = "admins_changed",
/// `name`
Name = "name",
/// `description`
Description = "description",
/// `settings`
Settings = "settings",
@unknown Unknown,
}
}
/// A chat changed on the phone or another device.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatChange {
/// Always `chat_change`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "chatId")]
pub chat_id: String,
pub change: ChatChangeChange,
/// The new value (`true` = archived, pinned, muted, read, starred).
pub value: Option<bool>,
/// Star changes: the wuapi id of the message, when stored.
#[serde(rename = "messageId")]
pub message_id: Option<String>,
/// Mute changes: when the mute ends. `null` for a mute with no end.
#[serde(rename = "muteExpiresAt")]
pub mute_expires_at: Option<String>,
/// Never set by the server: use `muteExpiresAt`. Kept for SDK compatibility.
///
/// **Deprecated.**
#[serde(rename = "mutedUntil", default, skip_serializing_if = "Option::is_none", deserialize_with = "crate::serde_helpers::double_option")]
pub muted_until: Option<Option<String>>,
}
string_enum! {
pub enum ChatChangeChange {
/// `archive`
Archive = "archive",
/// `pin`
Pin = "pin",
/// `mute`
Mute = "mute",
/// `read`
Read = "read",
/// `delete`
Delete = "delete",
/// `clear`
Clear = "clear",
/// `star`
Star = "star",
@unknown Unknown,
}
}
/// A contact is typing or recording in a chat.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatPresence {
/// Always `chat_presence`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "chatId")]
pub chat_id: String,
#[serde(rename = "contactId")]
pub contact_id: String,
pub state: ChatPresenceState,
}
string_enum! {
pub enum ChatPresenceState {
/// `typing`
Typing = "typing",
/// `recording`
Recording = "recording",
/// `paused`
Paused = "paused",
@unknown Unknown,
}
}
/// A subscribed contact came online or went offline.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactPresence {
/// Always `contact_presence`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "contactId")]
pub contact_id: String,
pub online: bool,
/// When shared.
#[serde(rename = "lastSeenAt")]
pub last_seen_at: Option<String>,
}
/// A contact or group picture changed or was removed. `pictureId` of the chat (and of the contact) follows.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PictureChange {
/// Always `picture_change`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// The contact or group whose picture changed.
#[serde(rename = "chatId")]
pub chat_id: String,
#[serde(rename = "pictureId")]
pub picture_id: Option<String>,
pub removed: bool,
/// Who changed it (groups).
#[serde(rename = "changedBy")]
pub changed_by: Option<String>,
#[serde(rename = "changedAt")]
pub changed_at: Option<String>,
}
/// The blocklist changed.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BlocklistChange {
/// Always `blocklist_change`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// Who was blocked or unblocked. When WhatsApp only says the list changed, wuapi compares it with the list it saw before and names the changes.
pub changes: Vec<BlocklistChangeChangesItem>,
/// `true` (with `changes` empty) when WhatsApp gave no changes and there was no earlier list to compare with: call `GET .../blocklist`.
pub refetch: bool,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BlocklistChangeChangesItem {
/// The contact: E.164 when the account knows the number, `lid:<digits>` otherwise.
#[serde(rename = "contactId")]
pub contact_id: String,
pub action: BlocklistChangeChangesItemAction,
/// The contact's number (E.164) when known.
pub phone: Option<String>,
/// The contact's LID (`lid:<digits>`) when known.
pub lid: Option<String>,
}
string_enum! {
pub enum BlocklistChangeChangesItemAction {
/// `block`
Block = "block",
/// `unblock`
Unblock = "unblock",
@unknown Unknown,
}
}
/// A label was edited or (un)assigned.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct LabelChange {
/// Always `label_change`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// - `label`: The label itself was edited.
/// - `chat`: A chat was (un)labeled.
/// - `message`: A message was (un)labeled.
pub kind: LabelChangeKind,
#[serde(rename = "labelId")]
pub label_id: String,
pub name: Option<String>,
pub color: Option<i64>,
pub deleted: Option<bool>,
#[serde(rename = "chatId")]
pub chat_id: Option<String>,
/// The wuapi id of the message, when stored.
#[serde(rename = "messageId")]
pub message_id: Option<String>,
pub labeled: Option<bool>,
}
string_enum! {
pub enum LabelChangeKind {
/// `label`
Label = "label",
/// `chat`
Chat = "chat",
/// `message`
Message = "message",
@unknown Unknown,
}
}
/// A call to the account.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Call {
/// Always `call`.
pub object: String,
pub id: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
/// The caller's contact id.
pub from: String,
/// Reliable on `call.received` only.
pub video: bool,
/// Set for group calls.
#[serde(rename = "groupId")]
pub group_id: Option<String>,
/// Why it ended, on `call.ended`.
#[serde(rename = "endReason")]
pub end_reason: Option<String>,
/// When the call rang, on `call.received`.
#[serde(rename = "startedAt")]
pub started_at: Option<String>,
/// On `call.ended`.
#[serde(rename = "endedAt")]
pub ended_at: Option<String>,
}
/// The account followed, unfollowed, muted or unmuted a channel.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelChange {
/// Always `channel_change`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
#[serde(rename = "channelId")]
pub channel_id: String,
pub change: ChannelChangeChange,
/// On `followed`: the channel name.
pub name: Option<String>,
/// On `unfollowed`: the role the account had.
pub role: Option<String>,
}
string_enum! {
pub enum ChannelChangeChange {
/// `followed`
Followed = "followed",
/// `unfollowed`
Unfollowed = "unfollowed",
/// `muted`
Muted = "muted",
/// `unmuted`
Unmuted = "unmuted",
@unknown Unknown,
}
}
/// A part of the history the phone sent after linking was stored. Only for accounts with `historySync: recent`: history import is off by default.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct HistorySync {
/// Always `history_sync`.
pub object: String,
/// The account this belongs to.
#[serde(rename = "accountId")]
pub account_id: String,
pub chunk: Option<i64>,
#[serde(rename = "syncType")]
pub sync_type: Option<String>,
pub progress: Option<i64>,
pub part: Option<i64>,
#[serde(rename = "conversationCount")]
pub conversation_count: i64,
/// Messages stored (with `source: history`).
#[serde(rename = "messageCount")]
pub message_count: i64,
/// Already stored.
#[serde(rename = "duplicateCount")]
pub duplicate_count: i64,
}
/// Fired on real transitions: `account.qr_code_issued` when the account enters `qr_ready` (not on each QR rotation; poll the account for the current `qrCodeUrl`), `account.pairing_code_issued` when a new pairing code is issued, `account.disconnected` when the account loses its connection: at once when it does not recover on its own (`disconnectReason` `logged_out`, for example), or, for a drop the session reconnects from by itself, only if it is not `ready` again within a short reconnect grace (currently 20 seconds; `status` may then read `initializing` or `authenticating` while it keeps retrying), so a quick reconnect fires neither this nor `account.connected`; `account.connected` on `ready` (the first link, or back after `account.disconnected`), `account.failed` on `failed`. Deleting an account fires nothing.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AccountEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: AccountEventType,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: AccountEventData,
}
string_enum! {
pub enum AccountEventType {
/// `account.qr_code_issued`
AccountQrCodeIssued = "account.qr_code_issued",
/// `account.pairing_code_issued`
AccountPairingCodeIssued = "account.pairing_code_issued",
/// `account.connected`
AccountConnected = "account.connected",
/// `account.disconnected`
AccountDisconnected = "account.disconnected",
/// `account.failed`
AccountFailed = "account.failed",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AccountEventData {
pub object: Account,
}
/// `message.sent` also fires for messages sent from the phone (`source: phone`) and for stories and channel posts. `message.deleted` carries the row with `deletedAt` set and the content cleared. `message.media_downloaded` fires when wuapi stored, in the background, a received file the account's `mediaAutoDownload` wanted up front but WhatsApp did not hand over at first: `media.downloaded` is now `true` and `media.url` is the file. Files fetched by your own `GET /v1/messages/{messageId}/media` do not fire it.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: MessageEventType,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: MessageEventData,
}
string_enum! {
pub enum MessageEventType {
/// `message.received`
MessageReceived = "message.received",
/// `message.sent`
MessageSent = "message.sent",
/// `message.delivered`
MessageDelivered = "message.delivered",
/// `message.read`
MessageRead = "message.read",
/// `message.failed`
MessageFailed = "message.failed",
/// `message.deleted`
MessageDeleted = "message.deleted",
/// `message.media_downloaded`
MessageMediaDownloaded = "message.media_downloaded",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageEventData {
pub object: Message,
}
/// A message was edited, by the contact or by you. `data.object.text` is the new text (the new caption for media) and `previousAttributes.text` is the text before. An edit that reaches wuapi before the message it edits is applied when the message is stored, so `message.edited` always follows its `message.received`. With several edits, the latest wins.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageEditedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: MessageEditedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageEditedEventData {
pub object: Message,
#[serde(rename = "previousAttributes")]
pub previous_attributes: MessageEditedEventDataPreviousAttributes,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct MessageEditedEventDataPreviousAttributes {
pub text: Option<String>,
}
/// Someone voted in a poll.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PollVotedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: PollVotedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PollVotedEventData {
pub object: PollVote,
}
/// The account joined or created a group.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupJoinedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: GroupJoinedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupJoinedEventData {
pub object: Group,
}
/// A group changed.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: GroupUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupUpdatedEventData {
pub object: GroupChange,
}
/// Someone asked to join a group that needs approval, or withdrew the request.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupJoinRequestEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: GroupJoinRequestEventType,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: GroupJoinRequestEventData,
}
string_enum! {
pub enum GroupJoinRequestEventType {
/// `group.join_requested`
GroupJoinRequested = "group.join_requested",
/// `group.join_request_revoked`
GroupJoinRequestRevoked = "group.join_request_revoked",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GroupJoinRequestEventData {
pub object: GroupJoinRequest,
}
/// A chat was archived, pinned, muted, marked read, deleted, cleared or a message starred, on the phone or another device. Live changes only; the initial full sync is not replayed.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ChatUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatUpdatedEventData {
pub object: ChatChange,
}
/// A contact is typing or recording in a chat.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatPresenceUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ChatPresenceUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChatPresenceUpdatedEventData {
pub object: ChatPresence,
}
/// A subscribed contact came online or went offline. Subscribe with `POST .../contacts/{contactId}/subscribe-presence`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactPresenceUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ContactPresenceUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactPresenceUpdatedEventData {
pub object: ContactPresence,
}
/// A contact or group picture changed or was removed.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactPictureUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ContactPictureUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactPictureUpdatedEventData {
pub object: PictureChange,
}
/// A contact changed their About text, or their WhatsApp username became known or changed. Fields WhatsApp did not send are `null`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ContactUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContactUpdatedEventData {
pub object: Contact,
}
/// The blocklist changed.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BlocklistUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: BlocklistUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BlocklistUpdatedEventData {
pub object: BlocklistChange,
}
/// A label was edited or (un)assigned to a chat or message. The full sync replays labels this way, which is how the label list arrives.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct LabelUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: LabelUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct LabelUpdatedEventData {
pub object: LabelChange,
}
/// `call.received` on an incoming call (reject it with `POST .../calls/{callId}/reject`), `call.ended` when it ends or is rejected.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CallEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: CallEventType,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: CallEventData,
}
string_enum! {
pub enum CallEventType {
/// `call.received`
CallReceived = "call.received",
/// `call.ended`
CallEnded = "call.ended",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CallEventData {
pub object: Call,
}
/// A new message in a followed channel, or new views and reactions on one. Not stored.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelMessageEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: ChannelMessageEventType,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ChannelMessageEventData,
}
string_enum! {
pub enum ChannelMessageEventType {
/// `channel.message_received`
ChannelMessageReceived = "channel.message_received",
/// `channel.message_updated`
ChannelMessageUpdated = "channel.message_updated",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelMessageEventData {
pub object: ChannelMessage,
}
/// The account followed, unfollowed, muted or unmuted a channel.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelUpdatedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ChannelUpdatedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ChannelUpdatedEventData {
pub object: ChannelChange,
}
/// A part of the history the phone sent after linking was stored. Only for accounts with `historySync: recent`: history import is off by default.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct HistorySyncedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: HistorySyncedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct HistorySyncedEventData {
pub object: HistorySync,
}
/// `project.deleted` fires when the background purge finishes.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProjectEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: ProjectEventType,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: ProjectEventData,
}
string_enum! {
pub enum ProjectEventType {
/// `project.created`
ProjectCreated = "project.created",
/// `project.updated`
ProjectUpdated = "project.updated",
/// `project.deleted`
ProjectDeleted = "project.deleted",
@unknown Unknown,
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ProjectEventData {
pub object: Project,
}
/// An invitation changed status (started, completed, failed, cancelled, resent). `url` is `null`. `expired` has no event. `previousAttributes.status` is the status before.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct InvitationStatusChangedEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The project the event belongs to, `null` when unassigned.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: InvitationStatusChangedEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct InvitationStatusChangedEventData {
pub object: Invitation,
#[serde(rename = "previousAttributes")]
pub previous_attributes: InvitationStatusChangedEventDataPreviousAttributes,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct InvitationStatusChangedEventDataPreviousAttributes {
pub status: InvitationStatus,
}
/// `webhook.test` is sent only when you press Send test event on an endpoint in the dashboard, to that endpoint, whether or not it subscribes to it. It is delivered once, with no retries.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct WebhookTestEvent {
/// Event id (`evt_...`). Deduplicate on it.
pub id: String,
pub object: String,
pub r#type: String,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
/// The endpoint's project, `null` for an organization endpoint.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub data: WebhookTestEventData,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct WebhookTestEventData {
pub object: WebhookEndpoint,
}
/// Body of every webhook request, discriminated by `type`.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum Event {
/// type: `account.qr_code_issued`, `account.pairing_code_issued`, `account.connected`, `account.disconnected`, `account.failed`
Account(AccountEvent),
/// type: `message.received`, `message.sent`, `message.delivered`, `message.read`, `message.failed`, `message.deleted`, `message.media_downloaded`
Message(MessageEvent),
/// type: `message.edited`
MessageEdited(MessageEditedEvent),
/// type: `poll.voted`
PollVoted(PollVotedEvent),
/// type: `group.joined`
GroupJoined(GroupJoinedEvent),
/// type: `group.updated`
GroupUpdated(GroupUpdatedEvent),
/// type: `group.join_requested`, `group.join_request_revoked`
GroupJoinRequest(GroupJoinRequestEvent),
/// type: `chat.updated`
ChatUpdated(ChatUpdatedEvent),
/// type: `chat.presence_updated`
ChatPresenceUpdated(ChatPresenceUpdatedEvent),
/// type: `contact.presence_updated`
ContactPresenceUpdated(ContactPresenceUpdatedEvent),
/// type: `contact.picture_updated`
ContactPictureUpdated(ContactPictureUpdatedEvent),
/// type: `contact.updated`
ContactUpdated(ContactUpdatedEvent),
/// type: `blocklist.updated`
BlocklistUpdated(BlocklistUpdatedEvent),
/// type: `label.updated`
LabelUpdated(LabelUpdatedEvent),
/// type: `call.received`, `call.ended`
Call(CallEvent),
/// type: `channel.message_received`, `channel.message_updated`
ChannelMessage(ChannelMessageEvent),
/// type: `channel.updated`
ChannelUpdated(ChannelUpdatedEvent),
/// type: `history.synced`
HistorySynced(HistorySyncedEvent),
/// type: `project.created`, `project.updated`, `project.deleted`
Project(ProjectEvent),
/// type: `invitation.status_changed`
InvitationStatusChanged(InvitationStatusChangedEvent),
/// type: `webhook.test`
WebhookTest(WebhookTestEvent),
/// A `type` this version of the SDK does not know, as raw JSON.
Unknown(serde_json::Value),
}
impl serde::Serialize for Event {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
match self {
Self::Account(value) => value.serialize(serializer),
Self::Message(value) => value.serialize(serializer),
Self::MessageEdited(value) => value.serialize(serializer),
Self::PollVoted(value) => value.serialize(serializer),
Self::GroupJoined(value) => value.serialize(serializer),
Self::GroupUpdated(value) => value.serialize(serializer),
Self::GroupJoinRequest(value) => value.serialize(serializer),
Self::ChatUpdated(value) => value.serialize(serializer),
Self::ChatPresenceUpdated(value) => value.serialize(serializer),
Self::ContactPresenceUpdated(value) => value.serialize(serializer),
Self::ContactPictureUpdated(value) => value.serialize(serializer),
Self::ContactUpdated(value) => value.serialize(serializer),
Self::BlocklistUpdated(value) => value.serialize(serializer),
Self::LabelUpdated(value) => value.serialize(serializer),
Self::Call(value) => value.serialize(serializer),
Self::ChannelMessage(value) => value.serialize(serializer),
Self::ChannelUpdated(value) => value.serialize(serializer),
Self::HistorySynced(value) => value.serialize(serializer),
Self::Project(value) => value.serialize(serializer),
Self::InvitationStatusChanged(value) => value.serialize(serializer),
Self::WebhookTest(value) => value.serialize(serializer),
Self::Unknown(value) => value.serialize(serializer),
}
}
}
impl<'de> serde::Deserialize<'de> for Event {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <serde_json::Value as serde::Deserialize>::deserialize(deserializer)?;
let tag = value.get("type").and_then(serde_json::Value::as_str);
match tag {
Some(
"account.qr_code_issued"
| "account.pairing_code_issued"
| "account.connected"
| "account.disconnected"
| "account.failed",
) => crate::serde_helpers::from_value(value).map(Self::Account),
Some(
"message.received"
| "message.sent"
| "message.delivered"
| "message.read"
| "message.failed"
| "message.deleted"
| "message.media_downloaded",
) => crate::serde_helpers::from_value(value).map(Self::Message),
Some("message.edited") => {
crate::serde_helpers::from_value(value).map(Self::MessageEdited)
}
Some("poll.voted") => crate::serde_helpers::from_value(value).map(Self::PollVoted),
Some("group.joined") => crate::serde_helpers::from_value(value).map(Self::GroupJoined),
Some("group.updated") => {
crate::serde_helpers::from_value(value).map(Self::GroupUpdated)
}
Some("group.join_requested" | "group.join_request_revoked") => {
crate::serde_helpers::from_value(value).map(Self::GroupJoinRequest)
}
Some("chat.updated") => crate::serde_helpers::from_value(value).map(Self::ChatUpdated),
Some("chat.presence_updated") => {
crate::serde_helpers::from_value(value).map(Self::ChatPresenceUpdated)
}
Some("contact.presence_updated") => {
crate::serde_helpers::from_value(value).map(Self::ContactPresenceUpdated)
}
Some("contact.picture_updated") => {
crate::serde_helpers::from_value(value).map(Self::ContactPictureUpdated)
}
Some("contact.updated") => {
crate::serde_helpers::from_value(value).map(Self::ContactUpdated)
}
Some("blocklist.updated") => {
crate::serde_helpers::from_value(value).map(Self::BlocklistUpdated)
}
Some("label.updated") => {
crate::serde_helpers::from_value(value).map(Self::LabelUpdated)
}
Some("call.received" | "call.ended") => {
crate::serde_helpers::from_value(value).map(Self::Call)
}
Some("channel.message_received" | "channel.message_updated") => {
crate::serde_helpers::from_value(value).map(Self::ChannelMessage)
}
Some("channel.updated") => {
crate::serde_helpers::from_value(value).map(Self::ChannelUpdated)
}
Some("history.synced") => {
crate::serde_helpers::from_value(value).map(Self::HistorySynced)
}
Some("project.created" | "project.updated" | "project.deleted") => {
crate::serde_helpers::from_value(value).map(Self::Project)
}
Some("invitation.status_changed") => {
crate::serde_helpers::from_value(value).map(Self::InvitationStatusChanged)
}
Some("webhook.test") => crate::serde_helpers::from_value(value).map(Self::WebhookTest),
_ => Ok(Self::Unknown(value)),
}
}
}
impl From<AccountEvent> for Event {
fn from(value: AccountEvent) -> Self {
Self::Account(value)
}
}
impl From<MessageEvent> for Event {
fn from(value: MessageEvent) -> Self {
Self::Message(value)
}
}
impl From<MessageEditedEvent> for Event {
fn from(value: MessageEditedEvent) -> Self {
Self::MessageEdited(value)
}
}
impl From<PollVotedEvent> for Event {
fn from(value: PollVotedEvent) -> Self {
Self::PollVoted(value)
}
}
impl From<GroupJoinedEvent> for Event {
fn from(value: GroupJoinedEvent) -> Self {
Self::GroupJoined(value)
}
}
impl From<GroupUpdatedEvent> for Event {
fn from(value: GroupUpdatedEvent) -> Self {
Self::GroupUpdated(value)
}
}
impl From<GroupJoinRequestEvent> for Event {
fn from(value: GroupJoinRequestEvent) -> Self {
Self::GroupJoinRequest(value)
}
}
impl From<ChatUpdatedEvent> for Event {
fn from(value: ChatUpdatedEvent) -> Self {
Self::ChatUpdated(value)
}
}
impl From<ChatPresenceUpdatedEvent> for Event {
fn from(value: ChatPresenceUpdatedEvent) -> Self {
Self::ChatPresenceUpdated(value)
}
}
impl From<ContactPresenceUpdatedEvent> for Event {
fn from(value: ContactPresenceUpdatedEvent) -> Self {
Self::ContactPresenceUpdated(value)
}
}
impl From<ContactPictureUpdatedEvent> for Event {
fn from(value: ContactPictureUpdatedEvent) -> Self {
Self::ContactPictureUpdated(value)
}
}
impl From<ContactUpdatedEvent> for Event {
fn from(value: ContactUpdatedEvent) -> Self {
Self::ContactUpdated(value)
}
}
impl From<BlocklistUpdatedEvent> for Event {
fn from(value: BlocklistUpdatedEvent) -> Self {
Self::BlocklistUpdated(value)
}
}
impl From<LabelUpdatedEvent> for Event {
fn from(value: LabelUpdatedEvent) -> Self {
Self::LabelUpdated(value)
}
}
impl From<CallEvent> for Event {
fn from(value: CallEvent) -> Self {
Self::Call(value)
}
}
impl From<ChannelMessageEvent> for Event {
fn from(value: ChannelMessageEvent) -> Self {
Self::ChannelMessage(value)
}
}
impl From<ChannelUpdatedEvent> for Event {
fn from(value: ChannelUpdatedEvent) -> Self {
Self::ChannelUpdated(value)
}
}
impl From<HistorySyncedEvent> for Event {
fn from(value: HistorySyncedEvent) -> Self {
Self::HistorySynced(value)
}
}
impl From<ProjectEvent> for Event {
fn from(value: ProjectEvent) -> Self {
Self::Project(value)
}
}
impl From<InvitationStatusChangedEvent> for Event {
fn from(value: InvitationStatusChangedEvent) -> Self {
Self::InvitationStatusChanged(value)
}
}
impl From<WebhookTestEvent> for Event {
fn from(value: WebhookTestEvent) -> Self {
Self::WebhookTest(value)
}
}
string_enum! {
/// - `pending`: Waiting for the bytes at `uploadUrl` and for `POST /v1/uploads/{uploadId}/complete`. Not sendable yet.
/// - `ready`: The file is stored. Send it with `media: { uploadId }` until `expiresAt`.
pub enum UploadStatus {
/// `pending`
Pending = "pending",
/// `ready`
Ready = "ready",
@unknown Unknown,
}
}
/// A file uploaded to be sent with `media: { uploadId }`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Upload {
/// Always `upload`.
pub object: String,
/// Pass it as `media.uploadId` when sending.
pub id: String,
/// Project the resource belongs to, `null` when it is in no project. Set at creation and never changes.
#[serde(rename = "projectId")]
pub project_id: Option<String>,
pub status: UploadStatus,
/// The file's MIME type, as declared. A send uses it unless it passes its own `media.mimeType`.
#[serde(rename = "mimeType")]
pub mime_type: String,
/// The file name a recipient sees for a document, when one was given.
pub filename: Option<String>,
/// Bytes: the declared size while `pending`, the stored file's size once `ready`.
pub size: i64,
/// Where to `POST` the file's raw bytes, with the file's `Content-Type` and no API key. Valid for 1 hour. It answers `{ "storageId": "..." }`: pass that to `POST /v1/uploads/{uploadId}/complete`. Only on the answer of the `POST /v1/uploads` that issued it; `null` everywhere else, and for an upload created with `base64`. Treat it as a secret until then.
#[serde(rename = "uploadUrl")]
pub upload_url: Option<String>,
/// `pending`: when the upload URL stops working (1 hour after creation). `ready`: until when the upload can be sent (24 hours after it became ready). After it the upload answers `404`.
#[serde(rename = "expiresAt")]
pub expires_at: String,
#[serde(rename = "createdAt")]
pub created_at: String,
}
/// Exactly one of: `size` (the bytes go to the `uploadUrl` of the answer; any size up to 100 MB), or `base64` (the bytes are in this request; up to 5 MB).
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum UploadCreateRequest {
File(FileUploadCreateRequest),
Inline(InlineUploadCreateRequest),
/// A shape this version of the SDK does not know.
Unknown(serde_json::Value),
}
impl From<FileUploadCreateRequest> for UploadCreateRequest {
fn from(value: FileUploadCreateRequest) -> Self {
Self::File(value)
}
}
impl From<InlineUploadCreateRequest> for UploadCreateRequest {
fn from(value: InlineUploadCreateRequest) -> Self {
Self::Inline(value)
}
}
/// An upload whose bytes you post to `uploadUrl`. Any size up to 100 MB.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct FileUploadCreateRequest {
/// The file's MIME type, such as `image/jpeg` or `audio/ogg; codecs=opus`. Sends use it as the message's `mimeType`.
#[serde(rename = "mimeType")]
pub mime_type: String,
/// The file's size in bytes, at most 104857600 (100 MB). The file posted to `uploadUrl` must be exactly this size.
pub size: i64,
/// The file name a recipient sees for a document.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
}
impl FileUploadCreateRequest {
/// A `FileUploadCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(mime_type: impl Into<String>, size: i64) -> Self {
Self {
mime_type: mime_type.into(),
size,
filename: None,
}
}
}
/// An upload with its bytes in the request. Up to 5 MB; the answer is already `ready`.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct InlineUploadCreateRequest {
/// The file's MIME type, such as `image/jpeg` or `audio/ogg; codecs=opus`. Sends use it as the message's `mimeType`.
#[serde(rename = "mimeType")]
pub mime_type: String,
/// The file's bytes in base64 (standard or URL-safe alphabet), at most 5 MB (5242880 bytes) once decoded.
pub base64: String,
/// The file name a recipient sees for a document.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub filename: Option<String>,
}
impl InlineUploadCreateRequest {
/// A `InlineUploadCreateRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(mime_type: impl Into<String>, base64: impl Into<String>) -> Self {
Self {
mime_type: mime_type.into(),
base64: base64.into(),
filename: None,
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct UploadCompleteRequest {
/// The `storageId` in the JSON answer of the `POST` of the bytes to `uploadUrl`.
#[serde(rename = "storageId")]
pub storage_id: String,
}
impl UploadCompleteRequest {
/// A `UploadCompleteRequest` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(storage_id: impl Into<String>) -> Self {
Self {
storage_id: storage_id.into(),
}
}
}
string_enum! {
pub enum ListChatsType {
/// `direct`
Direct = "direct",
/// `group`
Group = "group",
/// `channel`
Channel = "channel",
@unknown Unknown,
}
}
/// Params for `accounts.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct AccountsListParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
/// Filter by project: a project id, `ext:<externalId>`, or `none` for resources in no project. With an organization scope and no filter, the list covers every project and the unassigned resources. With a project scope the list is always that project's; naming another project answers `403 forbidden`. An unknown project answers `404 project_not_found`.
#[serde(rename = "projectId", default)]
pub project_id: Option<String>,
}
/// Params for `accounts.create`.
pub type AccountsCreateParams = AccountCreateRequest;
/// Params for `accounts.update`.
pub type AccountsUpdateParams = AccountUpdateRequest;
/// Params for `accounts.create_pairing_code`.
pub type AccountsCreatePairingCodeParams = PairingCodeRequest;
/// Params for `accounts.set_presence`.
pub type AccountsSetPresenceParams = AccountPresenceRequest;
/// Params for `accounts.set_default_disappearing_timer`.
pub type AccountsSetDefaultDisappearingTimerParams = DisappearingTimerRequest;
/// Params for `proxy_locations.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ProxyLocationsListParams {
/// Only this country (ISO 3166-1 alpha-2).
#[serde(default)]
pub country: Option<String>,
/// Search text: city name, city code, country name or ISO code. Case and accents are ignored.
#[serde(default)]
pub q: Option<String>,
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `messages.send`.
pub type MessagesSendParams = SendMessageRequest;
/// Params for `messages.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct MessagesListParams {
/// Only this account's messages.
#[serde(rename = "accountId", default)]
pub account_id: Option<String>,
/// Only this chat: a contact id, a group id, a channel id or `stories`.
#[serde(rename = "chatId", default)]
pub chat_id: Option<String>,
/// Only inbound or outbound messages.
#[serde(default)]
pub direction: Option<MessageDirection>,
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
/// Filter by project: a project id, `ext:<externalId>`, or `none` for resources in no project. With an organization scope and no filter, the list covers every project and the unassigned resources. With a project scope the list is always that project's; naming another project answers `403 forbidden`. An unknown project answers `404 project_not_found`.
#[serde(rename = "projectId", default)]
pub project_id: Option<String>,
}
/// Params for `messages.get_media`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct MessagesGetMediaParams {
/// `false` answers JSON with the file's URL instead of the `302` redirect.
///
/// Default: `true`.
#[serde(default)]
pub redirect: Option<bool>,
}
/// Params for `messages.edit`.
pub type MessagesEditParams = MessageEditRequest;
/// Params for `messages.delete`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct MessagesDeleteParams {
/// `false` deletes it on the linked devices only and keeps the row unchanged.
///
/// Default: `true`.
#[serde(rename = "forEveryone", default)]
pub for_everyone: Option<bool>,
}
/// Params for `messages.react`.
pub type MessagesReactParams = ReactRequest;
/// Params for `messages.vote`.
pub type MessagesVoteParams = VoteRequest;
/// Params for `messages.add_label`.
pub type MessagesAddLabelParams = LabelAssignRequest;
/// Params for `stories.create`.
pub type StoriesCreateParams = StoryCreateRequest;
/// Params for `uploads.create`.
pub type UploadsCreateParams = UploadCreateRequest;
/// Params for `uploads.complete`.
pub type UploadsCompleteParams = UploadCompleteRequest;
/// Params for `chats.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ChatsListParams {
/// `true`: only the chats WhatsApp reported as archived. `false`: every other chat, including those whose `archived` is `null`.
#[serde(default)]
pub archived: Option<bool>,
/// `true`: only the chats with unread messages or marked as unread. `false`: every other chat, including those whose `unread` is `null`.
#[serde(default)]
pub unread: Option<bool>,
/// Only chats of this type.
///
/// - `direct`: Chats with one contact.
/// - `group`: Groups.
/// - `channel`: Channels.
#[serde(default)]
pub r#type: Option<ListChatsType>,
/// Search: the contact's saved name, profile name, username or number, the group's name, or words of the chat's recent messages. The last word matches as a prefix. Results come best match first, not by date.
#[serde(default)]
pub q: Option<String>,
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `chats.send_presence`.
pub type ChatsSendPresenceParams = ChatPresenceRequest;
/// Params for `chats.send_read_receipts`.
pub type ChatsSendReadReceiptsParams = ReadReceiptsRequest;
/// Params for `chats.mute`.
pub type ChatsMuteParams = MuteRequest;
/// Params for `chats.delete`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ChatsDeleteParams {
/// Also delete the chat's media.
///
/// Default: `false`.
#[serde(rename = "deleteMedia", default)]
pub delete_media: Option<bool>,
}
/// Params for `chats.set_disappearing_timer`.
pub type ChatsSetDisappearingTimerParams = DisappearingTimerRequest;
/// Params for `chats.add_label`.
pub type ChatsAddLabelParams = LabelAssignRequest;
/// Params for `labels.upsert`.
pub type LabelsUpsertParams = LabelUpsertRequest;
/// Params for `contacts.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ContactsListParams {
/// Search: the saved name, profile name, business name, username or number. The last word matches as a prefix. Results come best match first, not by name.
#[serde(default)]
pub q: Option<String>,
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `contacts.check`.
pub type ContactsCheckParams = ContactCheckRequest;
/// Params for `contacts.lookup`.
pub type ContactsLookupParams = ContactLookupRequest;
/// Params for `contacts.get_picture`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ContactsGetPictureParams {
/// Return the small preview.
///
/// Default: `false`.
#[serde(default)]
pub preview: Option<bool>,
}
/// Params for `contacts.list_blocked`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ContactsListBlockedParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `contacts.resolve_link`.
pub type ContactsResolveLinkParams = LinkResolveRequest;
/// Params for `bots.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct BotsListParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `profile.update`.
pub type ProfileUpdateParams = ProfileUpdateRequest;
/// Params for `profile.set_picture`.
pub type ProfileSetPictureParams = PictureUploadRequest;
/// Params for `privacy.update`.
pub type PrivacyUpdateParams = PrivacyUpdateRequest;
/// Params for `calls.reject`.
pub type CallsRejectParams = CallRejectRequest;
/// Params for `orders.get`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
pub struct OrdersGetParams {
/// The order's token, from the order message.
pub token: String,
}
impl OrdersGetParams {
/// A `OrdersGetParams` from its required fields; the rest start as `None`.
#[must_use]
pub fn new(token: impl Into<String>) -> Self {
Self {
token: token.into(),
}
}
}
/// Params for `groups.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct GroupsListParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `groups.create`.
pub type GroupsCreateParams = GroupCreateRequest;
/// Params for `groups.join`.
pub type GroupsJoinParams = JoinGroupRequest;
/// Params for `groups.update`.
pub type GroupsUpdateParams = GroupUpdateRequest;
/// Params for `groups.add_participants`.
pub type GroupsAddParticipantsParams = ContactIdsRequest;
/// Params for `groups.remove_participants`.
pub type GroupsRemoveParticipantsParams = ContactIdsRequest;
/// Params for `groups.promote_participants`.
pub type GroupsPromoteParticipantsParams = ContactIdsRequest;
/// Params for `groups.demote_participants`.
pub type GroupsDemoteParticipantsParams = ContactIdsRequest;
/// Params for `groups.set_picture`.
pub type GroupsSetPictureParams = PictureUploadRequest;
/// Params for `groups.list_join_requests`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct GroupsListJoinRequestsParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `groups.approve_join_requests`.
pub type GroupsApproveJoinRequestsParams = ContactIdsRequest;
/// Params for `groups.reject_join_requests`.
pub type GroupsRejectJoinRequestsParams = ContactIdsRequest;
/// Params for `groups.list_subgroups`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct GroupsListSubgroupsParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `groups.link_subgroup`.
pub type GroupsLinkSubgroupParams = SubgroupLinkRequest;
/// Params for `groups.list_community_participants`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct GroupsListCommunityParticipantsParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `channels.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ChannelsListParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `channels.create`.
pub type ChannelsCreateParams = ChannelCreateRequest;
/// Params for `channels.list_messages`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ChannelsListMessagesParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `channels.react`.
pub type ChannelsReactParams = ReactRequest;
/// Params for `channels.mark_viewed`.
pub type ChannelsMarkViewedParams = MarkViewedRequest;
/// Params for `webhook_endpoints.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct WebhookEndpointsListParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
/// Filter by project: a project id, `ext:<externalId>`, or `none` for resources in no project. With an organization scope and no filter, the list covers every project and the unassigned resources. With a project scope the list is always that project's; naming another project answers `403 forbidden`. An unknown project answers `404 project_not_found`.
#[serde(rename = "projectId", default)]
pub project_id: Option<String>,
}
/// Params for `webhook_endpoints.create`.
pub type WebhookEndpointsCreateParams = WebhookEndpointCreateRequest;
/// Params for `webhook_endpoints.update`.
pub type WebhookEndpointsUpdateParams = WebhookEndpointUpdateRequest;
/// Params for `projects.create`.
pub type ProjectsCreateParams = ProjectCreateRequest;
/// Params for `projects.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ProjectsListParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
/// Exact match.
#[serde(rename = "externalId", default)]
pub external_id: Option<String>,
/// Only projects with this status.
#[serde(default)]
pub status: Option<ProjectStatus>,
}
/// Params for `projects.update`.
pub type ProjectsUpdateParams = ProjectUpdateRequest;
/// Params for `projects.get_usage`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ProjectsGetUsageParams {
/// Month in UTC as `YYYY-MM`. Defaults to the current month. Selects the month of `proxyBytes`, `sentMessageCount` and `receivedMessageCount`; `accountCount` and `billableAccountCount` are always current counts.
#[serde(default)]
pub month: Option<String>,
}
/// Params for `projects.api_keys.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct ProjectsApiKeysListParams {
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
}
/// Params for `projects.api_keys.create`.
pub type ProjectsApiKeysCreateParams = ApiKeyCreateRequest;
/// Params for `invitations.create`.
pub type InvitationsCreateParams = InvitationCreateRequest;
/// Params for `invitations.list`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct InvitationsListParams {
/// Only this status.
#[serde(default)]
pub status: Option<InvitationStatus>,
/// Page size, 1 to 100.
///
/// Default: `50`.
#[serde(default)]
pub limit: Option<i64>,
/// Opaque cursor from a previous page's `nextCursor`. An invalid or expired cursor answers `400 invalid_request`.
#[serde(default)]
pub cursor: Option<String>,
/// Filter by project: a project id, `ext:<externalId>`, or `none` for resources in no project. With an organization scope and no filter, the list covers every project and the unassigned resources. With a project scope the list is always that project's; naming another project answers `403 forbidden`. An unknown project answers `404 project_not_found`.
#[serde(rename = "projectId", default)]
pub project_id: Option<String>,
}
/// Params for `branding.update`.
pub type BrandingUpdateParams = BrandingUpdateRequest;
/// Params for `usage.by_project`.
#[derive(Debug, Clone, PartialEq, serde::Deserialize, Default)]
pub struct UsageByProjectParams {
/// Month in UTC as `YYYY-MM`. Defaults to the current month. Selects the month of `proxyBytes`, `sentMessageCount` and `receivedMessageCount`; `accountCount` and `billableAccountCount` are always current counts.
#[serde(default)]
pub month: Option<String>,
}
impl crate::pagination::CursorPage for AccountList {
type Item = Account;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for ProxyLocationItemList {
type Item = ProxyLocationItem;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for MessageList {
type Item = Message;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for ChatList {
type Item = Chat;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for ContactList {
type Item = Contact;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for BlockedContactList {
type Item = BlockedContact;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for BotList {
type Item = Bot;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for GroupList {
type Item = Group;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for GroupJoinRequestList {
type Item = GroupJoinRequest;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for SubgroupList {
type Item = Subgroup;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for CommunityParticipantList {
type Item = CommunityParticipant;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for ChannelList {
type Item = Channel;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for ChannelMessageList {
type Item = ChannelMessage;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for WebhookEndpointList {
type Item = WebhookEndpoint;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for ProjectList {
type Item = Project;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for ApiKeyList {
type Item = ApiKey;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
impl crate::pagination::CursorPage for InvitationList {
type Item = Invitation;
fn next_cursor(&self) -> Option<&str> {
self.next_cursor.as_deref()
}
fn into_items(self) -> Vec<Self::Item> {
self.items
}
}
/// The body of a webhook request, as returned by `verify_webhook`.
pub type WebhookEvent = Event;