public void UpdateVoiceBroadcast() { var expectedJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/updateCallBroadcast.json"); var restRequest = MockRestResponse(expectedJson); var callBroadcast = new CallBroadcast { Id = 11, Name = "Example API VB updated", FromNumber = "12135551189", AnsweringMachineConfig = AnsweringMachineConfig.LIVE_IMMEDIATE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is an updated VB config tts", MachineSoundId = 1258704003 }, ResumeNextDay = true }; Client.CallBroadcastsApi.Update(callBroadcast); Assert.AreEqual(Method.PUT, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.AreEqual(requestBodyParam.Value, expectedJson); Assert.That(restRequest.Value.Resource, Is.StringEnding("/11")); }
public void CreateIvrBroadcast() { var requestJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/createIvrBroadcast.json"); var responseJson = GetJsonPayload("/campaigns/callBroadcastsApi/response/createIvrBroadcast.json"); var restRequest = MockRestResponse(responseJson); var callBroadcast = new CallBroadcast { Name = "Example API IVR", FromNumber = "12135551189", DialplanXml = "<dialplan name=\"Root\"></dialplan>", Recipients = new List<Recipient> { new Recipient { PhoneNumber = "13233832214" }, new Recipient { PhoneNumber = "13233832215" }, } }; var id = Client.CallBroadcastsApi.Create(callBroadcast, true); Assert.That(Serializer.Serialize(id), Is.EqualTo(responseJson)); Assert.AreEqual(Method.POST, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson)); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("start") && p.Value.Equals("True"))); }
public void CreateVoiceBroadcast() { var requestJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/createCallBroadcast.json"); var responseJson = GetJsonPayload("/campaigns/callBroadcastsApi/response/createCallBroadcast.json"); var restRequest = MockRestResponse(responseJson); var callBroadcast = new CallBroadcast { Name = "Example API VB", FromNumber = "12135551189", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List<Recipient> { new Recipient { PhoneNumber = "13233832214" }, new Recipient { PhoneNumber = "13233832215" }, }, ResumeNextDay = true }; var id = Client.CallBroadcastsApi.Create(callBroadcast, true); Assert.That(Serializer.Serialize(id), Is.EqualTo(responseJson)); Assert.AreEqual(Method.POST, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson)); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("start") && p.Value.Equals("True"))); }
public void UpdateIvrBroadcast() { var expectedJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/updateIvrBroadcast.json"); var restRequest = MockRestResponse(expectedJson); var callBroadcast = new CallBroadcast { Id = 12, Name = "Example API IVR updated", FromNumber = "12135551189", DialplanXml = "<dialplan name=\"Root\">\r\n\t<play type=\"tts\">Congratulations! You have successfully configured a CallFire I V R.</play>\r\n</dialplan>" }; Client.CallBroadcastsApi.Update(callBroadcast); Assert.AreEqual(Method.PUT, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.AreEqual(requestBodyParam.Value, expectedJson); Assert.That(restRequest.Value.Resource, Is.StringEnding("/12")); }
public void IvrsCrudOperations() { var broadcast = new CallBroadcast { Name = "ivr_broadcast1", DialplanXml = "<dialplan name=\"Root\"></dialplan>", Recipients = new List<Recipient> { new Recipient { PhoneNumber = "12132212384" }, new Recipient { PhoneNumber = "12132212385" } } }; var id = Client.CallBroadcastsApi.Create(broadcast, true); Console.WriteLine("ivr id: " + id); var savedBroadcast = Client.CallBroadcastsApi.Get(id.Id); Assert.AreEqual(broadcast.Name, savedBroadcast.Name); savedBroadcast.Name = "updated_name"; savedBroadcast.DialplanXml = "<dialplan name=\"Root\">\r\n\t<play type=\"tts\">Congratulations! You have successfully configured a CallFire I V R.</play>\r\n</dialplan>"; Client.CallBroadcastsApi.Update(savedBroadcast); var updatedBroadcast = Client.CallBroadcastsApi.Get(id.Id, "id,name"); Assert.Null(updatedBroadcast.Status); Assert.NotNull(updatedBroadcast.Id); Assert.AreEqual(savedBroadcast.Name, updatedBroadcast.Name); }
public void VoiceBroadcastCrudOperations() { var broadcast = new CallBroadcast { Name = "call_broadcast1", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List<Recipient> { new Recipient { PhoneNumber = "12132212384" }, new Recipient { PhoneNumber = "12132212385" } }, ResumeNextDay = true }; var id = Client.CallBroadcastsApi.Create(broadcast, true); Console.WriteLine("broadcast id: " + id); var savedBroadcast = Client.CallBroadcastsApi.Get(id.Id); Assert.AreEqual(broadcast.Name, savedBroadcast.Name); Assert.AreEqual(savedBroadcast.ResumeNextDay, true); savedBroadcast.Name = "updated_name"; savedBroadcast.Sounds.LiveSoundText = null; savedBroadcast.Sounds.MachineSoundText = null; savedBroadcast.ResumeNextDay = false; Client.CallBroadcastsApi.Update(savedBroadcast); var updatedBroadcast = Client.CallBroadcastsApi.Get(id.Id, "id,name,resumeNextDay"); Assert.Null(updatedBroadcast.Status); Assert.NotNull(updatedBroadcast.Id); Assert.AreEqual(savedBroadcast.Name, updatedBroadcast.Name); Assert.AreEqual(updatedBroadcast.ResumeNextDay, false); }
public void StartStopArchiveCampaign() { var broadcast = new CallBroadcast { Name = "call_broadcast", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List<Recipient> { new Recipient { PhoneNumber = "12132041238" }, new Recipient { PhoneNumber = "14246525473" } } }; var id = Client.CallBroadcastsApi.Create(broadcast, true); CallBroadcast campaign = Client.CallBroadcastsApi.Get(id.Id); Console.WriteLine(campaign); Assert.NotNull(campaign); // start Client.CallBroadcastsApi.Start((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.RUNNING, campaign.Status); // stop Client.CallBroadcastsApi.Stop((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.STOPPED, campaign.Status); // archive Client.CallBroadcastsApi.Archive((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.ARCHIVED, campaign.Status); }
/// <summary> /// Update broadcast /// </summary> /// <param name="broadcast">broadcast to update</param> /// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception> /// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception> /// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception> /// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception> /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception> /// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception> /// <exception cref="CallfireClientException"> in case error has occurred in client.</exception> public void Update(CallBroadcast broadcast) { Validate.NotNull(broadcast.Id, "broadcast.id cannot be null"); Client.Put<object>(CB_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, broadcast.Id.ToString()), broadcast); }
/// <summary> /// Create a call broadcast campaign using the Call Broadcast API. A campaign can be created with /// no contacts and bare minimum configuration, but contacts will have to be added further on to use the campaign. /// If start set to true campaign starts immediately /// </summary> /// <param name="broadcast">call broadcast to create</param> /// <param name="start">if set to true then broadcast will start immediately, by default it set to false</param> /// <returns>ResourceId object with id of created broadcast</returns> /// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception> /// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception> /// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception> /// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception> /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception> /// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception> /// <exception cref="CallfireClientException"> in case error has occurred in client.</exception> public ResourceId Create(CallBroadcast broadcast, bool start = false) { var queryParams = ClientUtils.BuildQueryParams("start", start.ToString()); return Client.Post<ResourceId>(CB_PATH, broadcast, queryParams); }