Class: Vapi::ClientMessageConversationUpdate

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(messages_open_ai_formatted:, messages: OMIT, additional_properties: nil) ⇒ Vapi::ClientMessageConversationUpdate

Parameters:

  • messages (Array<Vapi::ClientMessageConversationUpdateMessagesItem>) (defaults to: OMIT)

    This is the most up-to-date conversation history at the time the message is sent.

  • messages_open_ai_formatted (Array<Vapi::OpenAiMessage>)

    This is the most up-to-date conversation history at the time the message is sent, formatted for OpenAI.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(messages_open_ai_formatted:, messages: OMIT, additional_properties: nil)
  @messages = messages if messages != OMIT
  @messages_open_ai_formatted = messages_open_ai_formatted
  @additional_properties = additional_properties
  @_field_set = { "messages": messages, "messagesOpenAIFormatted": messages_open_ai_formatted }.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/client_message_conversation_update.rb', line 17

def additional_properties
  @additional_properties
end

#messagesArray<Vapi::ClientMessageConversationUpdateMessagesItem> (readonly)

Returns This is the most up-to-date conversation history at the time the message is sent.

Returns:



12
13
14
# File 'lib/vapi_server_sdk/types/client_message_conversation_update.rb', line 12

def messages
  @messages
end

#messages_open_ai_formattedArray<Vapi::OpenAiMessage> (readonly)

Returns This is the most up-to-date conversation history at the time the message is sent, formatted for OpenAI.

Returns:

  • (Array<Vapi::OpenAiMessage>)

    This is the most up-to-date conversation history at the time the message is sent, formatted for OpenAI.



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

def messages_open_ai_formatted
  @messages_open_ai_formatted
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ClientMessageConversationUpdate

Deserialize a JSON object to an instance of ClientMessageConversationUpdate

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  messages = parsed_json["messages"]&.map do |item|
    item = item.to_json
    Vapi::ClientMessageConversationUpdateMessagesItem.from_json(json_object: item)
  end
  messages_open_ai_formatted = parsed_json["messagesOpenAIFormatted"]&.map do |item|
    item = item.to_json
    Vapi::OpenAiMessage.from_json(json_object: item)
  end
  new(
    messages: messages,
    messages_open_ai_formatted: messages_open_ai_formatted,
    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
# File 'lib/vapi_server_sdk/types/client_message_conversation_update.rb', line 74

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

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ClientMessageConversationUpdate to a JSON object

Returns:

  • (String)


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

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