Class: Vapi::BothCustomEndpointingRule

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assistant_regex:, customer_regex:, timeout_seconds:, assistant_regex_options: OMIT, customer_regex_options: OMIT, additional_properties: nil) ⇒ Vapi::BothCustomEndpointingRule

Parameters:

  • assistant_regex (String)

    This is the regex pattern to match the assistant’s message. Note:

    • This works by using the ‘RegExp.test` method in Node.JS. Eg.

    ‘/hello/.test(“hello there”)` will return `true`. Hot tip:

    • In JavaScript, escape ‘` when sending the regex pattern. Eg. `“hellosthere”`

    will be sent over the wire as ‘“hellosthere”`. Send `“hello\sthere”` instead.

    • ‘RegExp.test` does substring matching, so `/cat/.test(“I love cats”)` will

    return ‘true`. To do full string matching, send “^cat$”.

  • assistant_regex_options (Array<Vapi::RegexOption>) (defaults to: OMIT)

    These are the options for the assistant’s message regex match. Defaults to all disabled. @default []

  • customer_regex (String)
  • customer_regex_options (Array<Vapi::RegexOption>) (defaults to: OMIT)

    These are the options for the customer’s message regex match. Defaults to all disabled. @default []

  • timeout_seconds (Float)

    This is the endpointing timeout in seconds, if the rule is matched.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 58

def initialize(assistant_regex:, customer_regex:, timeout_seconds:, assistant_regex_options: OMIT,
               customer_regex_options: OMIT, additional_properties: nil)
  @assistant_regex = assistant_regex
  @assistant_regex_options = assistant_regex_options if assistant_regex_options != OMIT
  @customer_regex = customer_regex
  @customer_regex_options = customer_regex_options if customer_regex_options != OMIT
  @timeout_seconds = timeout_seconds
  @additional_properties = additional_properties
  @_field_set = {
    "assistantRegex": assistant_regex,
    "assistantRegexOptions": assistant_regex_options,
    "customerRegex": customer_regex,
    "customerRegexOptions": customer_regex_options,
    "timeoutSeconds": timeout_seconds
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



32
33
34
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 32

def additional_properties
  @additional_properties
end

#assistant_regexString (readonly)

This is the regex pattern to match the assistant’s message. Note:

  • This works by using the ‘RegExp.test` method in Node.JS. Eg.

‘/hello/.test(“hello there”)` will return `true`. Hot tip:

  • In JavaScript, escape ‘` when sending the regex pattern. Eg. `“hellosthere”`

will be sent over the wire as ‘“hellosthere”`. Send `“hello\sthere”` instead.

  • ‘RegExp.test` does substring matching, so `/cat/.test(“I love cats”)` will

return ‘true`. To do full string matching, send “^cat$”.

Returns:

  • (String)

    This is the regex pattern to match the assistant’s message. Note:

    • This works by using the ‘RegExp.test` method in Node.JS. Eg.

    ‘/hello/.test(“hello there”)` will return `true`. Hot tip:

    • In JavaScript, escape ‘` when sending the regex pattern. Eg. `“hellosthere”`

    will be sent over the wire as ‘“hellosthere”`. Send `“hello\sthere”` instead.

    • ‘RegExp.test` does substring matching, so `/cat/.test(“I love cats”)` will

    return ‘true`. To do full string matching, send “^cat$”.



18
19
20
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 18

def assistant_regex
  @assistant_regex
end

#assistant_regex_optionsArray<Vapi::RegexOption> (readonly)

Returns These are the options for the assistant’s message regex match. Defaults to all disabled. @default [].

Returns:

  • (Array<Vapi::RegexOption>)

    These are the options for the assistant’s message regex match. Defaults to all disabled. @default []



22
23
24
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 22

def assistant_regex_options
  @assistant_regex_options
end

#customer_regexString (readonly)

Returns:

  • (String)


24
25
26
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 24

def customer_regex
  @customer_regex
end

#customer_regex_optionsArray<Vapi::RegexOption> (readonly)

Returns These are the options for the customer’s message regex match. Defaults to all disabled. @default [].

Returns:

  • (Array<Vapi::RegexOption>)

    These are the options for the customer’s message regex match. Defaults to all disabled. @default []



28
29
30
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 28

def customer_regex_options
  @customer_regex_options
end

#timeout_secondsFloat (readonly)

Returns This is the endpointing timeout in seconds, if the rule is matched.

Returns:

  • (Float)

    This is the endpointing timeout in seconds, if the rule is matched.



30
31
32
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 30

def timeout_seconds
  @timeout_seconds
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::BothCustomEndpointingRule

Deserialize a JSON object to an instance of BothCustomEndpointingRule

Parameters:

  • json_object (String)

Returns:



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 81

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  assistant_regex = parsed_json["assistantRegex"]
  assistant_regex_options = parsed_json["assistantRegexOptions"]&.map do |item|
    item = item.to_json
    Vapi::RegexOption.from_json(json_object: item)
  end
  customer_regex = parsed_json["customerRegex"]
  customer_regex_options = parsed_json["customerRegexOptions"]&.map do |item|
    item = item.to_json
    Vapi::RegexOption.from_json(json_object: item)
  end
  timeout_seconds = parsed_json["timeoutSeconds"]
  new(
    assistant_regex: assistant_regex,
    assistant_regex_options: assistant_regex_options,
    customer_regex: customer_regex,
    customer_regex_options: customer_regex_options,
    timeout_seconds: timeout_seconds,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


118
119
120
121
122
123
124
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 118

def self.validate_raw(obj:)
  obj.assistant_regex.is_a?(String) != false || raise("Passed value for field obj.assistant_regex is not the expected type, validation failed.")
  obj.assistant_regex_options&.is_a?(Array) != false || raise("Passed value for field obj.assistant_regex_options is not the expected type, validation failed.")
  obj.customer_regex.is_a?(String) != false || raise("Passed value for field obj.customer_regex is not the expected type, validation failed.")
  obj.customer_regex_options&.is_a?(Array) != false || raise("Passed value for field obj.customer_regex_options is not the expected type, validation failed.")
  obj.timeout_seconds.is_a?(Float) != false || raise("Passed value for field obj.timeout_seconds is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of BothCustomEndpointingRule to a JSON object

Returns:

  • (String)


108
109
110
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 108

def to_json(*_args)
  @_field_set&.to_json
end