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