vapi_client/models/
server_message_phone_call_control.rs

1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct ServerMessagePhoneCallControl {
17    #[serde(rename = "phoneNumber", skip_serializing_if = "Option::is_none")]
18    pub phone_number: Option<models::ServerMessageAssistantRequestPhoneNumber>,
19    /// This is the type of the message. \"phone-call-control\" is an advanced type of message.  When it is requested in `assistant.serverMessages`, the hangup and forwarding responsibilities are delegated to your server. Vapi will no longer do the actual transfer and hangup.
20    #[serde(rename = "type")]
21    pub r#type: Type,
22    /// This is the request to control the phone call.
23    #[serde(rename = "request")]
24    pub request: Request,
25    #[serde(rename = "destination", skip_serializing_if = "Option::is_none")]
26    pub destination: Option<models::ServerMessagePhoneCallControlDestination>,
27    /// This is the ISO-8601 formatted timestamp of when the message was sent.
28    #[serde(rename = "timestamp", skip_serializing_if = "Option::is_none")]
29    pub timestamp: Option<f64>,
30    /// This is a live version of the `call.artifact`.  This matches what is stored on `call.artifact` after the call.
31    #[serde(rename = "artifact", skip_serializing_if = "Option::is_none")]
32    pub artifact: Option<models::Artifact>,
33    /// This is the assistant that is currently active. This is provided for convenience.  This matches one of the following: - `call.assistant`, - `call.assistantId`, - `call.squad[n].assistant`, - `call.squad[n].assistantId`, - `call.squadId->[n].assistant`, - `call.squadId->[n].assistantId`.
34    #[serde(rename = "assistant", skip_serializing_if = "Option::is_none")]
35    pub assistant: Option<models::CreateAssistantDto>,
36    /// This is the customer associated with the call.  This matches one of the following: - `call.customer`, - `call.customerId`.
37    #[serde(rename = "customer", skip_serializing_if = "Option::is_none")]
38    pub customer: Option<models::CreateCustomerDto>,
39    /// This is the call object.  This matches what was returned in POST /call.  Note: This might get stale during the call. To get the latest call object, especially after the call is ended, use GET /call/:id.
40    #[serde(rename = "call", skip_serializing_if = "Option::is_none")]
41    pub call: Option<models::Call>,
42}
43
44impl ServerMessagePhoneCallControl {
45    pub fn new(r#type: Type, request: Request) -> ServerMessagePhoneCallControl {
46        ServerMessagePhoneCallControl {
47            phone_number: None,
48            r#type,
49            request,
50            destination: None,
51            timestamp: None,
52            artifact: None,
53            assistant: None,
54            customer: None,
55            call: None,
56        }
57    }
58}
59/// This is the type of the message. \"phone-call-control\" is an advanced type of message.  When it is requested in `assistant.serverMessages`, the hangup and forwarding responsibilities are delegated to your server. Vapi will no longer do the actual transfer and hangup.
60#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
61pub enum Type {
62    #[serde(rename = "phone-call-control")]
63    PhoneCallControl,
64}
65
66impl Default for Type {
67    fn default() -> Type {
68        Self::PhoneCallControl
69    }
70}
71/// This is the request to control the phone call.
72#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
73pub enum Request {
74    #[serde(rename = "forward")]
75    Forward,
76    #[serde(rename = "hang-up")]
77    HangUp,
78}
79
80impl Default for Request {
81    fn default() -> Request {
82        Self::Forward
83    }
84}