Class: Vapi::FormatPlan
- Inherits:
-
Object
- Object
- Vapi::FormatPlan
- Defined in:
- lib/vapi_server_sdk/types/format_plan.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#enabled ⇒ Boolean
readonly
This determines whether the chunk is formatted before being sent to the voice provider.
-
#number_to_digits_cutoff ⇒ Float
readonly
This is the cutoff after which a number is converted to individual digits instead of being spoken as words.
-
#replacements ⇒ Array<Vapi::FormatPlanReplacementsItem>
readonly
These are the custom replacements you can make to the chunk before it is sent to the voice provider.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::FormatPlan
Deserialize a JSON object to an instance of FormatPlan.
-
.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(enabled: OMIT, number_to_digits_cutoff: OMIT, replacements: OMIT, additional_properties: nil) ⇒ Vapi::FormatPlan constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of FormatPlan to a JSON object.
Constructor Details
#initialize(enabled: OMIT, number_to_digits_cutoff: OMIT, replacements: OMIT, additional_properties: nil) ⇒ Vapi::FormatPlan
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 74 def initialize(enabled: OMIT, number_to_digits_cutoff: OMIT, replacements: OMIT, additional_properties: nil) @enabled = enabled if enabled != OMIT @number_to_digits_cutoff = number_to_digits_cutoff if number_to_digits_cutoff != OMIT @replacements = replacements if replacements != OMIT @additional_properties = additional_properties @_field_set = { "enabled": enabled, "numberToDigitsCutoff": number_to_digits_cutoff, "replacements": replacements }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
39 40 41 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 39 def additional_properties @additional_properties end |
#enabled ⇒ Boolean (readonly)
Returns This determines whether the chunk is formatted before being sent to the voice provider. This helps with enunciation. This includes phone numbers, emails and addresses. Default true. Usage:
-
To rely on the voice provider’s formatting logic, set this to
false.
If voice.chunkPlan.enabled is false, this is automatically false since there’s no chunk to format. @default true.
17 18 19 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 17 def enabled @enabled end |
#number_to_digits_cutoff ⇒ Float (readonly)
Returns This is the cutoff after which a number is converted to individual digits instead of being spoken as words. Example:
-
If cutoff 2025, “12345” is converted to “1 2 3 4 5” while “1200” is converted
to “twelve hundred”. Usage:
-
If your use case doesn’t involve IDs like zip codes, set this to a high value.
-
If your use case involves IDs that are shorter than 5 digits, set this to a
lower value. @default 2025.
28 29 30 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 28 def number_to_digits_cutoff @number_to_digits_cutoff end |
#replacements ⇒ Array<Vapi::FormatPlanReplacementsItem> (readonly)
Returns These are the custom replacements you can make to the chunk before it is sent to the voice provider. Usage:
-
To replace a specific word or phrase with a different word or phrase, use the
ExactReplacement type. Eg. ‘{ type: ’exact’, key: ‘hello’, value: ‘hi’ }‘
-
To replace a word or phrase that matches a pattern, use the
RegexReplacement
type. Eg. ‘{ type: ’regex’, regex: ‘\b5\b’, value: ‘hi’ }‘ @default [].
37 38 39 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 37 def replacements @replacements end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::FormatPlan
Deserialize a JSON object to an instance of FormatPlan
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 92 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) enabled = parsed_json["enabled"] number_to_digits_cutoff = parsed_json["numberToDigitsCutoff"] replacements = parsed_json["replacements"]&.map do |item| item = item.to_json Vapi::FormatPlanReplacementsItem.from_json(json_object: item) end new( enabled: enabled, number_to_digits_cutoff: number_to_digits_cutoff, replacements: replacements, 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.
122 123 124 125 126 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 122 def self.validate_raw(obj:) obj.enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.") obj.number_to_digits_cutoff&.is_a?(Float) != false || raise("Passed value for field obj.number_to_digits_cutoff is not the expected type, validation failed.") obj.replacements&.is_a?(Array) != false || raise("Passed value for field obj.replacements is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of FormatPlan to a JSON object
112 113 114 |
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 112 def to_json(*_args) @_field_set&.to_json end |