Class: Vapi::ServerMessageTranscript

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role:, transcript_type:, transcript:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) ⇒ Vapi::ServerMessageTranscript

Parameters:

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

    This is the phone number associated with the call. This matches one of the following:

    • ‘call.phoneNumber`,

    • ‘call.phoneNumberId`.

  • timestamp (String) (defaults to: OMIT)

    This is the ISO-8601 formatted timestamp of when the message was sent.

  • artifact (Vapi::Artifact) (defaults to: OMIT)

    This is a live version of the ‘call.artifact`. This matches what is stored on `call.artifact` after the call.

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

    This is the assistant that is currently active. This is provided for convenience. This matches one of the following:

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

    This is the customer associated with the call. This matches one of the following:

    • ‘call.customer`,

    • ‘call.customerId`.

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

    This is the call object. This matches what was returned in POST /call. Note: This might get stale during the call. To get the latest call object, especially after the call is ended, use GET /call/:id.

  • role (Vapi::ServerMessageTranscriptRole)

    This is the role for which the transcript is for.

  • transcript_type (Vapi::ServerMessageTranscriptTranscriptType)

    This is the type of the transcript.

  • transcript (String)

    This is the transcript content.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 88

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



52
53
54
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 52

def additional_properties
  @additional_properties
end

#artifactVapi::Artifact (readonly)

Returns This is a live version of the ‘call.artifact`. This matches what is stored on `call.artifact` after the call.

Returns:

  • (Vapi::Artifact)

    This is a live version of the ‘call.artifact`. This matches what is stored on `call.artifact` after the call.



24
25
26
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 24

def artifact
  @artifact
end

#assistantVapi::CreateAssistantDto (readonly)

Returns This is the assistant that is currently active. This is provided for convenience. This matches one of the following:

Returns:



34
35
36
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 34

def assistant
  @assistant
end

#callVapi::Call (readonly)

Returns This is the call object. This matches what was returned in POST /call. Note: This might get stale during the call. To get the latest call object, especially after the call is ended, use GET /call/:id.

Returns:

  • (Vapi::Call)

    This is the call object. This matches what was returned in POST /call. Note: This might get stale during the call. To get the latest call object, especially after the call is ended, use GET /call/:id.



44
45
46
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 44

def call
  @call
end

#customerVapi::CreateCustomerDto (readonly)

Returns This is the customer associated with the call. This matches one of the following:

  • ‘call.customer`,

  • ‘call.customerId`.

Returns:

  • (Vapi::CreateCustomerDto)

    This is the customer associated with the call. This matches one of the following:

    • ‘call.customer`,

    • ‘call.customerId`.



39
40
41
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 39

def customer
  @customer
end

#phone_numberVapi::ServerMessageTranscriptPhoneNumber (readonly)

Returns This is the phone number associated with the call. This matches one of the following:

  • ‘call.phoneNumber`,

  • ‘call.phoneNumberId`.

Returns:



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

def phone_number
  @phone_number
end

#roleVapi::ServerMessageTranscriptRole (readonly)

Returns This is the role for which the transcript is for.

Returns:



46
47
48
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 46

def role
  @role
end

#timestampString (readonly)

Returns This is the ISO-8601 formatted timestamp of when the message was sent.

Returns:

  • (String)

    This is the ISO-8601 formatted timestamp of when the message was sent.



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

def timestamp
  @timestamp
end

#transcriptString (readonly)

Returns This is the transcript content.

Returns:

  • (String)

    This is the transcript content.



50
51
52
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 50

def transcript
  @transcript
end

#transcript_typeVapi::ServerMessageTranscriptTranscriptType (readonly)

Returns This is the type of the transcript.

Returns:



48
49
50
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 48

def transcript_type
  @transcript_type
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ServerMessageTranscript

Deserialize a JSON object to an instance of ServerMessageTranscript

Parameters:

  • json_object (String)

Returns:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 119

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::ServerMessageTranscriptPhoneNumber.from_json(json_object: phone_number)
  end
  timestamp = parsed_json["timestamp"]
  if parsed_json["artifact"].nil?
    artifact = nil
  else
    artifact = parsed_json["artifact"].to_json
    artifact = Vapi::Artifact.from_json(json_object: artifact)
  end
  if parsed_json["assistant"].nil?
    assistant = nil
  else
    assistant = parsed_json["assistant"].to_json
    assistant = Vapi::CreateAssistantDto.from_json(json_object: assistant)
  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["call"].nil?
    call = nil
  else
    call = parsed_json["call"].to_json
    call = Vapi::Call.from_json(json_object: call)
  end
  role = parsed_json["role"]
  transcript_type = parsed_json["transcriptType"]
  transcript = parsed_json["transcript"]
  new(
    phone_number: phone_number,
    timestamp: timestamp,
    artifact: artifact,
    assistant: assistant,
    customer: customer,
    call: call,
    role: role,
    transcript_type: transcript_type,
    transcript: transcript,
    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)


183
184
185
186
187
188
189
190
191
192
193
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 183

def self.validate_raw(obj:)
  obj.phone_number.nil? || Vapi::ServerMessageTranscriptPhoneNumber.validate_raw(obj: obj.phone_number)
  obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.")
  obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact)
  obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant)
  obj.customer.nil? || Vapi::CreateCustomerDto.validate_raw(obj: obj.customer)
  obj.call.nil? || Vapi::Call.validate_raw(obj: obj.call)
  obj.role.is_a?(Vapi::ServerMessageTranscriptRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.")
  obj.transcript_type.is_a?(Vapi::ServerMessageTranscriptTranscriptType) != false || raise("Passed value for field obj.transcript_type is not the expected type, validation failed.")
  obj.transcript.is_a?(String) != false || raise("Passed value for field obj.transcript is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ServerMessageTranscript to a JSON object

Returns:

  • (String)


173
174
175
# File 'lib/vapi_server_sdk/types/server_message_transcript.rb', line 173

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