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