Class: Vapi::BothCustomEndpointingRule
- Inherits:
-
Object
- Object
- Vapi::BothCustomEndpointingRule
- Defined in:
- lib/vapi_server_sdk/types/both_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.
-
#assistant_regex ⇒ String
readonly
This is the regex pattern to match the assistant’s message.
-
#assistant_regex_options ⇒ Array<Vapi::RegexOption>
readonly
These are the options for the assistant’s message regex match.
- #customer_regex ⇒ String readonly
-
#customer_regex_options ⇒ Array<Vapi::RegexOption>
readonly
These are the options for the customer’s message 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::BothCustomEndpointingRule
Deserialize a JSON object to an instance of BothCustomEndpointingRule.
-
.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(assistant_regex:, customer_regex:, timeout_seconds:, assistant_regex_options: OMIT, customer_regex_options: OMIT, additional_properties: nil) ⇒ Vapi::BothCustomEndpointingRule constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of BothCustomEndpointingRule to a JSON object.
Constructor Details
#initialize(assistant_regex:, customer_regex:, timeout_seconds:, assistant_regex_options: OMIT, customer_regex_options: OMIT, additional_properties: nil) ⇒ Vapi::BothCustomEndpointingRule
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 = if != OMIT @customer_regex = customer_regex @customer_regex_options = if != OMIT @timeout_seconds = timeout_seconds @additional_properties = additional_properties @_field_set = { "assistantRegex": assistant_regex, "assistantRegexOptions": , "customerRegex": customer_regex, "customerRegexOptions": , "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.
32 33 34 |
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 32 def additional_properties @additional_properties end |
#assistant_regex ⇒ String (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$”.
18 19 20 |
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 18 def assistant_regex @assistant_regex end |
#assistant_regex_options ⇒ Array<Vapi::RegexOption> (readonly)
Returns 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 end |
#customer_regex ⇒ String (readonly)
24 25 26 |
# File 'lib/vapi_server_sdk/types/both_custom_endpointing_rule.rb', line 24 def customer_regex @customer_regex end |
#customer_regex_options ⇒ Array<Vapi::RegexOption> (readonly)
Returns 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 end |
#timeout_seconds ⇒ Float (readonly)
Returns 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
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"] = parsed_json["assistantRegexOptions"]&.map do |item| item = item.to_json Vapi::RegexOption.from_json(json_object: item) end customer_regex = parsed_json["customerRegex"] = 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: , customer_regex: customer_regex, 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.
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.&.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.&.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
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 |