Class: Vapi::Artifact

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(messages: OMIT, messages_open_ai_formatted: OMIT, recording_url: OMIT, stereo_recording_url: OMIT, video_recording_url: OMIT, video_recording_start_delay_seconds: OMIT, recording: OMIT, transcript: OMIT, pcap_url: OMIT, nodes: OMIT, variable_values: OMIT, additional_properties: nil) ⇒ Vapi::Artifact

Parameters:

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

    These are the messages that were spoken during the call.

  • messages_open_ai_formatted (Array<Vapi::OpenAiMessage>) (defaults to: OMIT)

    These are the messages that were spoken during the call, formatted for OpenAI.

  • recording_url (String) (defaults to: OMIT)

    This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

  • stereo_recording_url (String) (defaults to: OMIT)

    This is the stereo recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

  • video_recording_url (String) (defaults to: OMIT)

    This is video recording url for the call. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`.

  • video_recording_start_delay_seconds (Float) (defaults to: OMIT)

    This is video recording start delay in ms. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`. This can be used to align the playback of the recording with artifact.messages timestamps.

  • recording (Vapi::Recording) (defaults to: OMIT)

    This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

  • transcript (String) (defaults to: OMIT)

    This is the transcript of the call. This is derived from ‘artifact.messages` but provided for convenience.

  • pcap_url (String) (defaults to: OMIT)

    This is the packet capture url for the call. This is only available for ‘phone` type calls where phone number’s provider is ‘vapi` or `byo-phone-number`.

  • nodes (Array<Vapi::NodeArtifact>) (defaults to: OMIT)

    This is the history of workflow nodes that were executed during the call.

  • variable_values (Hash{String => Object}) (defaults to: OMIT)

    These are the variable values at the end of the workflow execution.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



71
72
73
74
75
76
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
# File 'lib/vapi_server_sdk/types/artifact.rb', line 71

def initialize(messages: OMIT, messages_open_ai_formatted: OMIT, recording_url: OMIT, stereo_recording_url: OMIT,
               video_recording_url: OMIT, video_recording_start_delay_seconds: OMIT, recording: OMIT, transcript: OMIT, pcap_url: OMIT, nodes: OMIT, variable_values: OMIT, additional_properties: nil)
  @messages = messages if messages != OMIT
  @messages_open_ai_formatted = messages_open_ai_formatted if messages_open_ai_formatted != OMIT
  @recording_url = recording_url if recording_url != OMIT
  @stereo_recording_url = stereo_recording_url if stereo_recording_url != OMIT
  @video_recording_url = video_recording_url if video_recording_url != OMIT
  if video_recording_start_delay_seconds != OMIT
    @video_recording_start_delay_seconds = video_recording_start_delay_seconds
  end
  @recording = recording if recording != OMIT
  @transcript = transcript if transcript != OMIT
  @pcap_url = pcap_url if pcap_url != OMIT
  @nodes = nodes if nodes != OMIT
  @variable_values = variable_values if variable_values != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "messages": messages,
    "messagesOpenAIFormatted": messages_open_ai_formatted,
    "recordingUrl": recording_url,
    "stereoRecordingUrl": stereo_recording_url,
    "videoRecordingUrl": video_recording_url,
    "videoRecordingStartDelaySeconds": video_recording_start_delay_seconds,
    "recording": recording,
    "transcript": transcript,
    "pcapUrl": pcap_url,
    "nodes": nodes,
    "variableValues": variable_values
  }.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



43
44
45
# File 'lib/vapi_server_sdk/types/artifact.rb', line 43

def additional_properties
  @additional_properties
end

#messagesArray<Vapi::ArtifactMessagesItem> (readonly)

Returns These are the messages that were spoken during the call.

Returns:



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

def messages
  @messages
end

#messages_open_ai_formattedArray<Vapi::OpenAiMessage> (readonly)

Returns These are the messages that were spoken during the call, formatted for OpenAI.

Returns:

  • (Array<Vapi::OpenAiMessage>)

    These are the messages that were spoken during the call, formatted for OpenAI.



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

def messages_open_ai_formatted
  @messages_open_ai_formatted
end

#nodesArray<Vapi::NodeArtifact> (readonly)

Returns This is the history of workflow nodes that were executed during the call.

Returns:

  • (Array<Vapi::NodeArtifact>)

    This is the history of workflow nodes that were executed during the call.



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

def nodes
  @nodes
end

#pcap_urlString (readonly)

Returns This is the packet capture url for the call. This is only available for ‘phone` type calls where phone number’s provider is ‘vapi` or `byo-phone-number`.

Returns:

  • (String)

    This is the packet capture url for the call. This is only available for ‘phone` type calls where phone number’s provider is ‘vapi` or `byo-phone-number`.



37
38
39
# File 'lib/vapi_server_sdk/types/artifact.rb', line 37

def pcap_url
  @pcap_url
end

#recordingVapi::Recording (readonly)

Returns This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

Returns:

  • (Vapi::Recording)

    This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.



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

def recording
  @recording
end

#recording_urlString (readonly)

Returns This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

Returns:

  • (String)

    This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.



18
19
20
# File 'lib/vapi_server_sdk/types/artifact.rb', line 18

def recording_url
  @recording_url
end

#stereo_recording_urlString (readonly)

Returns This is the stereo recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

Returns:

  • (String)

    This is the stereo recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.



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

def stereo_recording_url
  @stereo_recording_url
end

#transcriptString (readonly)

Returns This is the transcript of the call. This is derived from ‘artifact.messages` but provided for convenience.

