vapi_client/models/
server_message_speech_update.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 ServerMessageSpeechUpdate {
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. \"speech-update\" is sent whenever assistant or user start or stop speaking.
20    #[serde(rename = "type")]
21    pub r#type: Type,
22    /// This is the status of the speech update.
23    #[serde(rename = "status")]
24    pub status: Status,
25    /// This is the role which the speech update is for.
26    #[serde(rename = "role")]
27    pub role: Role,
28    /// This is the ISO-8601 formatted timestamp of when the message was sent.
29    #[serde(rename = "timestamp", skip_serializing_if = "Option::is_none")]
30    pub timestamp: Option<f64>,
31    /// This is a live version of the `call.artifact`.  This matches what is stored on `call.artifact` after the call.
32    #[serde(rename = "artifact", skip_serializing_if = "Option::is_none")]
33    pub artifact: Option<models::Artifact>,
34    /// 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`.
35    #[serde(rename = "assistant", skip_serializing_if = "Option::is_none")]
36    pub assistant: Option<models::CreateAssistantDto>,
37    /// This is the customer associated with the call.  This matches one of the following: - `call.customer`, - `call.customerId`.
38    #[serde(rename = "customer", skip_serializing_if = "Option::is_none")]
39    pub customer: Option<models::CreateCustomerDto>,
40    /// 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.
41    #[serde(rename = "call", skip_serializing_if = "Option::is_none")]
42    pub call: Option<models::Call>,
43}
44
45impl ServerMessageSpeechUpdate {
46    pub fn new(r#type: Type, status: Status, role: Role) -> ServerMessageSpeechUpdate {
47        ServerMessageSpeechUpdate {
48            phone_number: None,
49            r#type,
50            status,
51            role,
52            timestamp: None,
53            artifact: None,
54            assistant: None,
55            customer: None,
56            call: None,
57        }
58    }
59}
60/// This is the type of the message. \"speech-update\" is sent whenever assistant or user start or stop speaking.
61#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
62pub enum Type {
63    #[serde(rename = "speech-update")]
64    SpeechUpdate,
65}
66
67impl Default for Type {
68    fn default() -> Type {
69        Self::SpeechUpdate
70    }
71}
72/// This is the status of the speech update.
73#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
74pub enum Status {
75    #[serde(rename = "started")]
76    Started,
77    #[serde(rename = "stopped")]
78    Stopped,
79}
80
81impl Default for Status {
82    fn default() -> Status {
83        Self::Started
84    }
85}
86/// This is the role which the speech update is for.
87#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
88pub enum Role {
89    #[serde(rename = "assistant")]
90    Assistant,
91    #[serde(rename = "user")]
92    User,
93}
94
95impl Default for Role {
96    fn default() -> Role {
97        Self::Assistant
98    }
99}