Class: Vapi::ServerMessageEndOfCallReport

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ended_reason:, artifact:, analysis:, phone_number: OMIT, cost: OMIT, costs: OMIT, timestamp: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, started_at: OMIT, ended_at: OMIT, additional_properties: nil) ⇒ Vapi::ServerMessageEndOfCallReport

Parameters:

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

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

    • ‘call.phoneNumber`,

    • ‘call.phoneNumberId`.

  • ended_reason (Vapi::ServerMessageEndOfCallReportEndedReason)

    This is the reason the call ended. This can also be found at ‘call.endedReason` on GET /call/:id.

  • cost (Float) (defaults to: OMIT)

    This is the cost of the call in USD. This can also be found at ‘call.cost` on GET /call/:id.

  • costs (Array<Vapi::ServerMessageEndOfCallReportCostsItem>) (defaults to: OMIT)

    These are the costs of individual components of the call in USD. This can also be found at ‘call.costs` on GET /call/:id.

  • timestamp (String) (defaults to: OMIT)

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

  • artifact (Vapi::Artifact)

    These are the artifacts from the call. This can also be found at ‘call.artifact` on GET /call/:id.

  • 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.

  • analysis (Vapi::Analysis)

    This is the analysis of the call. This can also be found at ‘call.analysis` on GET /call/:id.

  • started_at (DateTime) (defaults to: OMIT)

    This is the ISO 8601 date-time string of when the call started. This can also be found at ‘call.startedAt` on GET /call/:id.

  • ended_at (DateTime) (defaults to: OMIT)

    This is the ISO 8601 date-time string of when the call ended. This can also be found at ‘call.endedAt` on GET /call/:id.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(ended_reason:, artifact:, analysis:, phone_number: OMIT, cost: OMIT, costs: OMIT, timestamp: OMIT,
               assistant: OMIT, customer: OMIT, call: OMIT, started_at: OMIT, ended_at: OMIT, additional_properties: nil)
  @phone_number = phone_number if phone_number != OMIT
  @ended_reason = ended_reason
  @cost = cost if cost != OMIT
  @costs = costs if costs != OMIT
  @timestamp = timestamp if timestamp != OMIT
  @artifact = artifact
  @assistant = assistant if assistant != OMIT
  @customer = customer if customer != OMIT
  @call = call if call != OMIT
  @analysis = analysis
  @started_at = started_at if started_at != OMIT
  @ended_at = ended_at if ended_at != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "phoneNumber": phone_number,
    "endedReason": ended_reason,
    "cost": cost,
    "costs": costs,
    "timestamp": timestamp,
    "artifact": artifact,
    "assistant": assistant,
    "customer": customer,
    "call": call,
    "analysis": analysis,
    "startedAt": started_at,
    "endedAt": ended_at
  }.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



66
67
68
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 66

def additional_properties
  @additional_properties
end

#analysisVapi::Analysis (readonly)

Returns This is the analysis of the call. This can also be found at ‘call.analysis` on GET /call/:id.

Returns:

  • (Vapi::Analysis)

    This is the analysis of the call. This can also be found at ‘call.analysis` on GET /call/:id.



58
59
60
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 58

def analysis
  @analysis
end

#artifactVapi::Artifact (readonly)

Returns These are the artifacts from the call. This can also be found at ‘call.artifact` on GET /call/:id.

Returns:

  • (Vapi::Artifact)

    These are the artifacts from the call. This can also be found at ‘call.artifact` on GET /call/:id.



35
36
37
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 35

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:



45
46
47
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 45

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.



55
56
57
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 55

def call
  @call
end

#costFloat (readonly)

Returns This is the cost of the call in USD. This can also be found at ‘call.cost` on GET /call/:id.

Returns:

  • (Float)

    This is the cost of the call in USD. This can also be found at ‘call.cost` on GET /call/:id.



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

def cost
  @cost
end

#costsArray<Vapi::ServerMessageEndOfCallReportCostsItem> (readonly)

Returns These are the costs of individual components of the call in USD. This can also be found at ‘call.costs` on GET /call/:id.

Returns:



30
31
32
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 30

def costs
  @costs
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`.



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

def customer
  @customer
end

#ended_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the call ended. This can also be found at ‘call.endedAt` on GET /call/:id.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the call ended. This can also be found at ‘call.endedAt` on GET /call/:id.



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

def ended_at
  @ended_at
end

#ended_reasonVapi::ServerMessageEndOfCallReportEndedReason (readonly)

Returns This is the reason the call ended. This can also be found at ‘call.endedReason` on GET /call/:id.

Returns:



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

def ended_reason
  @ended_reason
end

#phone_numberVapi::ServerMessageEndOfCallReportPhoneNumber (readonly)

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

  • ‘call.phoneNumber`,

  • ‘call.phoneNumberId`.

Returns:



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

def phone_number
  @phone_number
end

#started_atDateTime (readonly)

Returns This is the ISO 8601 date-time string of when the call started. This can also be found at ‘call.startedAt` on GET /call/:id.

Returns:

  • (DateTime)

    This is the ISO 8601 date-time string of when the call started. This can also be found at ‘call.startedAt` on GET /call/:id.



61
62
63
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 61

def started_at
  @started_at
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.



32
33
34
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 32

def timestamp
  @timestamp
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ServerMessageEndOfCallReport

Deserialize a JSON object to an instance of ServerMessageEndOfCallReport

Parameters:

  • json_object (String)

Returns:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 148

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::ServerMessageEndOfCallReportPhoneNumber.from_json(json_object: phone_number)
  end
  ended_reason = parsed_json["endedReason"]
  cost = parsed_json["cost"]
  costs = parsed_json["costs"]&.map do |item|
    item = item.to_json
    Vapi::ServerMessageEndOfCallReportCostsItem.from_json(json_object: item)
  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
  if parsed_json["analysis"].nil?
    analysis = nil
  else
    analysis = parsed_json["analysis"].to_json
    analysis = Vapi::Analysis.from_json(json_object: analysis)
  end
  started_at = (DateTime.parse(parsed_json["startedAt"]) unless parsed_json["startedAt"].nil?)
  ended_at = (DateTime.parse(parsed_json["endedAt"]) unless parsed_json["endedAt"].nil?)
  new(
    phone_number: phone_number,
    ended_reason: ended_reason,
    cost: cost,
    costs: costs,
    timestamp: timestamp,
    artifact: artifact,
    assistant: assistant,
    customer: customer,
    call: call,
    analysis: analysis,
    started_at: started_at,
    ended_at: ended_at,
    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)


226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 226

def self.validate_raw(obj:)
  obj.phone_number.nil? || Vapi::ServerMessageEndOfCallReportPhoneNumber.validate_raw(obj: obj.phone_number)
  obj.ended_reason.is_a?(Vapi::ServerMessageEndOfCallReportEndedReason) != false || raise("Passed value for field obj.ended_reason is not the expected type, validation failed.")
  obj.cost&.is_a?(Float) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.")
  obj.costs&.is_a?(Array) != false || raise("Passed value for field obj.costs is not the expected type, validation failed.")
  obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.")
  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)
  Vapi::Analysis.validate_raw(obj: obj.analysis)
  obj.started_at&.is_a?(DateTime) != false || raise("Passed value for field obj.started_at is not the expected type, validation failed.")
  obj.ended_at&.is_a?(DateTime) != false || raise("Passed value for field obj.ended_at is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ServerMessageEndOfCallReport to a JSON object

Returns:

  • (String)


216
217
218
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 216

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