vapi_client/models/regex_replacement.rs
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 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct RegexReplacement {
16 /// 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() }
17 #[serde(rename = "type")]
18 pub r#type: TypeTrue,
19 /// 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.
20 #[serde(rename = "regex")]
21 pub regex: String,
22 /// These are the options for the regex replacement. Defaults to all disabled. @default []
23 #[serde(rename = "options", skip_serializing_if = "Option::is_none")]
24 pub options: Option<Vec<models::RegexOption>>,
25 /// This is the value that will replace the match.
26 #[serde(rename = "value")]
27 pub value: String,
28}
29
30impl RegexReplacement {
31 pub fn new(r#type: TypeTrue, regex: String, value: String) -> RegexReplacement {
32 RegexReplacement {
33 r#type,
34 regex,
35 options: None,
36 value,
37 }
38 }
39}
40/// 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() }
41#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
42pub enum TypeTrue {
43 #[serde(rename = "regex")]
44 Regex,
45}
46
47impl Default for TypeTrue {
48 fn default() -> TypeTrue {
49 Self::Regex
50 }
51}