Class: Vapi::RegexReplacement

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regex:, value:, options: OMIT, additional_properties: nil) ⇒ Vapi::RegexReplacement

Parameters:

  • regex (String)

    This is the regex pattern to replace.

  • options (Array<Vapi::RegexOption>) (defaults to: OMIT)

    These are the options for the regex replacement. Default all options are disabled. @default []

  • 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



32
33
34
35
36
37
38
39
40
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 32

def initialize(regex:, value:, options: OMIT, additional_properties: nil)
  @regex = regex
  @options = options if options != OMIT
  @value = value
  @additional_properties = additional_properties
  @_field_set = { "regex": regex, "options": options, "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



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

def additional_properties
  @additional_properties
end

#optionsArray<Vapi::RegexOption> (readonly)

Returns These are the options for the regex replacement. Default all options are disabled. @default [].

Returns:

  • (Array<Vapi::RegexOption>)

    These are the options for the regex replacement. Default all options are disabled. @default []



14
15
16
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 14

def options
  @options
end

#regexString (readonly)

Returns This is the regex pattern to replace.

Returns:

  • (String)

    This is the regex pattern to replace.



10
11
12
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 10

def regex
  @regex
end

#valueString (readonly)

Returns This is the value that will replace the match.

Returns:

  • (String)

    This is the value that will replace the match.



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

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::RegexReplacement

Deserialize a JSON object to an instance of RegexReplacement

Parameters:

  • json_object (String)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 46

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  regex = parsed_json["regex"]
  options = parsed_json["options"]&.map do |item|
    item = item.to_json
    Vapi::RegexOption.from_json(json_object: item)
  end
  value = parsed_json["value"]
  new(
    regex: regex,
    options: options,
    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)


76
77
78
79
80
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 76

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.options&.is_a?(Array) != false || raise("Passed value for field obj.options 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 RegexReplacement to a JSON object

Returns:

  • (String)


66
67
68
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 66

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