Class: Vapi::ClientMessageSpeechUpdate

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, role:, phone_number: OMIT, turn: OMIT, timestamp: OMIT, call: OMIT, customer: OMIT, assistant: OMIT, additional_properties: nil) ⇒ Vapi::ClientMessageSpeechUpdate

Parameters:

  • phone_number (Vapi::ClientMessageSpeechUpdatePhoneNumber) (defaults to: OMIT)

    This is the phone number that the message is associated with.

  • status (Vapi::ClientMessageSpeechUpdateStatus)

    This is the status of the speech update.

  • role (Vapi::ClientMessageSpeechUpdateRole)

    This is the role which the speech update is for.

  • turn (Float) (defaults to: OMIT)

    This is the turn number of the speech update (0-indexed).

  • timestamp (Float) (defaults to: OMIT)

    This is the timestamp of the message.

  • call (Vapi::Call) (defaults to: OMIT)

    This is the call that the message is associated with.

  • customer (Vapi::CreateCustomerDto) (defaults to: OMIT)

    This is the customer that the message is associated with.

  • assistant (Vapi::CreateAssistantDto) (defaults to: OMIT)

    This is the assistant that the message is associated with.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(status:, role:, phone_number: OMIT, turn: OMIT, timestamp: OMIT, call: OMIT, customer: OMIT,
               assistant: OMIT, additional_properties: nil)
  @phone_number = phone_number if phone_number != OMIT
  @status = status
  @role = role
  @turn = turn if turn != OMIT
  @timestamp = timestamp if timestamp != OMIT
  @call = call if call != OMIT
  @customer = customer if customer != OMIT
  @assistant = assistant if assistant != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "phoneNumber": phone_number,
    "status": status,
    "role": role,
    "turn": turn,
    "timestamp": timestamp,
    "call": call,
    "customer": customer,
    "assistant": assistant
  }.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



31
32
33
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 31

def additional_properties
  @additional_properties
end

#assistantVapi::CreateAssistantDto (readonly)

Returns This is the assistant that the message is associated with.

Returns:



29
30
31
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 29

def assistant
  @assistant
end

#callVapi::Call (readonly)

Returns This is the call that the message is associated with.

Returns:

  • (Vapi::Call)

    This is the call that the message is associated with.



25
26
27
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 25

def call
  @call
end

#customerVapi::CreateCustomerDto (readonly)

Returns This is the customer that the message is associated with.

Returns:



27
28
29
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 27

def customer
  @customer
end

#phone_numberVapi::ClientMessageSpeechUpdatePhoneNumber (readonly)

Returns This is the phone number that the message is associated with.

Returns:



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

def phone_number
  @phone_number
end

#roleVapi::ClientMessageSpeechUpdateRole (readonly)

Returns This is the role which the speech update is for.

Returns:



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

def role
  @role
end

#statusVapi::ClientMessageSpeechUpdateStatus (readonly)

Returns This is the status of the speech update.

Returns:



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

def status
  @status
end

#timestampFloat (readonly)

Returns This is the timestamp of the message.

Returns:

  • (Float)

    This is the timestamp of the message.



23
24
25
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 23

def timestamp
  @timestamp
end

#turnFloat (readonly)

Returns This is the turn number of the speech update (0-indexed).

Returns:

  • (Float)

    This is the turn number of the speech update (0-indexed).



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

def turn
  @turn
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ClientMessageSpeechUpdate

Deserialize a JSON object to an instance of ClientMessageSpeechUpdate

Parameters:

  • json_object (String)

Returns:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 77

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["phoneNumber"].nil?
    phone_number = nil
  else
    phone_number = parsed_json["phoneNumber"].to_json
    phone_number = Vapi::ClientMessageSpeechUpdatePhoneNumber.from_json(json_object: phone_number)
  end
  status = parsed_json["status"]
  role = parsed_json["role"]
  turn = parsed_json["turn"]
  timestamp = parsed_json["timestamp"]
  if parsed_json["call"].nil?
    call = nil
  else
    call = parsed_json["call"].to_json
    call = Vapi::Call.from_json(json_object: call)
  end
  if parsed_json["customer"].nil?
    customer = nil
  else
    customer = parsed_json["customer"].to_json
    customer = Vapi::CreateCustomerDto.from_json(json_object: customer)
  end
  if parsed_json["assistant"].nil?
    assistant = nil
  else
    assistant = parsed_json["assistant"].to_json
    assistant = Vapi::CreateAssistantDto.from_json(json_object: assistant)
  end
  new(
    phone_number: phone_number,
    status: status,
    role: role,
    turn: turn,
    timestamp: timestamp,
    call: call,
    customer: customer,
    assistant: assistant,
    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)


134
135
136
137
138
139
140
141
142
143
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 134

def self.validate_raw(obj:)
  obj.phone_number.nil? || Vapi::ClientMessageSpeechUpdatePhoneNumber.validate_raw(obj: obj.phone_number)
  obj.status.is_a?(Vapi::ClientMessageSpeechUpdateStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.role.is_a?(Vapi::ClientMessageSpeechUpdateRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.")
  obj.turn&.is_a?(Float) != false || raise("Passed value for field obj.turn is not the expected type, validation failed.")
  obj.timestamp&.is_a?(Float) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.")
  obj.call.nil? || Vapi::Call.validate_raw(obj: obj.call)
  obj.customer.nil? || Vapi::CreateCustomerDto.validate_raw(obj: obj.customer)
  obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ClientMessageSpeechUpdate to a JSON object

Returns:

  • (String)


124
125
126
# File 'lib/vapi_server_sdk/types/client_message_speech_update.rb', line 124

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