Returns:

  • (String)

    This is the transcript of the call. This is derived from ‘artifact.messages` but provided for convenience.



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

def transcript
  @transcript
end

#variable_valuesHash{String => Object} (readonly)

Returns These are the variable values at the end of the workflow execution.

Returns:

  • (Hash{String => Object})

    These are the variable values at the end of the workflow execution.



41
42
43
# File 'lib/vapi_server_sdk/types/artifact.rb', line 41

def variable_values
  @variable_values
end

#video_recording_start_delay_secondsFloat (readonly)

Returns This is video recording start delay in ms. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`. This can be used to align the playback of the recording with artifact.messages timestamps.

Returns:

  • (Float)

    This is video recording start delay in ms. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`. This can be used to align the playback of the recording with artifact.messages timestamps.



28
29
30
# File 'lib/vapi_server_sdk/types/artifact.rb', line 28

def video_recording_start_delay_seconds
  @video_recording_start_delay_seconds
end

#video_recording_urlString (readonly)

Returns This is video recording url for the call. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`.

Returns:

  • (String)

    This is video recording url for the call. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`.



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

def video_recording_url
  @video_recording_url
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::Artifact

Deserialize a JSON object to an instance of Artifact

Parameters:

  • json_object (String)

Returns:



108
109
110
111
112
113
114
115
116
117
118
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
# File 'lib/vapi_server_sdk/types/artifact.rb', line 108

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::ArtifactMessagesItem.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
  recording_url = parsed_json["recordingUrl"]
  stereo_recording_url = parsed_json["stereoRecordingUrl"]
  video_recording_url = parsed_json["videoRecordingUrl"]
  video_recording_start_delay_seconds = parsed_json["videoRecordingStartDelaySeconds"]
  if parsed_json["recording"].nil?
    recording = nil
  else
    recording = parsed_json["recording"].to_json
    recording = Vapi::Recording.from_json(json_object: recording)
  end
  transcript = parsed_json["transcript"]
  pcap_url = parsed_json["pcapUrl"]
  nodes = parsed_json["nodes"]&.map do |item|
    item = item.to_json
    Vapi::NodeArtifact.from_json(json_object: item)
  end
  variable_values = parsed_json["variableValues"]
  new(
    messages: messages,
    messages_open_ai_formatted: messages_open_ai_formatted,
    recording_url: recording_url,
    stereo_recording_url: stereo_recording_url,
    video_recording_url: video_recording_url,
    video_recording_start_delay_seconds: video_recording_start_delay_seconds,
    recording: recording,
    transcript: transcript,
    pcap_url: pcap_url,
    nodes: nodes,
    variable_values: variable_values,
    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)


165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/vapi_server_sdk/types/artifact.rb', line 165

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.")
  obj.recording_url&.is_a?(String) != false || raise("Passed value for field obj.recording_url is not the expected type, validation failed.")
  obj.stereo_recording_url&.is_a?(String) != false || raise("Passed value for field obj.stereo_recording_url is not the expected type, validation failed.")
  obj.video_recording_url&.is_a?(String) != false || raise("Passed value for field obj.video_recording_url is not the expected type, validation failed.")
  obj.video_recording_start_delay_seconds&.is_a?(Float) != false || raise("Passed value for field obj.video_recording_start_delay_seconds is not the expected type, validation failed.")
  obj.recording.nil? || Vapi::Recording.validate_raw(obj: obj.recording)
  obj.transcript&.is_a?(String) != false || raise("Passed value for field obj.transcript is not the expected type, validation failed.")
  obj.pcap_url&.is_a?(String) != false || raise("Passed value for field obj.pcap_url is not the expected type, validation failed.")
  obj.nodes&.is_a?(Array) != false || raise("Passed value for field obj.nodes is not the expected type, validation failed.")
  obj.variable_values&.is_a?(Hash) != false || raise("Passed value for field obj.variable_values is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Artifact to a JSON object

Returns:

  • (String)


155
156
157
# File 'lib/vapi_server_sdk/types/artifact.rb', line 155

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