public void Execute() { var VONAGE_APPLICATION_ID = Environment.GetEnvironmentVariable("VONAGE_APPLICATION_ID") ?? "VONAGE_APPLICATION_ID"; var VONAGE_PRIVATE_KEY_PATH = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; var UUID = Environment.GetEnvironmentVariable("UUID") ?? "UUID"; var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH); var client = new VonageClient(credentials); var command = new CallEditCommand() { Action = CallEditCommand.ActionType.mute }; var response = client.VoiceClient.UpdateCall(UUID, command); Console.WriteLine($"Mute Call Command succeeded: {response}"); Thread.Sleep(5000); command = new CallEditCommand() { Action = CallEditCommand.ActionType.unmute }; response = client.VoiceClient.UpdateCall(UUID, command); Console.WriteLine($"Mute Call Command succeeded: {response}"); }
public void Execute() { var VONAGE_APPLICATION_ID = Environment.GetEnvironmentVariable("VONAGE_APPLICATION_ID") ?? "VONAGE_APPLICATION_ID"; var VONAGE_PRIVATE_KEY_PATH = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; var UUID = Environment.GetEnvironmentVariable("UUID") ?? "UUID"; var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH); var client = new VonageClient(credentials); var talkAction = new TalkAction() { Text = "This is a transfer action using an inline NCCO" }; var ncco = new Ncco(talkAction); var callEditCommand = new CallEditCommand() { Action = CallEditCommand.ActionType.transfer, Destination = new Destination() { Ncco = ncco } }; var response = client.VoiceClient.UpdateCall(UUID, callEditCommand); Console.WriteLine($"Call transfer success: {response}"); }
public void TestUpdateCall(bool passCreds, bool inlineNcco, bool testTransfer) { var uuid = "63f61863-4a51-4f6b-86e1-46edebcf9356"; var expectedUri = $"{ApiUrl}/v1/calls/{uuid}"; var expectedResponse = ""; string expectedRequestContent; Destination destination; CallEditCommand request; if (testTransfer) { if (inlineNcco) { expectedRequestContent = @"{""action"":""transfer"",""destination"":{""type"":""ncco"",""ncco"":[{""text"":""hello world"",""action"":""talk""}]}}"; destination = new Destination { Type = "ncco", Ncco = new Voice.Nccos.Ncco(new Voice.Nccos.TalkAction { Text = "hello world" }) }; } else { expectedRequestContent = @"{""action"":""transfer"",""destination"":{""type"":""ncco"",""url"":[""https://example.com/ncco.json""]}}"; destination = new Destination { Type = "ncco", Url = new[] { "https://example.com/ncco.json" } }; } request = new CallEditCommand { Destination = destination, Action = CallEditCommand.ActionType.transfer }; } else { expectedRequestContent = @"{""action"":""earmuff""}"; request = new CallEditCommand { Action = CallEditCommand.ActionType.earmuff }; } Setup(expectedUri, expectedResponse, expectedRequestContent); bool response; var creds = Request.Credentials.FromAppIdAndPrivateKey(AppId, PrivateKey); var client = new NexmoClient(creds); if (passCreds) { response = client.VoiceClient.UpdateCall(uuid, request, creds); } else { response = client.VoiceClient.UpdateCall(uuid, request); } Assert.True(response); }
public void Execute() { var VONAGE_APPLICATION_ID = Environment.GetEnvironmentVariable("VONAGE_APPLICATION_ID") ?? "VONAGE_APPLICATION_ID"; var VONAGE_PRIVATE_KEY_PATH = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH"; var UUID = Environment.GetEnvironmentVariable("UUID") ?? "UUID"; var NCCO_URL = Environment.GetEnvironmentVariable("NCCO_URL") ?? "NCCO_URL"; var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH); var client = new VonageClient(credentials); var callEditCommand = new CallEditCommand() { Action = CallEditCommand.ActionType.transfer, Destination = new Destination() { Url = new[] { NCCO_URL } } }; var response = client.VoiceClient.UpdateCall(UUID, callEditCommand); Console.WriteLine($"Call transfer success: {response}"); }
/// <summary> /// PUT /v1/calls/{uuid} - modify an existing Call /// </summary> /// <param name="id">id of call</param> /// <param name="cmd">Command to execute against call</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> public CallResponse Edit(string id, CallEditCommand cmd, Credentials creds = null) { return(Edit(id, cmd, creds ?? Credentials)); }
/// <summary> /// PUT /v1/calls/{uuid} - modify an existing Call /// </summary> /// <param name="id">id of call</param> /// <param name="cmd">Command to execute against call</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> public static CallResponse Edit(string id, CallEditCommand cmd, Credentials creds = null) { var response = VersionedApiRequest.DoRequest("PUT", ApiRequests.GetBaseUriFor(typeof(Call), $"/v1/calls/{id}"), cmd, creds); return(JsonConvert.DeserializeObject <CallResponse>(response.JsonResponse)); }