/// <summary> /// Ends a call if it is still in progress /// /// See: https://www.twilio.com/docs/voice/tutorials/how-to-modify-calls-in-progress-python . /// </summary> /// <param name="callSid">The SID of the call resource.</param> /// <param name="log">A logger instance.</param> /// <returns>A Task returning true if successful and false if failed.</returns> public async Task <bool> HangupCallAsync(string callSid, ILogger log) { log.LogInformation($"Checking with Twilio to see if call '{callSid}' exists and is not completed..."); CallResource call = await FetchCallAsync(callSid, log); if (call.Status != CallResource.StatusEnum.Completed) { log.LogInformation($"Attempting to hangup call '{callSid}'..."); await CallResource.UpdateAsync(callSid, status : CallResource.UpdateStatusEnum.Completed, client : _twilioClient); return(true); } else { log.LogInformation($"Call '{callSid}' has already completed."); return(false); } }