vapi_client/models/regex_replacement.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 RegexReplacement {
19 /// This is the regex replacement type. You can use this to replace a word or phrase that matches a pattern. Usage: - Replace all numbers with \"some number\": { type: 'regex', regex: '\\\\d+', value: 'some number' } - Replace email addresses with \"[EMAIL]\": { type: 'regex', regex: '\\\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Z|a-z]{2,}\\\\b', value: '[EMAIL]' } - Replace phone numbers with a formatted version: { type: 'regex', regex: '(\\\\d{3})(\\\\d{3})(\\\\d{4})', value: '($1) $2-$3' } - Replace all instances of \"color\" or \"colour\" with \"hue\": { type: 'regex', regex: 'colou?r', value: 'hue' } - Capitalize the first letter of every sentence: { type: 'regex', regex: '(?<=\\\\. |^)[a-z]', value: (match) => match.toUpperCase() }
20 #[serde(rename = "type")]
21 pub r#type: Type,
22 /// This is the regex pattern to replace. Note: - This works by using the `string.replace` method in Node.JS. Eg. `\"hello there\".replace(/hello/g, \"hi\")` will return `\"hi there\"`. Hot tip: - In JavaScript, escape `\\` when sending the regex pattern. Eg. `\"hello\\sthere\"` will be sent over the wire as `\"hellosthere\"`. Send `\"hello\\\\sthere\"` instead.
23 #[serde(rename = "regex")]
24 pub regex: String,
25 /// These are the options for the regex replacement. Defaults to all disabled. @default []
26 #[serde(rename = "options", skip_serializing_if = "Option::is_none")]
27 pub options: Option<Vec<models::RegexOption>>,
28 /// This is the value that will replace the match.
29 #[serde(rename = "value")]
30 pub value: String,
31}
32
33impl RegexReplacement {
34 pub fn new(r#type: Type, regex: String, value: String) -> RegexReplacement {
35 RegexReplacement {
36 r#type,
37 regex,
38 options: None,
39 value,
40 }
41 }
42}
43/// This is the regex replacement type. You can use this to replace a word or phrase that matches a pattern. Usage: - Replace all numbers with \"some number\": { type: 'regex', regex: '\\\\d+', value: 'some number' } - Replace email addresses with \"[EMAIL]\": { type: 'regex', regex: '\\\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Z|a-z]{2,}\\\\b', value: '[EMAIL]' } - Replace phone numbers with a formatted version: { type: 'regex', regex: '(\\\\d{3})(\\\\d{3})(\\\\d{4})', value: '($1) $2-$3' } - Replace all instances of \"color\" or \"colour\" with \"hue\": { type: 'regex', regex: 'colou?r', value: 'hue' } - Capitalize the first letter of every sentence: { type: 'regex', regex: '(?<=\\\\. |^)[a-z]', value: (match) => match.toUpperCase() }
44#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
45pub enum Type {
46 #[serde(rename = "regex")]
47 Regex,
48}
49
50impl Default for Type {
51 fn default() -> Type {
52 Self::Regex
53 }
54}