Class: Vapi::FormatPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled: OMIT, number_to_digits_cutoff: OMIT, replacements: OMIT, formatters_enabled: OMIT, additional_properties: nil) ⇒ Vapi::FormatPlan

Parameters:

  • enabled (Boolean) (defaults to: OMIT)

    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

  • number_to_digits_cutoff (Float) (defaults to: OMIT)

    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

  • replacements (Array<Vapi::FormatPlanReplacementsItem>) (defaults to: OMIT)

    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 []

  • formatters_enabled (Array<Vapi::FormatPlanFormattersEnabledItem>) (defaults to: OMIT)

    List of formatters to apply. If not provided, all default formatters will be applied. If provided, only the specified formatters will be applied. Note: Some essential formatters like angle bracket removal will always be applied. @default undefined

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 88

def initialize(enabled: OMIT, number_to_digits_cutoff: OMIT, replacements: OMIT, formatters_enabled: 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
  @formatters_enabled = formatters_enabled if formatters_enabled != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "enabled": enabled,
    "numberToDigitsCutoff": number_to_digits_cutoff,
    "replacements": replacements,
    "formattersEnabled": formatters_enabled
  }.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



47
48
49
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 47

def additional_properties
  @additional_properties
end

#enabledBoolean (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.

Returns:

  • (Boolean)

    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



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

def enabled
  @enabled
end

#formatters_enabledArray<Vapi::FormatPlanFormattersEnabledItem> (readonly)

Returns List of formatters to apply. If not provided, all default formatters will be applied. If provided, only the specified formatters will be applied. Note: Some essential formatters like angle bracket removal will always be applied. @default undefined.

Returns:

  • (Array<Vapi::FormatPlanFormattersEnabledItem>)

    List of formatters to apply. If not provided, all default formatters will be applied. If provided, only the specified formatters will be applied. Note: Some essential formatters like angle bracket removal will always be applied. @default undefined



45
46
47
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 45

def formatters_enabled
  @formatters_enabled
end

#number_to_digits_cutoffFloat (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.

Returns:

  • (Float)

    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



29
30
31
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 29

def number_to_digits_cutoff
  @number_to_digits_cutoff
end

#replacementsArray<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 [].

Returns:

  • (Array<Vapi::FormatPlanReplacementsItem>)

    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 []



38
39
40
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 38

def replacements
  @replacements
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::FormatPlan

Deserialize a JSON object to an instance of FormatPlan

Parameters:

  • json_object (String)

Returns:



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 109

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
  formatters_enabled = parsed_json["formattersEnabled"]
  new(
    enabled: enabled,
    number_to_digits_cutoff: number_to_digits_cutoff,
    replacements: replacements,
    formatters_enabled: formatters_enabled,
    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)


141
142
143
144
145
146
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 141

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.")
  obj.formatters_enabled&.is_a?(Array) != false || raise("Passed value for field obj.formatters_enabled is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of FormatPlan to a JSON object

Returns:

  • (String)


131
132
133
# File 'lib/vapi_server_sdk/types/format_plan.rb', line 131

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