public async Task CreateCallWithMachineDetectionReturnsCreated()
        {
            var accountId     = TestConstants.AccountId;
            var to            = TestConstants.To;
            var from          = TestConstants.From;
            var applicationId = TestConstants.VoiceApplicationId;
            var answerUrl     = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer");
            var machineDetectionConfiguration = new MachineDetectionConfiguration()
            {
                CallbackUrl = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/machine-detection")
            };

            var request = new CreateCallRequest()
            {
                ApplicationId    = applicationId,
                To               = to,
                From             = from,
                AnswerUrl        = answerUrl,
                MachineDetection = machineDetectionConfiguration
            };

            var createCallResponse = await _client.Voice.APIController.CreateCallAsync(accountId, request);

            Assert.Equal(201, createCallResponse.StatusCode);

            Assert.Equal(accountId, createCallResponse.Data.AccountId);
            Assert.Equal(applicationId, createCallResponse.Data.ApplicationId);
            Assert.Equal(to, createCallResponse.Data.To);
            Assert.Equal(from, createCallResponse.Data.From);
            Assert.True(Uri.IsWellFormedUriString(createCallResponse.Data.CallUrl, UriKind.Absolute));
            Assert.Equal(answerUrl, createCallResponse.Data.AnswerUrl);
            Assert.Equal(AnswerMethodEnum.POST, createCallResponse.Data.AnswerMethod);
            Assert.Equal(DisconnectMethodEnum.POST, createCallResponse.Data.DisconnectMethod);
        }
        public async Task CreateCallWithPriorityReturnsCreated()
        {
            var accountId     = TestConstants.AccountId;
            var to            = TestConstants.To;
            var from          = TestConstants.From;
            var applicationId = TestConstants.VoiceApplicationId;
            var answerUrl     = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer");
            var priority      = 4;

            var request = new CreateCallRequest()
            {
                ApplicationId = applicationId,
                To            = to,
                From          = from,
                AnswerUrl     = answerUrl,
                Priority      = priority
            };

            var createCallResponse = await _client.Voice.APIController.CreateCallAsync(accountId, request);

            Assert.Equal(201, createCallResponse.StatusCode);

            Assert.Equal(applicationId, createCallResponse.Data.ApplicationId);
            Assert.Equal(to, createCallResponse.Data.To);
            Assert.Equal(from, createCallResponse.Data.From);
            Assert.Equal(priority, createCallResponse.Data.Priority);
        }
        public void PostCallsTest()
        {
            // TODO: add unit test for the method 'PostCalls'
            CreateCallRequest body = null; // TODO: replace null with proper value
            var response           = instance.PostCalls(body);

            Assert.IsInstanceOf <CreateCallResponse> (response, "response is CreateCallResponse");
        }
 /// <summary>Snippet for CreateCall</summary>
 public void CreateCallRequestObject()
 {
     // Snippet: CreateCall(CreateCallRequest, CallSettings)
     // Create client
     CallsClient callsClient = CallsClient.Create();
     // Initialize request argument(s)
     CreateCallRequest request = new CreateCallRequest
     {
         ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
         Call = new Call(),
     };
     // Make the request
     Call response = callsClient.CreateCall(request);
     // End snippet
 }
        public async stt::Task CreateCallRequestObjectAsync()
        {
            moq::Mock <Calls.CallsClient> mockGrpcClient = new moq::Mock <Calls.CallsClient>(moq::MockBehavior.Strict);
            CreateCallRequest             request        = new CreateCallRequest
            {
                ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
                Call = new Call(),
            };
            Call expectedResponse = new Call
            {
                CallName  = CallName.FromProjectCall("[PROJECT]", "[CALL]"),
                To        = "to03e2b601",
                From      = "fromf8078ad9",
                IsPrivate = false,
                Labels    =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Transport       = Call.Types.Transport.Sip,
                Direction       = Call.Types.Direction.Incoming,
                ErrorCode       = "error_code42bd958e",
                ErrorMessage    = "error_messaged73952bd",
                Price           = new gt::Money(),
                State           = Call.Types.State.Busy,
                CreateTime      = new wkt::Timestamp(),
                StartTime       = new wkt::Timestamp(),
                RingTime        = new wkt::Timestamp(),
                AnswerTime      = new wkt::Timestamp(),
                EndTime         = new wkt::Timestamp(),
                Bridged         = true,
                OriginatingCall = "originating_call9e182b53",
                CreateMethod    = Call.Types.CreateMethod.Api,
                Options         = new Call.Types.ApiCallOptions(),
            };

            mockGrpcClient.Setup(x => x.CreateCallAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Call>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CallsClient client = new CallsClientImpl(mockGrpcClient.Object, null);
            Call        responseCallSettings = await client.CreateCallAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Call responseCancellationToken = await client.CreateCallAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public string CreateCall(string login, string password, string receiver_login)
        {
            string request = SERVER_DOMAIN + CREATE_CALL + "login="******"&password="******"&receiver_login="******"0");
        }
        /// <summary>Snippet for CreateCallAsync</summary>
        public async Task CreateCallRequestObjectAsync()
        {
            // Snippet: CreateCallAsync(CreateCallRequest, CallSettings)
            // Additional: CreateCallAsync(CreateCallRequest, CancellationToken)
            // Create client
            CallsClient callsClient = await CallsClient.CreateAsync();

            // Initialize request argument(s)
            CreateCallRequest request = new CreateCallRequest
            {
                ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
                Call = new Call(),
            };
            // Make the request
            Call response = await callsClient.CreateCallAsync(request);

            // End snippet
        }
Exemple #8
0
        private void CallButton_Click(object sender, EventArgs e)
        {
            try
            {
                var api = new ConversationsApi();

                CreateCallRequest body = new CreateCallRequest();
                body.PhoneNumber = "+6285221675710";

                CreateCallResponse result = api.PostConversationsCalls(body);
                conversationIdTextBox.Text = result.ToJson();
                conversationIdTextBox.Text = result.Id;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public async Task CreateCallInvalidFromPhoneNumberThrows()
        {
            var accountId     = TestConstants.AccountId;
            var to            = TestConstants.To;
            var from          = "abc";
            var applicationId = TestConstants.VoiceApplicationId;
            var answerUrl     = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer");

            var request = new CreateCallRequest()
            {
                ApplicationId = applicationId,
                To            = to,
                From          = from,
                AnswerUrl     = answerUrl
            };

            var ex = await Assert.ThrowsAsync <ApiErrorException>(() => _client.Voice.APIController.CreateCallAsync(accountId, request));

            Assert.Equal("Something's not quite right... Your request is invalid. Please fix it before trying again.", ex.Message);
        }
 partial void Modify_CreateCallRequest(ref CreateCallRequest request, ref gaxgrpc::CallSettings settings);
Exemple #11
0
 public void Init()
 {
     instance = new CreateCallRequest();
 }
 /// <summary>
 /// Creates a call in the state QUEUED. This will cause an outgoing call
 /// to be started.
 ///
 /// The caller must have `voice.calls.create` permission on the project.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override stt::Task <Call> CreateCallAsync(CreateCallRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_CreateCallRequest(ref request, ref callSettings);
     return(_callCreateCall.Async(request, callSettings));
 }
 /// <summary>
 /// Creates a call in the state QUEUED. This will cause an outgoing call
 /// to be started.
 ///
 /// The caller must have `voice.calls.create` permission on the project.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public override Call CreateCall(CreateCallRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_CreateCallRequest(ref request, ref callSettings);
     return(_callCreateCall.Sync(request, callSettings));
 }
 /// <summary>
 /// Creates a call in the state QUEUED. This will cause an outgoing call
 /// to be started.
 ///
 /// The caller must have `voice.calls.create` permission on the project.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Call> CreateCallAsync(CreateCallRequest request, st::CancellationToken cancellationToken) =>
 CreateCallAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
 /// <summary>
 /// Creates a call in the state QUEUED. This will cause an outgoing call
 /// to be started.
 ///
 /// The caller must have `voice.calls.create` permission on the project.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Call> CreateCallAsync(CreateCallRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
 /// <summary>
 /// Creates a call in the state QUEUED. This will cause an outgoing call
 /// to be started.
 ///
 /// The caller must have `voice.calls.create` permission on the project.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual Call CreateCall(CreateCallRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
Exemple #17
0
        public async Task GetCallReturnsOk()
        {
            var accountId     = TestConstants.AccountId;
            var to            = TestConstants.To;
            var from          = TestConstants.From;
            var applicationId = TestConstants.VoiceApplicationId;
            var answerUrl     = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer");

            var request = new CreateCallRequest()
            {
                ApplicationId = applicationId,
                To            = to,
                From          = from,
                AnswerUrl     = answerUrl
            };

            var createCallResponse = await _client.Voice.APIController.CreateCallAsync(accountId, request);

            var callId = createCallResponse.Data.CallId;

            var retries = 5;

            do
            {
                try
                {
                    // Attempt to get the call's state after it has been created.
                    var getCallStateResponse = await _client.Voice.APIController.GetCallAsync(accountId, callId);

                    // No need to retry if we've made it this far.
                    retries = 0;

                    Assert.Equal(200, getCallStateResponse.StatusCode);

                    Assert.Equal(callId, getCallStateResponse.Data.CallId);
                    Assert.Null(getCallStateResponse.Data.ParentCallId);
                    Assert.Equal(applicationId, getCallStateResponse.Data.ApplicationId);
                    Assert.Equal(accountId, getCallStateResponse.Data.AccountId);
                    Assert.Equal(to, getCallStateResponse.Data.To);
                    Assert.Equal(from, getCallStateResponse.Data.From);
                    Assert.Equal("outbound", getCallStateResponse.Data.Direction);
                    Assert.True(getCallStateResponse.Data.State == "initiated" || getCallStateResponse.Data.State == "disconnected");
                    Assert.Null(getCallStateResponse.Data.Identity);
                    Assert.Empty(getCallStateResponse.Data.StirShaken);
                    Assert.IsType <DateTime>(getCallStateResponse.Data.EnqueuedTime);
                    Assert.IsType <DateTime>(getCallStateResponse.Data.StartTime);
                    Assert.Null(getCallStateResponse.Data.AnswerTime);
                    Assert.True(getCallStateResponse.Data.DisconnectCause == null || getCallStateResponse.Data.DisconnectCause == "busy");

                    const string errorMessage = "Callee is busy";
                    Assert.True(getCallStateResponse.Data.ErrorMessage == null || getCallStateResponse.Data.ErrorMessage == errorMessage);
                    // Assert if there's an error id and the error message is unrelated to a busy call.
                    Assert.True(getCallStateResponse.Data.ErrorId == null || getCallStateResponse.Data.ErrorMessage == errorMessage);

                    Assert.IsType <DateTime>(getCallStateResponse.Data.LastUpdate);
                }
                catch (ApiErrorException ex)
                {
                    // There are times when the created call resource is not yet available after creating it.
                    retries = ex.ResponseCode == 404 ? retries - 1 : 0;
                    // Pause to give time to contemplate life.
                    Thread.Sleep(TestConstants.Timeout);
                }
            }while (retries > 0);
        }