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 CreateApiRequestToolDto {
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 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.
28#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
29pub name: Option<String>,
30/// This is the description of the tool. This will be passed to the model.
31#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
32pub description: Option<String>,
33/// This is where the request will be sent.
34#[serde(rename = "url")]
35pub url: String,
36/// This is the body of the request.
37#[serde(rename = "body", skip_serializing_if = "Option::is_none")]
38pub body: Option<models::JsonSchema>,
39/// These are the headers to send in the request.
40#[serde(rename = "headers", skip_serializing_if = "Option::is_none")]
41pub headers: Option<models::JsonSchema>,
42/// 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)
43#[serde(rename = "backoffPlan", skip_serializing_if = "Option::is_none")]
44pub backoff_plan: Option<models::BackoffPlan>,
45/// This is the plan that controls the variable extraction from the tool's response.
46#[serde(
47 rename = "variableExtractionPlan",
48 skip_serializing_if = "Option::is_none"
49)]
50pub variable_extraction_plan: Option<models::VariableExtractionPlan>,
51/// 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.
52#[serde(rename = "function", skip_serializing_if = "Option::is_none")]
53pub function: Option<models::OpenAiFunction>,
54}
5556impl CreateApiRequestToolDto {
57pub fn new(r#type: TypeTrue, method: MethodTrue, url: String) -> CreateApiRequestToolDto {
58 CreateApiRequestToolDto {
59 messages: None,
60 r#type,
61 method,
62 timeout_seconds: None,
63 name: None,
64 description: None,
65 url,
66 body: None,
67 headers: None,
68 backoff_plan: None,
69 variable_extraction_plan: None,
70 function: None,
71 }
72 }
73}
74/// The type of tool. \"apiRequest\" for API request tool.
75#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
76pub enum TypeTrue {
77#[serde(rename = "apiRequest")]
78ApiRequest,
79}
8081impl Default for TypeTrue {
82fn default() -> TypeTrue {
83Self::ApiRequest
84 }
85}
86///
87#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
88pub enum MethodTrue {
89#[serde(rename = "POST")]
90Post,
91#[serde(rename = "GET")]
92Get,
93}
9495impl Default for MethodTrue {
96fn default() -> MethodTrue {
97Self::Post
98 }
99}