vapi_client/models/
api_request.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 ApiRequest {
17    #[serde(rename = "type")]
18    pub r#type: Type,
19    #[serde(rename = "method")]
20    pub method: Method,
21    /// Api endpoint to send requests to.
22    #[serde(rename = "url")]
23    pub url: String,
24    /// These are the custom headers to include in the Api Request sent.  Each key-value pair represents a header name and its value.
25    #[serde(rename = "headers", skip_serializing_if = "Option::is_none")]
26    pub headers: Option<models::JsonSchema>,
27    /// This defined the JSON body of your Api Request. For example, if `body_schema` included \"my_field\": \"my_gather_statement.user_age\", then the json body sent to the server would have that particular value assign to it. Right now, only data from gather statements are supported.
28    #[serde(rename = "body", skip_serializing_if = "Option::is_none")]
29    pub body: Option<models::JsonSchema>,
30    /// This is the mode of the Api Request. We only support BLOCKING and BACKGROUND for now.
31    #[serde(rename = "mode")]
32    pub mode: Mode,
33    /// This is a list of hooks for a task. Each hook is a list of tasks to run on a trigger (such as on start, on failure, etc). Only Say is supported for now.
34    #[serde(rename = "hooks", skip_serializing_if = "Option::is_none")]
35    pub hooks: Option<Vec<models::Hook>>,
36    /// This is the schema for the outputs of the Api Request.
37    #[serde(rename = "output", skip_serializing_if = "Option::is_none")]
38    pub output: Option<models::JsonSchema>,
39    #[serde(rename = "name")]
40    pub name: String,
41    /// This is for metadata you want to store on the task.
42    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
43    pub metadata: Option<serde_json::Value>,
44}
45
46impl ApiRequest {
47    pub fn new(r#type: Type, method: Method, url: String, mode: Mode, name: String) -> ApiRequest {
48        ApiRequest {
49            r#type,
50            method,
51            url,
52            headers: None,
53            body: None,
54            mode,
55            hooks: None,
56            output: None,
57            name,
58            metadata: None,
59        }
60    }
61}
62///
63#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
64pub enum Type {
65    #[serde(rename = "apiRequest")]
66    ApiRequest,
67}
68
69impl Default for Type {
70    fn default() -> Type {
71        Self::ApiRequest
72    }
73}
74///
75#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
76pub enum Method {
77    #[serde(rename = "POST")]
78    Post,
79    #[serde(rename = "GET")]
80    Get,
81}
82
83impl Default for Method {
84    fn default() -> Method {
85        Self::Post
86    }
87}
88/// This is the mode of the Api Request. We only support BLOCKING and BACKGROUND for now.
89#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
90pub enum Mode {
91    #[serde(rename = "blocking")]
92    Blocking,
93    #[serde(rename = "background")]
94    Background,
95}
96
97impl Default for Mode {
98    fn default() -> Mode {
99        Self::Blocking
100    }
101}