Class: Vapi::ExactReplacement
- Inherits:
-
Object
- Object
- Vapi::ExactReplacement
- Defined in:
- lib/vapi_server_sdk/types/exact_replacement.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#key ⇒ String
readonly
This is the key to replace.
-
#replace_all_enabled ⇒ Boolean
readonly
This option let’s you control whether to replace all instances of the key or only the first one.
-
#value ⇒ String
readonly
This is the value that will replace the match.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ExactReplacement
Deserialize a JSON object to an instance of ExactReplacement.
-
.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(key:, value:, replace_all_enabled: OMIT, additional_properties: nil) ⇒ Vapi::ExactReplacement constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ExactReplacement to a JSON object.
Constructor Details
#initialize(key:, value:, replace_all_enabled: OMIT, additional_properties: nil) ⇒ Vapi::ExactReplacement
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#key ⇒ String (readonly)
Returns 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_enabled ⇒ Boolean (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.
16 17 18 |
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 16 def replace_all_enabled @replace_all_enabled end |
#value ⇒ String (readonly)
Returns 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
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.
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
72 73 74 |
# File 'lib/vapi_server_sdk/types/exact_replacement.rb', line 72 def to_json(*_args) @_field_set&.to_json end |