Class: Vapi::AssistantCustomEndpointingRule

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/assistant_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(regex:, timeout_seconds:, regex_options: OMIT, additional_properties: nil) ⇒ Vapi::AssistantCustomEndpointingRule

Parameters:

  • regex (String) —

    This is the regex pattern to match. 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. "hello\sthere" 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$".
  • regex_options (Array<Vapi::RegexOption>) (defaults to: OMIT) —

    These are the options for the 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



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 46

def initialize(regex:, timeout_seconds:, regex_options: OMIT, additional_properties: nil)
  @regex = regex
  @regex_options = regex_options if regex_options != OMIT
  @timeout_seconds = timeout_seconds
  @additional_properties = additional_properties
  @_field_set = {
    "regex": regex,
    "regexOptions": regex_options,
    "timeoutSeconds": timeout_seconds
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



25
26
27
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 25

def additional_properties
  @additional_properties
end

#regex ⇒ String (readonly)

This is the regex pattern to match. 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. "hello\sthere" 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. 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. "hello\sthere" 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/assistant_custom_endpointing_rule.rb', line 18

def regex
  @regex
end

#regex_options ⇒ Array<Vapi::RegexOption> (readonly)

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

Returns:

  • (Array<Vapi::RegexOption>) —

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



21
22
23
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 21

def regex_options
  @regex_options
end

#timeout_seconds ⇒ Float (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.



23
24
25
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 23

def timeout_seconds
  @timeout_seconds
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::AssistantCustomEndpointingRule

Deserialize a JSON object to an instance of AssistantCustomEndpointingRule

Parameters:

  • json_object (String)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 64

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  regex = parsed_json["regex"]
  regex_options = parsed_json["regexOptions"]&.map do |item|
    item = item.to_json
    Vapi::RegexOption.from_json(json_object: item)
  end
  timeout_seconds = parsed_json["timeoutSeconds"]
  new(
    regex: regex,
    regex_options: 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)


94
95
96
97
98
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 94

def self.validate_raw(obj:)
  obj.regex.is_a?(String) != false || raise("Passed value for field obj.regex is not the expected type, validation failed.")
  obj.regex_options&.is_a?(Array) != false || raise("Passed value for field obj.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 AssistantCustomEndpointingRule to a JSON object

Returns:

  • (String)


84
85
86
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 84

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