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 */
1011use crate::models;
12use serde::{Deserialize, Serialize};
1314#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct ApiRequestTool {
16/// These are the messages that will be spoken to the user as the tool is running. For some tools, this is auto-filled based on special fields like `tool.destinations`. For others like the function tool, these can be custom configured.
17#[serde(rename = "messages", skip_serializing_if = "Option::is_none")]
18pub messages: Option<Vec<models::CreateDtmfToolDtoMessagesInner>>,
19/// The type of tool. \"apiRequest\" for API request tool.
20#[serde(rename = "type")]
21pub r#type: TypeTrue,
22#[serde(rename = "method")]
23pub method: MethodTrue,
24/// This is the timeout in seconds for the request. Defaults to 20 seconds. @default 20
25#[serde(rename = "timeoutSeconds", skip_serializing_if = "Option::is_none")]
26pub timeout_seconds: Option<f64>,
27/// This is the unique identifier for the tool.
28#[serde(rename = "id")]
29pub id: String,
30/// This is the unique identifier for the organization that this tool belongs to.
31#[serde(rename = "orgId")]
32pub org_id: String,
33/// This is the ISO 8601 date-time string of when the tool was created.
34#[serde(rename = "createdAt")]
35pub created_at: String,
36/// This is the ISO 8601 date-time string of when the tool was last updated.
37#[serde(rename = "updatedAt")]
38pub updated_at: String,
39/// This is the function definition of the tool. For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on tool-specific fields like `tool.destinations`. But, even in those cases, you can provide a custom function definition for advanced use cases. An example of an advanced use case is if you want to customize the message that's spoken for `endCall` tool. You can specify a function where it returns an argument \"reason\". Then, in `messages` array, you can have many \"request-complete\" messages. One of these messages will be triggered if the `messages[].conditions` matches the \"reason\" argument.
40#[serde(rename = "function", skip_serializing_if = "Option::is_none")]
41pub function: Option<models::OpenAiFunction>,
42/// This is the name of the tool. This will be passed to the model. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 40.
43#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
44pub name: Option<String>,
45/// This is the description of the tool. This will be passed to the model.
46#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
47pub description: Option<String>,
48/// This is where the request will be sent.
49#[serde(rename = "url")]
50pub url: String,
51/// This is the body of the request.
52#[serde(rename = "body", skip_serializing_if = "Option::is_none")]
53pub body: Option<models::JsonSchema>,
54/// These are the headers to send in the request.
55#[serde(rename = "headers", skip_serializing_if = "Option::is_none")]
56pub headers: Option<models::JsonSchema>,
57/// This is the backoff plan if the request fails. Defaults to undefined (the request will not be retried). @default undefined (the request will not be retried)
58#[serde(rename = "backoffPlan", skip_serializing_if = "Option::is_none")]
59pub backoff_plan: Option<models::BackoffPlan>,
60/// This is the plan that controls the variable extraction from the tool's response.
61#[serde(
62 rename = "variableExtractionPlan",
63 skip_serializing_if = "Option::is_none"
64)]
65pub variable_extraction_plan: Option<models::VariableExtractionPlan>,
66}
6768impl ApiRequestTool {
69pub fn new(
70 r#type: TypeTrue,
71 method: MethodTrue,
72 id: String,
73 org_id: String,
74 created_at: String,
75 updated_at: String,
76 url: String,
77 ) -> ApiRequestTool {
78 ApiRequestTool {
79 messages: None,
80 r#type,
81 method,
82 timeout_seconds: None,
83 id,
84 org_id,
85 created_at,
86 updated_at,
87 function: None,
88 name: None,
89 description: None,
90 url,
91 body: None,
92 headers: None,
93 backoff_plan: None,
94 variable_extraction_plan: None,
95 }
96 }
97}
98/// The type of tool. \"apiRequest\" for API request tool.
99#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
100pub enum TypeTrue {
101#[serde(rename = "apiRequest")]
102ApiRequest,
103}
104105impl Default for TypeTrue {
106fn default() -> TypeTrue {
107Self::ApiRequest
108 }
109}
110///
111#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
112pub enum MethodTrue {
113#[serde(rename = "POST")]
114Post,
115#[serde(rename = "GET")]
116Get,
117}
118119impl Default for MethodTrue {
120fn default() -> MethodTrue {
121Self::Post
122 }
123}