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, chat: 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 that the message is associated with.

  • 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 (Float) (defaults to: OMIT)

    This is the timestamp of the message.

  • 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 the message is associated with.

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

    This is the customer that the message is associated with.

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

    This is the call that the message is associated with.

  • chat (Vapi::Chat) (defaults to: OMIT)

    This is the chat object.

  • 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



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

def initialize(ended_reason:, artifact:, analysis:, phone_number: OMIT, cost: OMIT, costs: OMIT, timestamp: OMIT,
               assistant: OMIT, customer: OMIT, call: OMIT, chat: 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
  @chat = chat if chat != 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,
    "chat": chat,
    "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



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

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.



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

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.



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

def artifact
  @artifact
end

#assistantVapi::CreateAssistantDto (readonly)

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

Returns:



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

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.



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

def call
  @call
end

#chatVapi::Chat (readonly)

Returns This is the chat object.

Returns:



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

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



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

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:



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

def costs
  @costs
end

#customerVapi::CreateCustomerDto (readonly)

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

Returns:



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

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.



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

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:



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

def ended_reason
  @ended_reason
end

#phone_numberVapi::ServerMessageEndOfCallReportPhoneNumber (readonly)

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

Returns:



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

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.



47
48
49
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 47

def started_at
  @started_at
end

#timestampFloat (readonly)

Returns This is the timestamp of the message.

Returns:

  • (Float)

    This is the timestamp of the message.



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

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:



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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 120

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["chat"].nil?
    chat = nil
  else
    chat = parsed_json["chat"].to_json
    chat = Vapi::Chat.from_json(json_object: chat)
  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,
    chat: chat,
    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)


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 205

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?(Float) != 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)
  obj.chat.nil? || Vapi::Chat.validate_raw(obj: obj.chat)
  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)


195
196
197
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report.rb', line 195

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