/*
* 1MSG WhatsApp Business API (Public)
*
* Public client API for sending messages, managing groups, flows, and templates. This is the API exposed to end customers via platform.1msg.io **Authentication:** All requests require `token` query parameter with JWT or API key. **Documentation:** https://help.1msg.io/platform-1msg/getting-start/quick-start **API Docs:** https://docs.1msg.io/
*
* The version of the OpenAPI document: 1.0.0
* Contact: support@1msg.io
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// InitiateCallRequest : Call action payload for `POST /initiateCall` (proxies upstream `POST /calling/calls`). Despite the path name, this endpoint handles **all** call actions — not only outbound connect. ## Required fields by `action` | action | Required | `session` | |--------|----------|-----------| | `connect` (outbound) | `messaging_product`, `to`, `action` | `sdp_type: offer` + business WebRTC SDP | | `pre_accept` | `messaging_product`, `call_id`, `action` | `sdp_type: answer` (WebRTC-generated) | | `accept` | `messaging_product`, `call_id`, `action` | `sdp_type: answer` (WebRTC-generated) | | `reject` | `messaging_product`, `call_id`, `action` | none | | `terminate` | `messaging_product`, `call_id`, `action` | none | **Critical:** For `pre_accept` / `accept`, `session.sdp` must be a **WebRTC-generated SDP answer**. Do not echo Meta's offer SDP back. Postman alone cannot establish real media — you need a WebRTC (or SIP) stack.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct InitiateCallRequest {
/// Must be `whatsapp`
#[serde(rename = "messaging_product")]
pub messaging_product: MessagingProduct,
/// Call control action
#[serde(rename = "action")]
pub action: Action,
/// WhatsApp call id from the inbound/outbound calls webhook (`calls[].id`). Required for `pre_accept`, `accept`, `reject`, `terminate`.
#[serde(rename = "call_id", skip_serializing_if = "Option::is_none")]
pub call_id: Option<String>,
/// Recipient WhatsApp user phone (digits, country code, no +). Required for outbound `connect`.
#[serde(rename = "to", skip_serializing_if = "Option::is_none")]
pub to: Option<String>,
/// Optional opaque string echoed on later call webhooks for correlation
#[serde(rename = "biz_opaque_callback_data", skip_serializing_if = "Option::is_none")]
pub biz_opaque_callback_data: Option<String>,
#[serde(rename = "session", skip_serializing_if = "Option::is_none")]
pub session: Option<models::InitiateCallRequestSession>,
}
impl InitiateCallRequest {
/// Call action payload for `POST /initiateCall` (proxies upstream `POST /calling/calls`). Despite the path name, this endpoint handles **all** call actions — not only outbound connect. ## Required fields by `action` | action | Required | `session` | |--------|----------|-----------| | `connect` (outbound) | `messaging_product`, `to`, `action` | `sdp_type: offer` + business WebRTC SDP | | `pre_accept` | `messaging_product`, `call_id`, `action` | `sdp_type: answer` (WebRTC-generated) | | `accept` | `messaging_product`, `call_id`, `action` | `sdp_type: answer` (WebRTC-generated) | | `reject` | `messaging_product`, `call_id`, `action` | none | | `terminate` | `messaging_product`, `call_id`, `action` | none | **Critical:** For `pre_accept` / `accept`, `session.sdp` must be a **WebRTC-generated SDP answer**. Do not echo Meta's offer SDP back. Postman alone cannot establish real media — you need a WebRTC (or SIP) stack.
pub fn new(messaging_product: MessagingProduct, action: Action) -> InitiateCallRequest {
InitiateCallRequest {
messaging_product,
action,
call_id: None,
to: None,
biz_opaque_callback_data: None,
session: None,
}
}
}
/// Must be `whatsapp`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum MessagingProduct {
#[serde(rename = "whatsapp")]
Whatsapp,
}
impl Default for MessagingProduct {
fn default() -> MessagingProduct {
Self::Whatsapp
}
}
/// Call control action
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Action {
#[serde(rename = "connect")]
Connect,
#[serde(rename = "pre_accept")]
PreAccept,
#[serde(rename = "accept")]
Accept,
#[serde(rename = "reject")]
Reject,
#[serde(rename = "terminate")]
Terminate,
}
impl Default for Action {
fn default() -> Action {
Self::Connect
}
}