Class: Vapi::ResponseOutputMessage

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, content:, role:, status:, type:, additional_properties: nil) ⇒ Vapi::ResponseOutputMessage

Parameters:

  • id (String)

    The unique ID of the output message

  • content (Array<Vapi::ResponseOutputText>)

    Content of the output message

  • role (String)

    The role of the output message

  • status (Vapi::ResponseOutputMessageStatus)

    The status of the message

  • type (String)

    The type of the output message

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



35
36
37
38
39
40
41
42
43
# File 'lib/vapi_server_sdk/types/response_output_message.rb', line 35

def initialize(id:, content:, role:, status:, type:, additional_properties: nil)
  @id = id
  @content = content
  @role = role
  @status = status
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "id": id, "content": content, "role": role, "status": status, "type": type }
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



21
22
23
# File 'lib/vapi_server_sdk/types/response_output_message.rb', line 21

def additional_properties
  @additional_properties
end

#contentArray<Vapi::ResponseOutputText> (readonly)

Returns Content of the output message.

Returns:



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

def content
  @content
end

#idString (readonly)

Returns The unique ID of the output message.

Returns:

  • (String)

    The unique ID of the output message



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

def id
  @id
end

#roleString (readonly)

Returns The role of the output message.

Returns:

  • (String)

    The role of the output message



15
16
17
# File 'lib/vapi_server_sdk/types/response_output_message.rb', line 15

def role
  @role
end

#statusVapi::ResponseOutputMessageStatus (readonly)

Returns The status of the message.

Returns:



17
18
19
# File 'lib/vapi_server_sdk/types/response_output_message.rb', line 17

def status
  @status
end

#typeString (readonly)

Returns The type of the output message.

Returns:

  • (String)

    The type of the output message



19
20
21
# File 'lib/vapi_server_sdk/types/response_output_message.rb', line 19

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ResponseOutputMessage

Deserialize a JSON object to an instance of ResponseOutputMessage

Parameters:

  • json_object (String)

Returns:



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

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


83
84
85
86
87
88
89
# File 'lib/vapi_server_sdk/types/response_output_message.rb', line 83

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.content.is_a?(Array) != false || raise("Passed value for field obj.content is not the expected type, validation failed.")
  obj.role.is_a?(String) != false || raise("Passed value for field obj.role is not the expected type, validation failed.")
  obj.status.is_a?(Vapi::ResponseOutputMessageStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ResponseOutputMessage to a JSON object

Returns:

  • (String)


73
74
75
# File 'lib/vapi_server_sdk/types/response_output_message.rb', line 73

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