Class: Vapi::WebChat

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, output:, session_id: OMIT, additional_properties: nil) ⇒ Vapi::WebChat

Parameters:

  • id (String)

    This is the unique identifier for the chat.

  • session_id (String) (defaults to: OMIT)

    This is the ID of the session for the chat. Send it in the next chat request to continue the conversation.

  • output (Array<Vapi::WebChatOutputItem>)

    This is the output messages generated by the system in response to the input.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



30
31
32
33
34
35
36
37
38
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 30

def initialize(id:, output:, session_id: OMIT, additional_properties: nil)
  @id = id
  @session_id = session_id if session_id != OMIT
  @output = output
  @additional_properties = additional_properties
  @_field_set = { "id": id, "sessionId": session_id, "output": output }.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



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

def additional_properties
  @additional_properties
end

#idString (readonly)

Returns This is the unique identifier for the chat.

Returns:

  • (String)

    This is the unique identifier for the chat.



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

def id
  @id
end

#outputArray<Vapi::WebChatOutputItem> (readonly)

Returns This is the output messages generated by the system in response to the input.

Returns:

  • (Array<Vapi::WebChatOutputItem>)

    This is the output messages generated by the system in response to the input.



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

def output
  @output
end

#session_idString (readonly)

Returns This is the ID of the session for the chat. Send it in the next chat request to continue the conversation.

Returns:

  • (String)

    This is the ID of the session for the chat. Send it in the next chat request to continue the conversation.



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

def session_id
  @session_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::WebChat

Deserialize a JSON object to an instance of WebChat

Parameters:

  • json_object (String)

Returns:



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

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


74
75
76
77
78
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 74

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.session_id&.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.")
  obj.output.is_a?(Array) != false || raise("Passed value for field obj.output is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WebChat to a JSON object

Returns:

  • (String)


64
65
66
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 64

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