Class: Vapi::ExactReplacement

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, value:, replace_all_enabled: OMIT, additional_properties: nil) ⇒ Vapi::ExactReplacement

Parameters:

  • replace_all_enabled (Boolean) (defaults to: OMIT)

    This option let’s you control whether to replace all instances of the key or only the first one. By default, it only replaces the first instance. Examples:

    • For { type: ‘exact’, key: ‘hello’, value: ‘hi’, replaceAllEnabled: false }.

    Before: “hello world, hello universe” | After: “hi world, hello universe”

    • For { type: ‘exact’, key: ‘hello’, value: ‘hi’, replaceAllEnabled: true }.

    Before: “hello world, hello universe” | After: “hi world, hi universe” @default false

  • key (String)

    This is the key to replace.

  • value (String)

    This is the value that will replace the match.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



41
42
43
44
45
46
47
48
49
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 41

def initialize(key:, value:, replace_all_enabled: OMIT, additional_properties: nil)
  @replace_all_enabled = replace_all_enabled if replace_all_enabled != OMIT
  @key = key
  @value = value
  @additional_properties = additional_properties
  @_field_set = { "replaceAllEnabled": replace_all_enabled, "key": key, "value": value }.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



22
23
24
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 22

def additional_properties
  @additional_properties
end

#keyString (readonly)

Returns This is the key to replace.

Returns:

  • (String)

    This is the key to replace.



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

def key
  @key
end

#replace_all_enabledBoolean (readonly)

Returns This option let’s you control whether to replace all instances of the key or only the first one. By default, it only replaces the first instance. Examples:

  • For { type: ‘exact’, key: ‘hello’, value: ‘hi’, replaceAllEnabled: false }.

Before: “hello world, hello universe” | After: “hi world, hello universe”

  • For { type: ‘exact’, key: ‘hello’, value: ‘hi’, replaceAllEnabled: true }.

Before: “hello world, hello universe” | After: “hi world, hi universe” @default false.

Returns:

  • (Boolean)

    This option let’s you control whether to replace all instances of the key or only the first one. By default, it only replaces the first instance. Examples:

    • For { type: ‘exact’, key: ‘hello’, value: ‘hi’, replaceAllEnabled: false }.

    Before: “hello world, hello universe” | After: “hi world, hello universe”

    • For { type: ‘exact’, key: ‘hello’, value: ‘hi’, replaceAllEnabled: true }.

    Before: “hello world, hello universe” | After: “hi world, hi universe” @default false



16
17
18
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 16

def replace_all_enabled
  @replace_all_enabled
end

#valueString (readonly)

Returns This is the value that will replace the match.

Returns:

  • (String)

    This is the value that will replace the match.



20
21
22
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 20

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ExactReplacement

Deserialize a JSON object to an instance of ExactReplacement

Parameters:

  • json_object (String)

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 55

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  replace_all_enabled = parsed_json["replaceAllEnabled"]
  key = parsed_json["key"]
  value = parsed_json["value"]
  new(
    replace_all_enabled: replace_all_enabled,
    key: key,
    value: value,
    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)


82
83
84
85
86
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 82

def self.validate_raw(obj:)
  obj.replace_all_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.replace_all_enabled is not the expected type, validation failed.")
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
  obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ExactReplacement to a JSON object

Returns:

  • (String)


72
73
74
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 72

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