Class: Vapi::AssistantCustomEndpointingRule
- Inherits:
-
Object
- Object
- Vapi::AssistantCustomEndpointingRule
- Defined in:
- lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#regex ⇒ String
readonly
This is the regex pattern to match.
-
#regex_options ⇒ Array<Vapi::RegexOption>
readonly
These are the options for the regex match.
-
#timeout_seconds ⇒ Float
readonly
This is the endpointing timeout in seconds, if the rule is matched.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::AssistantCustomEndpointingRule
Deserialize a JSON object to an instance of AssistantCustomEndpointingRule.
-
.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.
Instance Method Summary collapse
- #initialize(regex:, timeout_seconds:, regex_options: OMIT, additional_properties: nil) ⇒ Vapi::AssistantCustomEndpointingRule constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AssistantCustomEndpointingRule to a JSON object.
Constructor Details
#initialize(regex:, timeout_seconds:, regex_options: OMIT, additional_properties: nil) ⇒ Vapi::AssistantCustomEndpointingRule
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 = if != OMIT @timeout_seconds = timeout_seconds @additional_properties = additional_properties @_field_set = { "regex": regex, "regexOptions": , "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.
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. `“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/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 [].
21 22 23 |
# File 'lib/vapi_server_sdk/types/assistant_custom_endpointing_rule.rb', line 21 def @regex_options end |
#timeout_seconds ⇒ Float (readonly)
Returns 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
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"] = 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: , 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.
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.&.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
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 |