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