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