/*
* Vapi API
*
* Voice AI for developers.
*
* The version of the OpenAPI document: 1.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ApiRequestTool {
/// 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.
#[serde(rename = "messages", skip_serializing_if = "Option::is_none")]
pub messages: Option<Vec<models::CreateDtmfToolDtoMessagesInner>>,
/// The type of tool. \"apiRequest\" for API request tool.
#[serde(rename = "type")]
pub r#type: TypeTrue,
#[serde(rename = "method")]
pub method: MethodTrue,
/// This is the timeout in seconds for the request. Defaults to 20 seconds. @default 20
#[serde(rename = "timeoutSeconds", skip_serializing_if = "Option::is_none")]
pub timeout_seconds: Option<f64>,
/// This is the unique identifier for the tool.
#[serde(rename = "id")]
pub id: String,
/// This is the unique identifier for the organization that this tool belongs to.
#[serde(rename = "orgId")]
pub org_id: String,
/// This is the ISO 8601 date-time string of when the tool was created.
#[serde(rename = "createdAt")]
pub created_at: String,
/// This is the ISO 8601 date-time string of when the tool was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: String,
/// 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.
#[serde(rename = "function", skip_serializing_if = "Option::is_none")]
pub function: Option<models::OpenAiFunction>,
/// 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.
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// This is the description of the tool. This will be passed to the model.
#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// This is where the request will be sent.
#[serde(rename = "url")]
pub url: String,
/// This is the body of the request.
#[serde(rename = "body", skip_serializing_if = "Option::is_none")]
pub body: Option<models::JsonSchema>,
/// These are the headers to send in the request.
#[serde(rename = "headers", skip_serializing_if = "Option::is_none")]
pub headers: Option<models::JsonSchema>,
/// 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)
#[serde(rename = "backoffPlan", skip_serializing_if = "Option::is_none")]
pub backoff_plan: Option<models::BackoffPlan>,
/// This is the plan that controls the variable extraction from the tool's response.
#[serde(
rename = "variableExtractionPlan",
skip_serializing_if = "Option::is_none"
)]
pub variable_extraction_plan: Option<models::VariableExtractionPlan>,
}
impl ApiRequestTool {
pub fn new(
r#type: TypeTrue,
method: MethodTrue,
id: String,
org_id: String,
created_at: String,
updated_at: String,
url: String,
) -> ApiRequestTool {
ApiRequestTool {
messages: None,
r#type,
method,
timeout_seconds: None,
id,
org_id,
created_at,
updated_at,
function: None,
name: None,
description: None,
url,
body: None,
headers: None,
backoff_plan: None,
variable_extraction_plan: None,
}
}
}
/// The type of tool. \"apiRequest\" for API request tool.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum TypeTrue {
#[serde(rename = "apiRequest")]
ApiRequest,
}
impl Default for TypeTrue {
fn default() -> TypeTrue {
Self::ApiRequest
}
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum MethodTrue {
#[serde(rename = "POST")]
Post,
#[serde(rename = "GET")]
Get,
}
impl Default for MethodTrue {
fn default() -> MethodTrue {
Self::Post
}
}