public void FetchStatusAsyncSuccess() { InitializeSecrets(); string expectedCallSid = "CA10000000000000000000000000000003"; string expectedStatusText = "in-progress"; CallResource.StatusEnum expectedStatus = CallResource.StatusEnum.InProgress; string expectedResponseContent = TemplateManager.Load(CallResponseTemplatePath, new Dictionary <string, string>() { { "expectedCallSid", expectedCallSid }, { "expectedStatus", expectedStatusText }, }); HttpResponseMessage expectedResponse = TestHelper.CreateHttpResponseMessage(HttpStatusCode.OK, expectedResponseContent); HttpClientMock httpClient = Container.GetService <IHttpClientWrapper>() as HttpClientMock; httpClient.MessageHandler.RegisterExpectedCallResponse(expectedCallSid, "status", expectedResponse); TwilioCallWrapper callWrapper = Container.GetService <ITwilioCallWrapper>() as TwilioCallWrapper; callWrapper.InitializeAsync( _config[TwilioAccountSidSecretNameAppSettingName], _config[TwilioAuthTokenSecretNameAppSettingName], _config[AuthorityAppSettingName]).Wait(); CallResource.StatusEnum status = callWrapper.FetchStatusAsync(expectedCallSid, Log).Result; Assert.AreEqual(expectedStatus, status); }
/// <summary> /// Initializes a new instance of the <see cref="TwilioFailedCallException"/> class. /// </summary> /// <param name="status">The final call status.</param> /// <param name="message">Additional message regarding failure.</param> public TwilioFailedCallException(CallResource.StatusEnum status, string message) : base(message) { Status = status; }
/// <summary> /// Initializes a new instance of the <see cref="TwilioUnknownCallStatusException"/> class. /// </summary> /// <param name="status">The final call status.</param> /// <param name="message">Additional message describing the exception.</param> public TwilioUnknownCallStatusException(CallResource.StatusEnum status, string message) : base(message) { Status = status; }
public async Task <string> CallMeetingAsync(string mNum) { Console.WriteLine(">\tDialing into webex meeting with access code " + mNum); TwilioClient.Init(_accountSid, _authToken); // call in number and call from number const string vancouverTollNum = "+14084189388"; const string twilioAccNum = "+15046366992"; // this is the webex call vancouver toll number var to = new PhoneNumber(vancouverTollNum); // This is the twilio number linked to our account var from = new PhoneNumber(twilioAccNum); Console.WriteLine(">\tCalling In..."); // makes the call resource to send var call = CallResource.Create(to, from, //method: Twilio.Http.HttpMethod.Get, sendDigits: FormatDigits(mNum) + "wwww#", // Records the outgoing call record: true, // default message that plays from the url url: new Uri("http://lonelycompany.ca/test.xml") ); var callSid = call.Sid; // set status to default value CallResource.StatusEnum status = CallResource.StatusEnum.Queued; // for checking what Sid was used in the loop CallResource finishedCall = null; // wait for meeting to finish while (status != CallResource.StatusEnum.Completed) { // return all the call resources for account user var calls = CallResource.ReadAsync().Result; // find element in list finishedCall = calls.First(record => record.Sid == callSid); var pendingStatus = finishedCall.Status; if (pendingStatus == CallResource.StatusEnum.Ringing) { Console.WriteLine(">\tRinging..."); status = pendingStatus; } else if (pendingStatus == CallResource.StatusEnum.InProgress && status == pendingStatus) { Console.WriteLine(">\tCalled in!"); status = pendingStatus; } // check if the record is if (pendingStatus == CallResource.StatusEnum.Completed) { Console.WriteLine(">\tCall Completed"); // if the call has been completed return the completed status status = pendingStatus; } else if (status == CallResource.StatusEnum.Canceled || status == CallResource.StatusEnum.Failed || status == CallResource.StatusEnum.NoAnswer) { Console.Error.WriteLine(">\tThe call was not completed."); break; } } //var subresourceUri = finishedCall.SubresourceUris; // retrieve 10 most recent recordings var recordings = RecordingResource.Read(limit: 10); var resultRecording = recordings.First(recording => recording.CallSid == callSid); //Console.WriteLine("The recording call sid is: " + resultRecording.CallSid); //Console.WriteLine("The recording sid is: " + resultRecording.Sid); return(resultRecording.Sid); }