Class: Vapi::ClientInboundMessageAddMessage

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, trigger_response_enabled: OMIT, additional_properties: nil) ⇒ Vapi::ClientInboundMessageAddMessage

Parameters:

  • message (Vapi::OpenAiMessage)

    This is the message to add to the conversation.

  • trigger_response_enabled (Boolean) (defaults to: OMIT)

    This is the flag to trigger a response, or to insert the message into the conversation history silently. Defaults to ‘true`. Usage:

    • Use ‘true` to trigger a response.

    • Use ‘false` to insert the message into the conversation history silently.

    @default true

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(message:, trigger_response_enabled: OMIT, additional_properties: nil)
  @message = message
  @trigger_response_enabled = trigger_response_enabled if trigger_response_enabled != OMIT
  @additional_properties = additional_properties
  @_field_set = { "message": message, "triggerResponseEnabled": trigger_response_enabled }.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



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

def additional_properties
  @additional_properties
end

#messageVapi::OpenAiMessage (readonly)

Returns This is the message to add to the conversation.

Returns:



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

def message
  @message
end

#trigger_response_enabledBoolean (readonly)

Returns This is the flag to trigger a response, or to insert the message into the conversation history silently. Defaults to ‘true`. Usage:

  • Use ‘true` to trigger a response.

  • Use ‘false` to insert the message into the conversation history silently.

@default true.

Returns:

  • (Boolean)

    This is the flag to trigger a response, or to insert the message into the conversation history silently. Defaults to ‘true`. Usage:

    • Use ‘true` to trigger a response.

    • Use ‘false` to insert the message into the conversation history silently.

    @default true



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

def trigger_response_enabled
  @trigger_response_enabled
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ClientInboundMessageAddMessage

Deserialize a JSON object to an instance of ClientInboundMessageAddMessage

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["message"].nil?
    message = nil
  else
    message = parsed_json["message"].to_json
    message = Vapi::OpenAiMessage.from_json(json_object: message)
  end
  trigger_response_enabled = parsed_json["triggerResponseEnabled"]
  new(
    message: message,
    trigger_response_enabled: trigger_response_enabled,
    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)


78
79
80
81
# File 'lib/vapi_server_sdk/types/client_inbound_message_add_message.rb', line 78

def self.validate_raw(obj:)
  Vapi::OpenAiMessage.validate_raw(obj: obj.message)
  obj.trigger_response_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.trigger_response_enabled is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ClientInboundMessageAddMessage to a JSON object

Returns:

  • (String)


68
69
70
# File 'lib/vapi_server_sdk/types/client_inbound_message_add_message.rb', line 68

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