vapi_client/models/
server_message_phone_call_control.rs

1/*
2 * Vapi API
3 *
4 * Voice AI for developers.
5 *
6 * The version of the OpenAPI document: 1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct ServerMessagePhoneCallControl {
16    #[serde(rename = "phoneNumber", skip_serializing_if = "Option::is_none")]
17    pub phone_number: Option<models::ServerMessageAssistantRequestPhoneNumber>,
18    /// 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.
19    #[serde(rename = "type")]
20    pub r#type: Type,
21    /// This is the request to control the phone call.
22    #[serde(rename = "request")]
23    pub request: Request,
24    #[serde(rename = "destination", skip_serializing_if = "Option::is_none")]
25    pub destination: Option<models::ServerMessagePhoneCallControlDestination>,
26    /// This is the timestamp of when the message was sent in milliseconds since Unix Epoch.
27    #[serde(rename = "timestamp", skip_serializing_if = "Option::is_none")]
28    pub timestamp: Option<f64>,
29    /// This is a live version of the `call.artifact`.  This matches what is stored on `call.artifact` after the call.
30    #[serde(rename = "artifact", skip_serializing_if = "Option::is_none")]
31    pub artifact: Option<models::Artifact>,
32    /// 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`.
33    #[serde(rename = "assistant", skip_serializing_if = "Option::is_none")]
34    pub assistant: Option<models::CreateAssistantDto>,
35    /// This is the customer associated with the call.  This matches one of the following: - `call.customer`, - `call.customerId`.
36    #[serde(rename = "customer", skip_serializing_if = "Option::is_none")]
37    pub customer: Option<models::CreateCustomerDto>,
38    /// 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.
39    #[serde(rename = "call", skip_serializing_if = "Option::is_none")]
40    pub call: Option<models::Call>,
41}
42
43impl ServerMessagePhoneCallControl {
44    pub fn new(r#type: Type, request: Request) -> ServerMessagePhoneCallControl {
45        ServerMessagePhoneCallControl {
46            phone_number: None,
47            r#type,
48            request,
49            destination: None,
50            timestamp: None,
51            artifact: None,
52            assistant: None,
53            customer: None,
54            call: None,
55        }
56    }
57}
58/// 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.
59#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
60pub enum Type {
61    #[serde(rename = "phone-call-control")]
62    PhoneCallControl,
63}
64
65impl Default for Type {
66    fn default() -> Type {
67        Self::PhoneCallControl
68    }
69}
70/// This is the request to control the phone call.
71#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
72pub enum Request {
73    #[serde(rename = "forward")]
74    Forward,
75    #[serde(rename = "hang-up")]
76    HangUp,
77}
78
79impl Default for Request {
80    fn default() -> Request {
81        Self::Forward
82    }
83}
84