public async System.Threading.Tasks.Task UpdateAsync() { var call = await CallResource.FetchAsync(SID); SetCall(call); }
public static async Task <Report> GetReport(NotificationResource @event, TwilioRestClient client) { var report = new Report { Sid = @event.Sid, ErrorCode = @event.ErrorCode }; if (otherErrorCodes.Contains(@event.ErrorCode)) { report.ErrorType = ErrorType.Other; return(report); } report.CallSid = @event.CallSid; var url = GetUrl(@event); if (url == null) { throw new ArgumentException($"Can't determine url for {@event.Sid}"); } if (url.EndsWith("/InboundCallDialStatusChange") || url.EndsWith("/OutboundCallDialStatusChange") || url.EndsWith("/OutboundCallConnected") || // not necessary for call connection callback url.EndsWith("/InboundCallStatus") || url.EndsWith("/OutboundCallStatus") ) { report.ErrorType = ErrorType.CallWasConnected; return(report); } if (url.EndsWith("/Tulsa")) { report.ErrorType = ErrorType.CallWasntConnected; report.TenantPhone = "tulsa"; return(report); } if (url.EndsWith("/Okc")) { report.ErrorType = ErrorType.CallWasntConnected; report.TenantPhone = "okc"; return(report); } if (url.EndsWith("/Index")) { var msg = GetPartOf(@event.MessageText, "Msg"); if ( msg?.StartsWith( "HTTP+Connection+Failure+-+Read+timed+out.+Falling+back+to+http%3A%2F%2Ftwimlets.com%2Fforward%3FPhoneNumber%3D%25") == true || msg?.StartsWith( "An+attempt+to+retrieve+content+from+https%3A%2F%2Ftwilio.servicetitan.com%2FTwilioProxy%2FIndex+returned+the+HTTP+status+code+502.+Falling+back+to+http%3A%2F%2Ftwimlets.com%2Fforward%3FPhoneNumber%3D%25") == true || msg?.StartsWith( "An+attempt+to+retrieve+content+from+https%3A%2F%2Ftwilio.servicetitan.com%2FTwilioProxy%2FIndex+returned+the+HTTP+status+code+502.+Falling+back+to+https%3A%2F%2Fignorant-goat-7596.twil.io") == true || msg?.StartsWith( "HTTP+Connection+Failure+-+Read+timed+out.+Falling+back+to+https%3A%2F%2Fignorant-goat-7596.twil.io") == true || GetPartOf(@event.MessageText, "msg")?.StartsWith( "HTTP+Connection+Failure+-+Read+timed+out.+Falling+back+to+http%3A%2F%2Ftwimlets.com%2Fforward%3FPhoneNumber%3D%25") == true ) { report.ErrorType = ErrorType.CallWasConnected; return(report); } } var call = await CallResource.FetchAsync(@event.CallSid, client : client); if (url.EndsWith("/OutboundCallGather")) { report.ErrorType = ErrorType.CallWasntConnected; report.TenantPhone = call.From; } else if (url.EndsWith("/OutboundCallResponse")) { if (await HasChildren(call, client)) { throw new NotSupportedException($"OutboundCallResponse - {@event.Sid}"); } report.ErrorType = ErrorType.CallWasntConnected; report.TenantPhone = call.From; } else if (url.EndsWith("/Index")) { if (await HasChildren(call, client)) { throw new NotSupportedException($"Index - {@event.Sid}"); } report.ErrorType = ErrorType.CallWasntConnected; report.TenantPhone = call.To; } return(report); }
public async Task UpdateAsync() { var call = await CallResource.FetchAsync(m_sid); SetCall(call); }
/// <summary> /// Retrieves a call object from the call sid. /// </summary> /// <param name="callSid">The SID of the call resource to retrieve.</param> /// <param name="log">A logger instance.</param> /// <returns>A Task returning the call resource.</returns> public async Task <CallResource> FetchCallAsync(string callSid, ILogger log) { log.LogInformation($"Attempting to fetch call '{callSid}' from Twilio..."); return(await CallResource.FetchAsync(callSid, client : _twilioClient)); }