Class: Vapi::ToolMessageDelayed

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, timing_milliseconds: OMIT, conditions: OMIT, additional_properties: nil) ⇒ Vapi::ToolMessageDelayed

Parameters:

  • timing_milliseconds (Float) (defaults to: OMIT)

    The number of milliseconds to wait for the server response before saying this message.

  • content (String)

    This is the content that the assistant says when this message is triggered.

  • conditions (Array<Vapi::Condition>) (defaults to: OMIT)

    This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vapi_server_sdk/types/tool_message_delayed.rb', line 32

def initialize(content:, timing_milliseconds: OMIT, conditions: OMIT, additional_properties: nil)
  @timing_milliseconds = timing_milliseconds if timing_milliseconds != OMIT
  @content = content
  @conditions = conditions if conditions != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "timingMilliseconds": timing_milliseconds,
    "content": content,
    "conditions": conditions
  }.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/tool_message_delayed.rb', line 18

def additional_properties
  @additional_properties
end

#conditionsArray<Vapi::Condition> (readonly)

Returns This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered.

Returns:

  • (Array<Vapi::Condition>)

    This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered.



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

def conditions
  @conditions
end

#contentString (readonly)

Returns This is the content that the assistant says when this message is triggered.

Returns:

  • (String)

    This is the content that the assistant says when this message is triggered.



13
14
15
# File 'lib/vapi_server_sdk/types/tool_message_delayed.rb', line 13

def content
  @content
end

#timing_millisecondsFloat (readonly)

Returns The number of milliseconds to wait for the server response before saying this message.

Returns:

  • (Float)

    The number of milliseconds to wait for the server response before saying this message.



11
12
13
# File 'lib/vapi_server_sdk/types/tool_message_delayed.rb', line 11

def timing_milliseconds
  @timing_milliseconds
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ToolMessageDelayed

Deserialize a JSON object to an instance of ToolMessageDelayed

Parameters:

  • json_object (String)

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vapi_server_sdk/types/tool_message_delayed.rb', line 50

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  timing_milliseconds = parsed_json["timingMilliseconds"]
  content = parsed_json["content"]
  conditions = parsed_json["conditions"]&.map do |item|
    item = item.to_json
    Vapi::Condition.from_json(json_object: item)
  end
  new(
    timing_milliseconds: timing_milliseconds,
    content: content,
    conditions: conditions,
    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)


80
81
82
83
84
# File 'lib/vapi_server_sdk/types/tool_message_delayed.rb', line 80

def self.validate_raw(obj:)
  obj.timing_milliseconds&.is_a?(Float) != false || raise("Passed value for field obj.timing_milliseconds is not the expected type, validation failed.")
  obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.")
  obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ToolMessageDelayed to a JSON object

Returns:

  • (String)


70
71
72
# File 'lib/vapi_server_sdk/types/tool_message_delayed.rb', line 70

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