From 97d3a706a4486366c5f77355357e9ca069a83ece Mon Sep 17 00:00:00 2001 From: vmalinovskiy Date: Mon, 21 Nov 2016 13:13:07 +0200 Subject: [PATCH 1/4] vmalinovskiy: added deleteCampaignSound, getCreditsUsage apis, removed Dnc Lists api --- CallfireApiClient.nuspec | 7 +- docs/api/ApiExamples.adoc | 3 +- docs/api/account/MeApi.adoc | 12 + docs/api/campaigns/CampaignSoundsApi.adoc | 7 + docs/api/contacts/DncListsApi.adoc | 84 ------- .../Api/Account/MeApiIntegrationTest.cs | 26 +++ .../CampaignSoundsApiIntegrationTest.cs | 16 ++ .../ContactListsApiIntegrationTest.cs | 2 +- .../Contacts/DncListsApiIntegrationTest.cs | 70 ------ .../CallfireApiClient.IntegrationTests.csproj | 1 - .../Api/Account/MeApiTest.cs | 26 +++ .../Api/Campaigns/CampaignSoundsApiTest.cs | 11 + .../Api/Contacts/DncApiTest.cs | 2 +- .../Api/Contacts/DncListsApiTest.cs | 215 ------------------ .../CallfireApiClient.Tests.csproj | 10 +- .../meApi/response/getCreditsUsage.json | 7 + .../contacts/dncApi/request/addDncItems.json | 6 - .../dncApi/request/createDncList.json | 8 - .../dncApi/response/createDncList.json | 5 - .../dncApi/response/findDncLists.json | 14 -- .../{findDncList.json => findDncs.json} | 0 .../contacts/dncApi/response/getDncList.json | 8 - .../response/getUniversalDncNumbers.json | 12 - src/CallfireApiClient/Api/Account/MeApi.cs | 21 ++ .../Api/Account/Model/CreditsUsage.cs | 47 ++++ .../Model/Request/DateIntervalRequest.cs | 28 +++ .../Api/Campaigns/CampaignSoundsApi.cs | 21 +- .../Api/Common/Model/ListHolder.cs | 1 + .../Api/Contacts/DncListsApi.cs | 197 ---------------- .../Api/Contacts/Model/DncList.cs | 20 -- .../Model/Request/AddDncListItemsRequest.cs | 16 -- .../Model/Request/FindDncListsRequest.cs | 16 -- .../CallfireApiClient.csproj | 6 +- src/CallfireApiClient/CallfireClient.cs | 4 - .../Properties/AssemblyInfo.cs | 2 +- src/CallfireApiClient/RestApiClient.cs | 2 +- 36 files changed, 234 insertions(+), 699 deletions(-) delete mode 100644 docs/api/contacts/DncListsApi.adoc delete mode 100644 src/CallfireApiClient.IntegrationTests/Api/Contacts/DncListsApiIntegrationTest.cs delete mode 100644 src/CallfireApiClient.Tests/Api/Contacts/DncListsApiTest.cs create mode 100644 src/CallfireApiClient.Tests/JsonMocks/account/meApi/response/getCreditsUsage.json delete mode 100644 src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/addDncItems.json delete mode 100644 src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/createDncList.json delete mode 100644 src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/createDncList.json delete mode 100644 src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncLists.json rename src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/{findDncList.json => findDncs.json} (100%) delete mode 100644 src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getDncList.json delete mode 100644 src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getUniversalDncNumbers.json create mode 100644 src/CallfireApiClient/Api/Account/Model/CreditsUsage.cs create mode 100644 src/CallfireApiClient/Api/Account/Model/Request/DateIntervalRequest.cs delete mode 100644 src/CallfireApiClient/Api/Contacts/DncListsApi.cs delete mode 100644 src/CallfireApiClient/Api/Contacts/Model/DncList.cs delete mode 100644 src/CallfireApiClient/Api/Contacts/Model/Request/AddDncListItemsRequest.cs delete mode 100644 src/CallfireApiClient/Api/Contacts/Model/Request/FindDncListsRequest.cs diff --git a/CallfireApiClient.nuspec b/CallfireApiClient.nuspec index fc5c006..3db0831 100644 --- a/CallfireApiClient.nuspec +++ b/CallfireApiClient.nuspec @@ -1,7 +1,7 @@ CallfireApiClient - 1.1.10 + 1.1.11 CallFire API v2 client Vladimir Mikhailov @@ -15,6 +15,11 @@ C# client library for integration with Callfire REST API v2 services Callfire API client Changelog ============================= +Version 1.1.11 - Nov 18 2016 +- added deleteCampaignSound api +- added getCreditsHistory api +- remove dnc lists api (not supported anymore) + Version 1.1.10 - Oct 26 2016 - added more parameters to call tracking config in Number Lease config object diff --git a/docs/api/ApiExamples.adoc b/docs/api/ApiExamples.adoc index 1d7f960..cd626b9 100644 --- a/docs/api/ApiExamples.adoc +++ b/docs/api/ApiExamples.adoc @@ -12,11 +12,10 @@ *** link:campaigns/BatchesApi.adoc[Contact batches] *** link:campaigns/CallBroadcastsApi.adoc[Call broadcasts] *** link:campaigns/TextBroadcastsApi.adoc[Text broadcasts] -* Contacts & Do Not Contact (DNC) lists +* Contacts & Dncs ** link:contacts/ContactsApi.adoc[User contacts] ** link:contacts/ContactListsApi.adoc[Contact lists] ** link:contacts/DncApi.adoc[Do Not Contact API] -** link:contacts/DncListsApi.adoc[Do Not Contact lists API] * link:keywords/KeywordsMain.adoc[Keywords & keyword leases API] * link:numbers/NumbersMain.adoc[Numbers & number leases API] * link:webhooks/SubscriptionsApi.adoc[Subscriptions API] diff --git a/docs/api/account/MeApi.adoc b/docs/api/account/MeApi.adoc index 54c87b7..3de11ce 100644 --- a/docs/api/account/MeApi.adoc +++ b/docs/api/account/MeApi.adoc @@ -18,6 +18,18 @@ Example how to find billing plan usage for the user. Returns billing plan usage BillingPlanUsage plan = Client.MeApi.GetBillingPlanUsage(); Console.WriteLine("Plan: " + plan.ToString()); +=== Get credits usage info +''' +Example how find credit usage for the user. Returns credits usage for time period specified or if unspecified then total for all time. +[source,csharp] + CallfireClient Client = new CallfireClient("api_login", "api_password"); + var request = new DateIntervalRequest + { + IntervalBegin = DateTime.UtcNow.AddMonths(-2), + IntervalEnd = DateTime.UtcNow + }; + CreditsUsage creditsUsage = Client.MeApi.GetCreditUsage(request); + === Get account caller IDs ''' Example how to get a list of verified caller ids. If the number is not shown in the list, then it is not verified, diff --git a/docs/api/campaigns/CampaignSoundsApi.adoc b/docs/api/campaigns/CampaignSoundsApi.adoc index c8b4d2d..d9caa42 100644 --- a/docs/api/campaigns/CampaignSoundsApi.adoc +++ b/docs/api/campaigns/CampaignSoundsApi.adoc @@ -20,6 +20,13 @@ Returns a single CampaignSound instance for a given campaign sound id. This is t CallfireClient Client = new CallfireClient("api_login", "api_password"); CampaignSound campaignSound = Client.CampaignSoundsApi.Get(12345, "name,status,lengthInSeconds"); +=== Delete campaign sound +''' +Example how to delete a single CampaignSound instance for a given campaign sound id. +[source,csharp] + CallfireClient Client = new CallfireClient("api_login", "api_password"); + Client.CampaignSoundsApi.Delete(12345); + === Download MP3 sound ''' Download the MP3 version of the hosted file. diff --git a/docs/api/contacts/DncListsApi.adoc b/docs/api/contacts/DncListsApi.adoc deleted file mode 100644 index 8f0fe84..0000000 --- a/docs/api/contacts/DncListsApi.adoc +++ /dev/null @@ -1,84 +0,0 @@ -= DNC lists API - - -=== Find dnc lists -''' -Example how to find all do not contact (DNC) lists. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var findRequest = new FindDncListsRequest(); - Page doNotCallLists = Client.DncListsApi.Find(findRequest); - Console.WriteLine("Page of dnc lists:" + doNotCallLists); - -=== Create dnc list -''' -Example how to create do not contact (DNC) list. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - DncList dncList = new DncList { Name = "dncList1" }; - ResourceId dncListId = Client.DncListsApi.Create(dncList); - -=== Get universal dnc numbers -''' -Example how to search Universal Do Not Contact by number. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - IList universalDncNumbers = Client.DncListsApi.GetUniversalDncNumber("16502572135", "16502572136"); - -=== Get dnc list -''' -Example how to get DNC list by id. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - DncList dncList = Client.DncListsApi.Get(1975140003); - -=== Delete dnc list -''' -Example how to delete DNC list. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.DncListsApi.Delete(1975140003); - -=== Get dnc list items -''' -Example how to get fifth 2 DNC items from list. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - GetByIdRequest getItemsRequest = new GetByIdRequest - { - Id = 1975140003, - Limit = 2, - Offset = 5 - }; - Page dncListItems = Client.DncListsApi.GetListItems(getItemsRequest); - -=== Add dnc list item -''' -Example how to add 3 DNC items to list. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - DoNotContact dnc1 = new DoNotContact { Number = "12135543211", Text = true, Call = false }; - DoNotContact dnc2 = new DoNotContact { Number = "12135543212", Text = true, Call = false }; - DoNotContact dnc3 = new DoNotContact { Number = "12135543213", Text = true, Call = false }; - AddDncListItemsRequest addItemsRequest = new AddDncListItemsRequest - { - ContactListId = 1975140003, - Contacts = new List { dnc1, dnc2, dnc3 } - }; - Client.DncListsApi.AddListItems(addItemsRequest); - -=== Remove dnc list item -''' -Example how to delete DNC list item (you should specify list id and phone number to delete). -[source,csharp] - //number param is required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.DncListsApi.RemoveListItem(1975140003, "16505044730"); - -=== Remove dnc list items -''' -Example how to delete DNC list items (you should specify list id and phone numbers to delete). -[source,csharp] - //numbers param is required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.DncListsApi.RemoveListItems(1975140003, new List { "16505044730", "16505044731" }); diff --git a/src/CallfireApiClient.IntegrationTests/Api/Account/MeApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Account/MeApiIntegrationTest.cs index 2d477bd..2d08b37 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Account/MeApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Account/MeApiIntegrationTest.cs @@ -24,6 +24,32 @@ public void GetBillingPlanUsage() Console.WriteLine("plan: " + plan.ToString()); } + [Test] + public void GetCreditsUsage() + { + var request = new DateIntervalRequest + { + IntervalBegin = DateTime.UtcNow.AddMonths(-2), + IntervalEnd = DateTime.UtcNow + }; + var creditsUsage = Client.MeApi.GetCreditUsage(request); + Assert.NotNull(creditsUsage.IntervalBegin); + Assert.NotNull(creditsUsage.IntervalEnd); + Assert.NotNull(creditsUsage.TextsSent); + Assert.NotNull(creditsUsage.CallsDurationMinutes); + Assert.NotNull(creditsUsage.CreditsUsed); + + creditsUsage = Client.MeApi.GetCreditUsage(); + Assert.NotNull(creditsUsage); + + request = new DateIntervalRequest + { + IntervalEnd = DateTime.UtcNow.AddMonths(-2) + }; + creditsUsage = Client.MeApi.GetCreditUsage(request); + Assert.NotNull(creditsUsage); + } + [Test] public void GetCallerIds() { diff --git a/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CampaignSoundsApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CampaignSoundsApiIntegrationTest.cs index 9767cdd..5e87ff0 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CampaignSoundsApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CampaignSoundsApiIntegrationTest.cs @@ -25,6 +25,22 @@ public void TestFind() } } + [Test] + public void TestUploadSoundAndDeleteIt() + { + String soundName = "mp3_test_" + DateTime.Now.ToString(); + string mp3FilePath = "Resources/File-examples/train1.mp3"; + CampaignSound campaignSound = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath, soundName); + Assert.NotNull(campaignSound.Id); + + Client.CampaignSoundsApi.Delete((long) campaignSound.Id); + + FindSoundsRequest request = new FindSoundsRequest { Filter = soundName }; + Page campaignSounds = Client.CampaignSoundsApi.Find(request); + Assert.True(campaignSounds.Items.Count == 0); + + } + [Test, Ignore("performs real call to specified number")] public void TestCallInToRecord() { diff --git a/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactListsApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactListsApiIntegrationTest.cs index 8e4fd67..ae793fc 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactListsApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactListsApiIntegrationTest.cs @@ -116,7 +116,7 @@ public void TestContactListItemsCRUD() Client.ContactListsApi.RemoveListItems(id.Id, new List { (long)items[0].Id, (long)items[1].Id }); contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); - Assert.IsNull(contactListItems.Items); + Assert.True(contactListItems.Items.Count == 0); Assert.AreEqual(0, contactListItems.TotalCount); Client.ContactListsApi.Delete(id.Id); diff --git a/src/CallfireApiClient.IntegrationTests/Api/Contacts/DncListsApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Contacts/DncListsApiIntegrationTest.cs deleted file mode 100644 index 46c6597..0000000 --- a/src/CallfireApiClient.IntegrationTests/Api/Contacts/DncListsApiIntegrationTest.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using NUnit.Framework; -using CallfireApiClient.Api.Contacts.Model; -using CallfireApiClient.Api.Contacts.Model.Request; -using CallfireApiClient.Api.Common.Model; -using System.Collections.Generic; -using CallfireApiClient.Api.Common.Model.Request; - -namespace CallfireApiClient.IntegrationTests.Api.Contacts -{ - [TestFixture] - public class DncListsApiIntegrationTest : AbstractIntegrationTest - { - - [Test] - public void TestDncContactListWithItemsCRUD() - { - //test add and get dnc list - DncList dncList = new DncList { Name = "dncList1" }; - ResourceId dncListId = Client.DncListsApi.Create(dncList); - DncList created = Client.DncListsApi.Get(dncListId.Id); - Assert.AreEqual("dncList1", created.Name); - Assert.Greater(created.Created, DateTime.Now.AddMinutes(-3)); - - //test find dnc list - FindDncListsRequest findRequest = new FindDncListsRequest { Name = "dncList1" }; - Page doNotCallLists = Client.DncListsApi.Find(findRequest); - Assert.Greater(doNotCallLists.TotalCount, 0); - Console.WriteLine("Page of dnc list:" + doNotCallLists); - - //test add dnc list items - DoNotContact dnc1 = new DoNotContact { Number = "12135543211", Text = true, Call = false }; - DoNotContact dnc2 = new DoNotContact { Number = "12135543212", Text = true, Call = false }; - DoNotContact dnc3 = new DoNotContact { Number = "12135543213", Text = true, Call = false }; - - AddDncListItemsRequest addItemsRequest = new AddDncListItemsRequest - { - ContactListId = dncListId.Id, - Contacts = new List { dnc1, dnc2, dnc3 } - }; - Client.DncListsApi.AddListItems(addItemsRequest); - - //test get dnc list items - GetByIdRequest getItemsRequest = new GetByIdRequest { Id = dncListId.Id }; - Page dncListItems = Client.DncListsApi.GetListItems(getItemsRequest); - IList items = dncListItems.Items; - Assert.AreEqual(3, items.Count); - - //test remove dnc list items - Client.DncListsApi.RemoveListItem(dncListId.Id, "12135543211"); - dncListItems = Client.DncListsApi.GetListItems(getItemsRequest); - items = dncListItems.Items; - Assert.AreEqual(2, items.Count); - - Client.DncListsApi.RemoveListItems(dncListId.Id, new List { "12135543212", "12135543213" }); - - dncListItems = Client.DncListsApi.GetListItems(getItemsRequest); - Assert.AreEqual(null, dncListItems.Items); - Assert.AreEqual(0, dncListItems.TotalCount); - - // test delete dnc list - Client.DncListsApi.Delete(dncListId.Id); - - // test get UniversalDncNumber - IList universalDncNumber = Client.DncListsApi.GetUniversalDncNumber("12135543212"); - Console.WriteLine("universal:" + universalDncNumber); - } - } -} - diff --git a/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj b/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj index 0e20c46..7009c81 100644 --- a/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj +++ b/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj @@ -53,7 +53,6 @@ - diff --git a/src/CallfireApiClient.Tests/Api/Account/MeApiTest.cs b/src/CallfireApiClient.Tests/Api/Account/MeApiTest.cs index f2021a7..ae5c1dd 100644 --- a/src/CallfireApiClient.Tests/Api/Account/MeApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Account/MeApiTest.cs @@ -32,6 +32,32 @@ public void GetBillingPlanUsage() Assert.That(Serializer.Serialize(billingPlanUsage), Is.EqualTo(expectedJson)); } + [Test] + public void GetCreditsUsage() + { + string expectedJson = GetJsonPayload("/account/meApi/response/getCreditsUsage.json"); + var restRequest = MockRestResponse(expectedJson); + + var request = new DateIntervalRequest + { + IntervalBegin = DateTime.UtcNow.AddMonths(-2), + IntervalEnd = DateTime.UtcNow + }; + + + CreditsUsage creditsUsage = Client.MeApi.GetCreditUsage(request); + Assert.That(Serializer.Serialize(creditsUsage), Is.EqualTo(expectedJson)); + + DateTime intBeg = (DateTime) request.IntervalBegin; + DateTime intEnd = (DateTime) request.IntervalEnd; + long ib = (long)(intBeg.ToUniversalTime() - ClientConstants.EPOCH).TotalMilliseconds; + long ie = (long)(intEnd.ToUniversalTime() - ClientConstants.EPOCH).TotalMilliseconds; + + Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("intervalBegin") && p.Value.Equals(ib.ToString()))); + Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("intervalEnd") && p.Value.Equals(ie.ToString()))); + } + + [Test] public void GetCallerIds() { diff --git a/src/CallfireApiClient.Tests/Api/Campaigns/CampaignSoundsApiTest.cs b/src/CallfireApiClient.Tests/Api/Campaigns/CampaignSoundsApiTest.cs index 6754dd4..4176f6e 100644 --- a/src/CallfireApiClient.Tests/Api/Campaigns/CampaignSoundsApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Campaigns/CampaignSoundsApiTest.cs @@ -33,6 +33,17 @@ public void TestFind() Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("filter") && p.Value.Equals("1234"))); } + [Test] + public void TestDelete() + { + var restRequest = MockRestResponse(); + + Client.CampaignSoundsApi.Delete(11L); + + Assert.AreEqual(Method.DELETE, restRequest.Value.Method); + Assert.That(restRequest.Value.Resource, Is.StringEnding("/11")); + } + [Test] public void TestGetWithFieldsParam() { diff --git a/src/CallfireApiClient.Tests/Api/Contacts/DncApiTest.cs b/src/CallfireApiClient.Tests/Api/Contacts/DncApiTest.cs index 1c886f3..4acf33e 100644 --- a/src/CallfireApiClient.Tests/Api/Contacts/DncApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Contacts/DncApiTest.cs @@ -16,7 +16,7 @@ public class DncApiTest : AbstractApiTest [Test] public void Find() { - string expectedJson = GetJsonPayload("/contacts/dncApi/response/findDncList.json"); + string expectedJson = GetJsonPayload("/contacts/dncApi/response/findDncs.json"); var restRequest = MockRestResponse(expectedJson); FindDncContactsRequest request = new FindDncContactsRequest diff --git a/src/CallfireApiClient.Tests/Api/Contacts/DncListsApiTest.cs b/src/CallfireApiClient.Tests/Api/Contacts/DncListsApiTest.cs deleted file mode 100644 index 9ba96f1..0000000 --- a/src/CallfireApiClient.Tests/Api/Contacts/DncListsApiTest.cs +++ /dev/null @@ -1,215 +0,0 @@ -using NUnit.Framework; -using System.Collections.Generic; -using CallfireApiClient.Api.Common.Model; -using CallfireApiClient.Api.Common.Model.Request; -using CallfireApiClient.Api.Contacts.Model; -using CallfireApiClient.Api.Contacts.Model.Request; -using RestSharp; -using System; -using System.Linq; - -namespace CallfireApiClient.Tests.Api.Contacts -{ - [TestFixture] - public class DncListsApiTest : AbstractApiTest - { - private const string EMPTY_TO_NUMBER_MSG = "toNumber cannot be blank"; - private const string EMPTY_NUMBER_MSG = "number cannot be blank"; - private const string EMPTY_REQ_CONTACT_LIST_ID_MSG = "request.contactListId cannot be null"; - - [Test] - public void Find() - { - string expectedJson = GetJsonPayload("/contacts/dncApi/response/findDncLists.json"); - var restRequest = MockRestResponse(expectedJson); - - FindDncListsRequest request = new FindDncListsRequest - { - Limit = 1, - Offset = 5, - Fields = FIELDS, - CampaignId = TEST_LONG, - Name = TEST_STRING - }; - - Page dncList = Client.DncListsApi.Find(request); - - Assert.NotNull(dncList); - Assert.That(Serializer.Serialize(dncList), Is.EqualTo(expectedJson)); - Assert.AreEqual(Method.GET, restRequest.Value.Method); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("limit") && p.Value.Equals("1"))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("offset") && p.Value.Equals("5"))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("campaignId") && p.Value.Equals(TEST_LONG.ToString()))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("name") && p.Value.Equals(TEST_STRING))); - } - - [Test] - public void Create() - { - string requestJson = GetJsonPayload("/contacts/dncApi/request/createDncList.json"); - string responseJson = GetJsonPayload("/contacts/dncApi/response/createDncList.json"); - var restRequest = MockRestResponse(responseJson); - - DncList dncList = new DncList - { - Id = TEST_LONG, - CampaignId = TEST_LONG, - Size = unchecked((int)TEST_LONG), - Name = TEST_STRING - }; - - ResourceId res = Client.DncListsApi.Create(dncList); - - Assert.That(Serializer.Serialize(res), 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)); - } - - [Test] - public void GetUniversalDncNumbersByNullToNumber() - { - var ex = Assert.Throws(() => Client.DncListsApi.GetUniversalDncNumber(null)); - Assert.That(ex.Message, Is.EqualTo(EMPTY_TO_NUMBER_MSG)); - var ex1 = Assert.Throws(() => Client.DncListsApi.GetUniversalDncNumber("")); - Assert.That(ex1.Message, Is.EqualTo(EMPTY_TO_NUMBER_MSG)); - } - - [Test] - public void GetUniversalDncNumbers() - { - string expectedJson = GetJsonPayload("/contacts/dncApi/response/getUniversalDncNumbers.json"); - var restRequest = MockRestResponse(expectedJson); - - IList universalDncNumbers = Client.DncListsApi.GetUniversalDncNumber(TEST_LONG.ToString(), TEST_LONG.ToString(), FIELDS); - - Assert.NotNull(universalDncNumbers); - Assert.That(Serializer.Serialize(new ListHolder(universalDncNumbers)), Is.EqualTo(expectedJson)); - Assert.AreEqual(Method.GET, restRequest.Value.Method); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("fromNumber") && p.Value.Equals(TEST_LONG.ToString()))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS))); - } - - [Test] - public void GetDnc() - { - string expectedJson = GetJsonPayload("/contacts/dncApi/response/getDncList.json"); - var restRequest = MockRestResponse(expectedJson); - - DncList dncList = Client.DncListsApi.Get(TEST_LONG, FIELDS); - - Assert.NotNull(dncList); - Assert.That(Serializer.Serialize(dncList), Is.EqualTo(expectedJson)); - Assert.AreEqual(Method.GET, restRequest.Value.Method); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS))); - } - - - [Test] - public void DeleteDncById() - { - var restRequest = MockRestResponse(); - - Client.DncListsApi.Delete(TEST_LONG); - - Assert.AreEqual(Method.DELETE, restRequest.Value.Method); - Assert.That(restRequest.Value.Resource, Is.StringContaining("/" + TEST_LONG)); - } - - [Test] - public void GetDncItemsByNullId() - { - var ex = Assert.Throws(() => Client.DncListsApi.GetListItems(new GetByIdRequest())); - Assert.That(ex.Message, Is.EqualTo(EMPTY_REQUEST_ID_MSG)); - } - - [Test] - public void GetDncItems() - { - string expectedJson = GetJsonPayload("/contacts/dncApi/response/findDncList.json"); - var restRequest = MockRestResponse(expectedJson); - - GetByIdRequest request = new GetByIdRequest - { - Limit = 1, - Offset = 5, - Fields = FIELDS, - Id = TEST_LONG - }; - - Page dncs = Client.DncListsApi.GetListItems(request); - - Assert.NotNull(dncs); - Assert.That(Serializer.Serialize(dncs), Is.EqualTo(expectedJson)); - Assert.AreEqual(Method.GET, restRequest.Value.Method); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS))); - } - - [Test] - public void AddDncItemsByNullId() - { - var ex = Assert.Throws(() => Client.DncListsApi.AddListItems(new AddDncListItemsRequest())); - Assert.That(ex.Message, Is.EqualTo(EMPTY_REQ_CONTACT_LIST_ID_MSG)); - } - - [Test] - public void AddDncItems() - { - string requestJson = GetJsonPayload("/contacts/dncApi/request/addDncItems.json"); - var restRequest = MockRestResponse(); - - var dncs = new List(); - var dnc = new DoNotContact { ListId = TEST_LONG, Number = TEST_LONG.ToString() }; - dncs.Add(dnc); - var request = new AddDncListItemsRequest(); - request.ContactListId = TEST_LONG; - request.Contacts = dncs; - - Client.DncListsApi.AddListItems(request); - - Assert.AreEqual(Method.POST, restRequest.Value.Method); - Assert.That(restRequest.Value.Resource, Is.StringContaining("/" + TEST_LONG)); - var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); - Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson)); - } - - [Test] - public void RemoveListItemByNullNumber() - { - var ex = Assert.Throws(() => Client.DncListsApi.RemoveListItem(TEST_LONG, null)); - Assert.That(ex.Message, Is.EqualTo(EMPTY_NUMBER_MSG)); - var ex1 = Assert.Throws(() => Client.DncListsApi.RemoveListItem(TEST_LONG, "")); - Assert.That(ex1.Message, Is.EqualTo(EMPTY_NUMBER_MSG)); - } - - - [Test] - public void RemoveListItem() - { - var restRequest = MockRestResponse(); - - Client.DncListsApi.RemoveListItem(TEST_LONG, "123456"); - - Assert.AreEqual(Method.DELETE, restRequest.Value.Method); - Assert.That(restRequest.Value.Resource, Is.StringContaining("/" + TEST_LONG)); - Assert.That(restRequest.Value.Resource, Is.StringContaining("/123456")); - } - - - [Test] - public void RemoveListItems() - { - var restRequest = MockRestResponse(); - - Client.DncListsApi.RemoveListItems(TEST_LONG, new List { "123456", "123457" }); - - Assert.AreEqual(Method.DELETE, restRequest.Value.Method); - Assert.That(restRequest.Value.Resource, Is.StringContaining("/" + TEST_LONG)); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("number") && p.Value.Equals("123456"))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("number") && p.Value.Equals("123457"))); - } - - } -} - diff --git a/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj b/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj index 7572c16..eeea146 100644 --- a/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj +++ b/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj @@ -57,7 +57,6 @@ - @@ -78,6 +77,7 @@ + @@ -104,14 +104,8 @@ - - - - - - - + diff --git a/src/CallfireApiClient.Tests/JsonMocks/account/meApi/response/getCreditsUsage.json b/src/CallfireApiClient.Tests/JsonMocks/account/meApi/response/getCreditsUsage.json new file mode 100644 index 0000000..8ede628 --- /dev/null +++ b/src/CallfireApiClient.Tests/JsonMocks/account/meApi/response/getCreditsUsage.json @@ -0,0 +1,7 @@ +{ + "intervalBegin": 1000000000000, + "intervalEnd": 1000000000000, + "callsDurationMinutes": 100, + "textsSent": 2015, + "creditsUsed": 2015.000 +} diff --git a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/addDncItems.json b/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/addDncItems.json deleted file mode 100644 index 5c198d1..0000000 --- a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/addDncItems.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "number": "100500", - "listId": 100500 - } -] \ No newline at end of file diff --git a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/createDncList.json b/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/createDncList.json deleted file mode 100644 index 9f5043e..0000000 --- a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/request/createDncList.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": 100500, - "size": 100500, - "campaignId": 100500, - "name": "test" -} - - diff --git a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/createDncList.json b/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/createDncList.json deleted file mode 100644 index 8e5665e..0000000 --- a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/createDncList.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": 100500 -} - - diff --git a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncLists.json b/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncLists.json deleted file mode 100644 index e3861cf..0000000 --- a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncLists.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "items": [ - { - "id": 100500, - "size": 100500, - "campaignId": 100500, - "name": "test", - "created": 123456 - } - ], - "totalCount": 1 -} - - diff --git a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncList.json b/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncs.json similarity index 100% rename from src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncList.json rename to src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/findDncs.json diff --git a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getDncList.json b/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getDncList.json deleted file mode 100644 index 9f5043e..0000000 --- a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getDncList.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": 100500, - "size": 100500, - "campaignId": 100500, - "name": "test" -} - - diff --git a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getUniversalDncNumbers.json b/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getUniversalDncNumbers.json deleted file mode 100644 index a36728b..0000000 --- a/src/CallfireApiClient.Tests/JsonMocks/contacts/dncApi/response/getUniversalDncNumbers.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "items": [ - { - "toNumber": "100500", - "fromNumber": "100500", - "inboundCall": false, - "inboundText": false, - "outboundCall": false, - "outboundText": false - } - ] -} \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Account/MeApi.cs b/src/CallfireApiClient/Api/Account/MeApi.cs index 76ef09c..10715e7 100644 --- a/src/CallfireApiClient/Api/Account/MeApi.cs +++ b/src/CallfireApiClient/Api/Account/MeApi.cs @@ -12,6 +12,7 @@ public class MeApi { private const string ME_ACCOUNT_PATH = "/me/account"; private const string ME_BILLING_PATH = "/me/billing/plan-usage"; + private const string ME_BILLING_CREDIT_PATH = "/me/billing/credit-usage"; private const string ME_API_CREDS_PATH = "/me/api/credentials"; private const string ME_API_CREDS_ITEM_PATH = "/me/api/credentials/{}"; private const string ME_CALLERIDS_PATH = "/me/callerids"; @@ -57,6 +58,26 @@ public BillingPlanUsage GetBillingPlanUsage() return Client.Get(ME_BILLING_PATH); } + /// + /// Find credit usage for the user. Returns credits usage for time period specified or if unspecified then total for all time. + /// + /// request for date range filtering + /// CreditsUsage object + /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. + /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. + /// in case HTTP response code is 403 - Forbidden, insufficient permissions. + /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. + /// in case HTTP response code is 500 - Internal Server Error. + /// in case HTTP response code is something different from codes listed above. + /// in case error has occurred in client. + public CreditsUsage GetCreditUsage(DateIntervalRequest request = null) + { + if (request != null) + return Client.Get(ME_BILLING_CREDIT_PATH, request); + else + return Client.Get(ME_BILLING_CREDIT_PATH); + } + /// /// Returns a list of verified caller ids. If the number is not shown in the list, /// then it is not verified, and will have to send for a verification code. diff --git a/src/CallfireApiClient/Api/Account/Model/CreditsUsage.cs b/src/CallfireApiClient/Api/Account/Model/CreditsUsage.cs new file mode 100644 index 0000000..eabb537 --- /dev/null +++ b/src/CallfireApiClient/Api/Account/Model/CreditsUsage.cs @@ -0,0 +1,47 @@ +using System; +using CallfireApiClient.Api.Common.Model; + +namespace CallfireApiClient.Api.Account.Model +{ + /// + /// Object represents Credits usage statistics + /// + public class CreditsUsage : CallfireModel + { + /// + /// Gets beginning of usage period + /// + /// beginning of usage period + public DateTime IntervalBegin { get; private set; } + + /// + /// Gets end of usage period + /// + /// end of usage period + public DateTime IntervalEnd { get; private set; } + + /// + /// Gets sum of calls duration rounded to nearest whole minute + /// + /// sum of calls duration rounded to nearest whole minute + public int CallsDurationMinutes { get; private set; } + + /// + /// Gets number of texts sent + /// + /// number of texts sent + public int TextsSent { get; private set; } + + /// + /// Gets total credits used by textsSent and callsDurationMinutes + /// + /// total credits used by textsSent and callsDurationMinutes + public Decimal CreditsUsed { get; private set; } + + public override string ToString() + { + return string.Format("[CreditsUsage: IntervalBegin={0}, IntervalEnd={1}, CallsDurationMinutes={2}, TextsSent={3}, CreditsUsed={4}]", + IntervalBegin, IntervalEnd, CallsDurationMinutes, TextsSent, CreditsUsed); + } + } +} \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Account/Model/Request/DateIntervalRequest.cs b/src/CallfireApiClient/Api/Account/Model/Request/DateIntervalRequest.cs new file mode 100644 index 0000000..46c307b --- /dev/null +++ b/src/CallfireApiClient/Api/Account/Model/Request/DateIntervalRequest.cs @@ -0,0 +1,28 @@ +using System; +using CallfireApiClient.Api.Common.Model; + +namespace CallfireApiClient.Api.Account.Model.Request +{ + /// + /// Request object for GET /me/billing/plan-usage + /// + public class DateIntervalRequest : CallfireModel + { + /// + /// Sets beginning of usage period + /// + /// beginning of usage period + public DateTime? IntervalBegin { get; set; } + + /// + /// Sets end of usage period + /// + /// end of usage period + public DateTime? IntervalEnd { get; set; } + + public override string ToString() + { + return string.Format("[DateIntervalRequest: IntervalBegin={0}, IntervalEnd={1}]", IntervalBegin, IntervalEnd); + } + } +} \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Campaigns/CampaignSoundsApi.cs b/src/CallfireApiClient/Api/Campaigns/CampaignSoundsApi.cs index 3679451..95b6baf 100644 --- a/src/CallfireApiClient/Api/Campaigns/CampaignSoundsApi.cs +++ b/src/CallfireApiClient/Api/Campaigns/CampaignSoundsApi.cs @@ -56,12 +56,28 @@ public Page Find(FindSoundsRequest request) /// in case error has occurred in client. public CampaignSound Get(long id, string fields = null) { - Validate.NotBlank(id.ToString(), "id cannot be blank"); string path = SOUNDS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()); var queryParams = ClientUtils.BuildQueryParams("fields", fields); return Client.Get(path, queryParams); } + /// + /// Delete a single CampaignSound instance for a given campaign sound id. + /// + /// id of campaign sound + /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. + /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. + /// in case HTTP response code is 403 - Forbidden, insufficient permissions. + /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. + /// in case HTTP response code is 500 - Internal Server Error. + /// in case HTTP response code is something different from codes listed above. + /// in case error has occurred in client. + public void Delete(long id) + { + string path = SOUNDS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()); + Client.Delete(path); + } + /// /// Download the MP3 version of the hosted file. /// @@ -76,7 +92,6 @@ public CampaignSound Get(long id, string fields = null) /// in case error has occurred in client. public Stream GetMp3(long id) { - Validate.NotBlank(id.ToString(), "id cannot be blank"); string path = SOUNDS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()) + ".mp3"; return Client.GetFileData(path); } @@ -95,9 +110,7 @@ public Stream GetMp3(long id) /// in case error has occurred in client. public Stream GetWav(long id) { - Validate.NotBlank(id.ToString(), "id cannot be blank"); string path = SOUNDS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()) + ".wav"; - return Client.GetFileData(path); } diff --git a/src/CallfireApiClient/Api/Common/Model/ListHolder.cs b/src/CallfireApiClient/Api/Common/Model/ListHolder.cs index c481af2..e540dd0 100644 --- a/src/CallfireApiClient/Api/Common/Model/ListHolder.cs +++ b/src/CallfireApiClient/Api/Common/Model/ListHolder.cs @@ -11,6 +11,7 @@ public class ListHolder : CallfireModel public ListHolder() { + Items = new List(); } public ListHolder(IList items) diff --git a/src/CallfireApiClient/Api/Contacts/DncListsApi.cs b/src/CallfireApiClient/Api/Contacts/DncListsApi.cs deleted file mode 100644 index cff33a4..0000000 --- a/src/CallfireApiClient/Api/Contacts/DncListsApi.cs +++ /dev/null @@ -1,197 +0,0 @@ -using CallfireApiClient.Api.Contacts.Model; -using CallfireApiClient.Api.Contacts.Model.Request; -using CallfireApiClient.Api.Common.Model; -using CallfireApiClient.Api.Common.Model.Request; -using System.Collections.Generic; - -namespace CallfireApiClient.Api.Contacts -{ - public class DncListsApi - { - private const string DNC_LISTS_PATH = "/contacts/dncs/lists"; - private const string DNC_LISTS_UNIVERSAL_PATH = "/contacts/dncs/lists/universal/{}"; - private const string DNC_LISTS_LIST_PATH = "/contacts/dncs/lists/{}"; - private const string DNC_LISTS_LIST_ITEMS_PATH = "/contacts/dncs/lists/{}/items"; - private const string DNC_LISTS_LIST_ITEMS_NUMBER_PATH = "/contacts/dncs/lists/{}/items/{}"; - - private readonly RestApiClient Client; - - internal DncListsApi(RestApiClient client) - { - Client = client; - } - - /// - /// Find do not contact (DNC) lists - /// - /// request with properties to find - /// paged list with dnc lists - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public Page Find(FindDncListsRequest request) - { - return Client.Get>(DNC_LISTS_PATH, request); - } - - /// - /// Create do not contact (DNC) list. - /// - /// list to create - /// newly created dnc list id - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public ResourceId Create(DncList dncList) - { - return Client.Post(DNC_LISTS_PATH, dncList); - } - - /// - /// Search Universal Do Not Contact by number - /// - /// Phone Number in Do Not Contact list - /// Searches for entries where fromNumber is communicating with toNumber, or vice versa. - /// Limit fields returned. Example fields=limit,offset,items(id,name) - /// list of universal dncs - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public IList GetUniversalDncNumber(string toNumber, string fromNumber = null, string fields = null) - { - Validate.NotBlank(toNumber, "toNumber cannot be blank"); - string path = DNC_LISTS_UNIVERSAL_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, toNumber); - var queryParams = new List>(2); - ClientUtils.AddQueryParamIfSet("fields", fields, queryParams); - ClientUtils.AddQueryParamIfSet("fromNumber", fromNumber, queryParams); - return Client.Get>(path, queryParams).Items; - } - - /// - /// Find do not contact (DNC) lists - /// - /// id of DNC list - /// limit fields returned. Example fields=name,status - /// dnc list object - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public DncList Get(long id, string fields = null) - { - Validate.NotBlank(id.ToString(), "id cannot be blank"); - string path = DNC_LISTS_LIST_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()); - var queryParams = ClientUtils.BuildQueryParams("fields", fields); - return Client.Get(path, queryParams); - } - - /// - /// Delete DNC list - /// - /// DNC list id - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public void Delete(long id) - { - Client.Delete(DNC_LISTS_LIST_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString())); - } - - /// - /// Get DNC list items - /// - /// Property request.id required - /// request object with properties to filter - /// paged list with dnc items - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public Page GetListItems(GetByIdRequest request) - { - Validate.NotBlank(request.Id.ToString(), "request.id cannot be null"); - string path = DNC_LISTS_LIST_ITEMS_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, request.Id.ToString()); - return Client.Get>(path, request); - } - - /// - /// Add DNC list items to list - /// - /// request object with DNC items to add - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public void AddListItems(AddDncListItemsRequest request) - { - Validate.NotBlank(request.ContactListId.ToString(), "request.contactListId cannot be null"); - string path = DNC_LISTS_LIST_ITEMS_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, request.ContactListId.ToString()); - Client.Post(path, request.Contacts); - } - - /// - /// Delete single DNC list contact by number - /// - /// id of DNC list - /// number to remove - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public void RemoveListItem(long id, string number) - { - Validate.NotBlank(number, "number cannot be blank"); - string path = DNC_LISTS_LIST_ITEMS_NUMBER_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()).ReplaceFirst(ClientConstants.PLACEHOLDER, number); - Client.Delete(path); - } - - /// - /// Delete DNC list items - /// - /// id of DNC list - /// numbers to remove - /// in case HTTP response code is 400 - Bad request, the request was formatted improperly. - /// in case HTTP response code is 401 - Unauthorized, API Key missing or invalid. - /// in case HTTP response code is 403 - Forbidden, insufficient permissions. - /// in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist. - /// in case HTTP response code is 500 - Internal Server Error. - /// in case HTTP response code is something different from codes listed above. - /// in case error has occurred in client. - public void RemoveListItems(long id, IList numbers) - { - Validate.NotBlank(id.ToString(), "id cannot be blank"); - string path = DNC_LISTS_LIST_ITEMS_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()); - var queryParams = new List>(1); - ClientUtils.AddQueryParamIfSet("number", numbers, queryParams); - Client.Delete(path, queryParams); - } - } -} \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Contacts/Model/DncList.cs b/src/CallfireApiClient/Api/Contacts/Model/DncList.cs deleted file mode 100644 index 7baf3c9..0000000 --- a/src/CallfireApiClient/Api/Contacts/Model/DncList.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using CallfireApiClient.Api.Common.Model; - -namespace CallfireApiClient.Api.Contacts.Model -{ - public class DncList : CallfireModel - { - public long? Id { get; set; } - public int? Size { get; set; } - public long? CampaignId { get; set; } - public string Name { get; set; } - public DateTime? Created { get; set; } - - public override string ToString() - { - return string.Format("[DncList: id={0}, size={1}, campaignId={2}, name={3}, created={4}", - Id, Size, CampaignId, Name, Created); - } - } -} \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Contacts/Model/Request/AddDncListItemsRequest.cs b/src/CallfireApiClient/Api/Contacts/Model/Request/AddDncListItemsRequest.cs deleted file mode 100644 index 48a9c91..0000000 --- a/src/CallfireApiClient/Api/Contacts/Model/Request/AddDncListItemsRequest.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Newtonsoft.Json; - -namespace CallfireApiClient.Api.Contacts.Model.Request -{ - public class AddDncListItemsRequest : AddContactsRequest - { - [JsonIgnore] - public long? ContactListId { get; set; } - - public override string ToString() - { - return string.Format("[AddDncListItemsRequest: {0}, ContactListId={1}]", base.ToString(), ContactListId); - } - } -} - diff --git a/src/CallfireApiClient/Api/Contacts/Model/Request/FindDncListsRequest.cs b/src/CallfireApiClient/Api/Contacts/Model/Request/FindDncListsRequest.cs deleted file mode 100644 index 8bd0541..0000000 --- a/src/CallfireApiClient/Api/Contacts/Model/Request/FindDncListsRequest.cs +++ /dev/null @@ -1,16 +0,0 @@ -using CallfireApiClient.Api.Common.Model.Request; - -namespace CallfireApiClient.Api.Contacts.Model.Request -{ - public class FindDncListsRequest : FindRequest - { - public long? CampaignId { get; set; } - public string Name { get; set; } - - public override string ToString() - { - return string.Format("[FindNumberLeaseConfigsRequest: {0} CampaignId={1}, Name={2}]", base.ToString(), CampaignId, Name); - } - } -} - diff --git a/src/CallfireApiClient/CallfireApiClient.csproj b/src/CallfireApiClient/CallfireApiClient.csproj index 7f3cf98..18c49de 100644 --- a/src/CallfireApiClient/CallfireApiClient.csproj +++ b/src/CallfireApiClient/CallfireApiClient.csproj @@ -44,6 +44,8 @@ + + @@ -120,23 +122,19 @@ - - - - diff --git a/src/CallfireApiClient/CallfireClient.cs b/src/CallfireApiClient/CallfireClient.cs index 384776e..6d32f4f 100644 --- a/src/CallfireApiClient/CallfireClient.cs +++ b/src/CallfireApiClient/CallfireClient.cs @@ -29,7 +29,6 @@ public class CallfireClient readonly Lazy _KeywordsApi; readonly Lazy _KeywordLeasesApi; readonly Lazy _DncApi; - readonly Lazy _DncListsApi; readonly Lazy _CallsApi; readonly Lazy _TextsApi; readonly Lazy _TextAutoRepliesApi; @@ -65,8 +64,6 @@ public class CallfireClient public DncApi DncApi { get { return _DncApi.Value; } } - public DncListsApi DncListsApi { get { return _DncListsApi.Value; } } - public CallsApi CallsApi { get { return _CallsApi.Value; } } public TextsApi TextsApi { get { return _TextsApi.Value; } } @@ -96,7 +93,6 @@ public CallfireClient(string username, string password) _KeywordsApi = new Lazy(() => new KeywordsApi(RestApiClient)); _KeywordLeasesApi = new Lazy(() => new KeywordLeasesApi(RestApiClient)); _DncApi = new Lazy(() => new DncApi(RestApiClient)); - _DncListsApi = new Lazy(() => new DncListsApi(RestApiClient)); _CallsApi = new Lazy(() => new CallsApi(RestApiClient)); _TextsApi = new Lazy(() => new TextsApi(RestApiClient)); _TextAutoRepliesApi = new Lazy(() => new TextAutoRepliesApi(RestApiClient)); diff --git a/src/CallfireApiClient/Properties/AssemblyInfo.cs b/src/CallfireApiClient/Properties/AssemblyInfo.cs index 8b496d7..d85b3f6 100644 --- a/src/CallfireApiClient/Properties/AssemblyInfo.cs +++ b/src/CallfireApiClient/Properties/AssemblyInfo.cs @@ -13,7 +13,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("1.1.10.*")] +[assembly: AssemblyVersion("1.1.11.*")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/src/CallfireApiClient/RestApiClient.cs b/src/CallfireApiClient/RestApiClient.cs index 4c3b066..e98a224 100644 --- a/src/CallfireApiClient/RestApiClient.cs +++ b/src/CallfireApiClient/RestApiClient.cs @@ -140,7 +140,7 @@ public static KeyValueConfigurationCollection LoadAppSettings() /// in case HTTP response code is 500 - Internal Server Error. /// in case HTTP response code is something different from codes listed above. /// in case error has occurred in client. - public T Get(String path, FindRequest request = null) where T : new() + public T Get(String path, CallfireModel request = null) where T : new() { return Get(path, ClientUtils.BuildQueryParams(request)); } From 78041db389cc1906e991e267dbd909c40b96a696 Mon Sep 17 00:00:00 2001 From: vmalinovskiy Date: Mon, 21 Nov 2016 13:17:08 +0200 Subject: [PATCH 2/4] vmalinovskiy: added deleteCampaignSound, getCreditsUsage apis, removed Dnc Lists api --- Changelog.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index feef701..7ce3739 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,10 @@ Callfire API client Changelog ============================= +Version 1.1.11 - Nov 18 2016 +- added deleteCampaignSound api +- added getCreditsHistory api +- remove dnc lists api (not supported anymore) + Version 1.1.10 - Oct 26 2016 - added more parameters to call tracking config in Number Lease config object From fd94f39636c807c94453c900f3d4e51f740caf35 Mon Sep 17 00:00:00 2001 From: vmalinovskiy Date: Tue, 22 Nov 2016 15:20:36 +0200 Subject: [PATCH 3/4] vmalinovskiy: removed excess api samples (they are present on developers.callfire.com) --- README.adoc | 3 +- docs/api/ApiExamples.adoc | 22 --- docs/api/account/MeApi.adoc | 101 ------------- docs/api/account/OrdersApi.adoc | 36 ----- docs/api/callstexts/CallsApi.adoc | 121 --------------- docs/api/callstexts/MediaApi.adoc | 34 ----- docs/api/callstexts/TextsApi.adoc | 57 ------- docs/api/campaigns/BatchesApi.adoc | 22 --- docs/api/campaigns/CallBroadcastsApi.adoc | 154 ------------------- docs/api/campaigns/CampaignSoundsApi.adoc | 95 ------------ docs/api/campaigns/TextAutoRepliesApi.adoc | 47 ------ docs/api/campaigns/TextBroadcastsApi.adoc | 163 --------------------- docs/api/contacts/ContactListsApi.adoc | 75 ---------- docs/api/contacts/ContactsApi.adoc | 61 -------- docs/api/contacts/DncApi.adoc | 28 ---- docs/api/keywords/KeywordLeasesApi.adoc | 28 ---- docs/api/keywords/KeywordsApi.adoc | 23 --- docs/api/keywords/KeywordsMain.adoc | 3 - docs/api/numbers/NumberLeasesApi.adoc | 67 --------- docs/api/numbers/NumbersApi.adoc | 37 ----- docs/api/numbers/NumbersMain.adoc | 3 - docs/api/webhooks/SubscriptionsApi.adoc | 55 ------- docs/api/webhooks/WebhooksApi.adoc | 77 ---------- 23 files changed, 1 insertion(+), 1311 deletions(-) delete mode 100644 docs/api/ApiExamples.adoc delete mode 100644 docs/api/account/MeApi.adoc delete mode 100644 docs/api/account/OrdersApi.adoc delete mode 100644 docs/api/callstexts/CallsApi.adoc delete mode 100644 docs/api/callstexts/MediaApi.adoc delete mode 100644 docs/api/callstexts/TextsApi.adoc delete mode 100644 docs/api/campaigns/BatchesApi.adoc delete mode 100644 docs/api/campaigns/CallBroadcastsApi.adoc delete mode 100644 docs/api/campaigns/CampaignSoundsApi.adoc delete mode 100644 docs/api/campaigns/TextAutoRepliesApi.adoc delete mode 100644 docs/api/campaigns/TextBroadcastsApi.adoc delete mode 100644 docs/api/contacts/ContactListsApi.adoc delete mode 100644 docs/api/contacts/ContactsApi.adoc delete mode 100644 docs/api/contacts/DncApi.adoc delete mode 100644 docs/api/keywords/KeywordLeasesApi.adoc delete mode 100644 docs/api/keywords/KeywordsApi.adoc delete mode 100644 docs/api/keywords/KeywordsMain.adoc delete mode 100644 docs/api/numbers/NumberLeasesApi.adoc delete mode 100644 docs/api/numbers/NumbersApi.adoc delete mode 100644 docs/api/numbers/NumbersMain.adoc delete mode 100644 docs/api/webhooks/SubscriptionsApi.adoc delete mode 100644 docs/api/webhooks/WebhooksApi.adoc diff --git a/README.adoc b/README.adoc index e51724d..7afd60e 100644 --- a/README.adoc +++ b/README.adoc @@ -12,8 +12,7 @@ C# client for Callfire platform API version 2. See link:docs/GettingStarted.adoc .*Table of contents* * link:docs/GettingStarted.adoc[Getting Started] -* link:docs/api/ApiExamples.adoc[API code examples] -* link:https://developers.callfire.com/docs.html[REST endpoints documentation] +* link:https://developers.callfire.com/docs.html[REST endpoints documentation and api code samples] * Have a question ? ** link:https://developers.callfire.com/chat.html[Public chat room] ** link:http://stackoverflow.com/questions/tagged/callfire[Ask on stackoverflow] diff --git a/docs/api/ApiExamples.adoc b/docs/api/ApiExamples.adoc deleted file mode 100644 index cd626b9..0000000 --- a/docs/api/ApiExamples.adoc +++ /dev/null @@ -1,22 +0,0 @@ -= API Code Examples - -* Account -** link:account/MeApi.adoc[User account API] -** link:account/OrdersApi.adoc[Account orders] -* link:callstexts/CallsApi.adoc[Send individual calls] -* link:callstexts/TextsApi.adoc[Send individual texts] -* Campaigns -** link:campaigns/CampaignSoundsApi.adoc[Campaign Sounds] -** link:campaigns/TextAutoRepliesApi.adoc[Text auto replies] -** Broadcasts -*** link:campaigns/BatchesApi.adoc[Contact batches] -*** link:campaigns/CallBroadcastsApi.adoc[Call broadcasts] -*** link:campaigns/TextBroadcastsApi.adoc[Text broadcasts] -* Contacts & Dncs -** link:contacts/ContactsApi.adoc[User contacts] -** link:contacts/ContactListsApi.adoc[Contact lists] -** link:contacts/DncApi.adoc[Do Not Contact API] -* link:keywords/KeywordsMain.adoc[Keywords & keyword leases API] -* link:numbers/NumbersMain.adoc[Numbers & number leases API] -* link:webhooks/SubscriptionsApi.adoc[Subscriptions API] -* link:webhooks/WebhooksApi.adoc[Webhooks] diff --git a/docs/api/account/MeApi.adoc b/docs/api/account/MeApi.adoc deleted file mode 100644 index 3de11ce..0000000 --- a/docs/api/account/MeApi.adoc +++ /dev/null @@ -1,101 +0,0 @@ -= User account API - -== Account specific APIs - -=== Get account info -''' -Example how to get account information like name, surname, email, account permissions. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - UserAccount account = Client.MeApi.GetAccount(); - Console.WriteLine("Account: " + account); - -=== Get billing plan usage info -''' -Example how to find billing plan usage for the user. Returns billing plan usage for the current month. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - BillingPlanUsage plan = Client.MeApi.GetBillingPlanUsage(); - Console.WriteLine("Plan: " + plan.ToString()); - -=== Get credits usage info -''' -Example how find credit usage for the user. Returns credits usage for time period specified or if unspecified then total for all time. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new DateIntervalRequest - { - IntervalBegin = DateTime.UtcNow.AddMonths(-2), - IntervalEnd = DateTime.UtcNow - }; - CreditsUsage creditsUsage = Client.MeApi.GetCreditUsage(request); - -=== Get account caller IDs -''' -Example how to get a list of verified caller ids. If the number is not shown in the list, then it is not verified, - and will have to send for a verification code. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - IList callerIds = Client.MeApi.GetCallerIds(); - Console.WriteLine("CallerIds: " + String.Join(",", callerIds)); - -=== Send verification code to caller ID -''' -Example how to send a verification code to the phone number. The verification code is delivered - via a phone call. This code needs to be submitted to the verify caller id API endpoint. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - String phoneNumber = "12132224444"; - Client.MeApi.SendVerificationCode(phoneNumber); - -=== Verify caller ID -''' -You can verify your caller ID with the verification code received from the previous operation, a call to this - endpoint is required to finish verification. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new CallerIdVerificationRequest - { - CallerId = "12132212384", - VerificationCode = "123" - }; - bool? verified = Client.MeApi.VerifyCallerId(request); - Console.WriteLine("Verified: " + verified); - -== API credentials CRUD operations -*/me* endpoint has operations to *find, create, get and delete* API user credentials. To execute one of these - operations you should create *CallfireClient* with your regular account credentials not API one, because only - account holder can manipulate API users. - -=== Create API credentials -''' -Example how to create API user. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - ApiCredentials credentials = new ApiCredentials { Name = "test1" }; - ApiCredentials created = Client.MeApi.CreateApiCredentials(credentials); - Console.WriteLine(created); - -=== Find API credentials -''' -Example how to get first 2 API users. -[source] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new CommonFindRequest { Limit = 2 }; - Page apiCredentials = Client.MeApi.FindApiCredentials(request); - Console.WriteLine("Page of credentials:" + apiCredentials); - -=== Get API credentials -''' -Example how to get particular API user and limit returned fields to name and enabled flag. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - ApiCredentials credentials = Client.MeApi.GetApiCredentials(123456, "name,enabled"); - Console.WriteLine("Credentials:" + credentials); - -=== Delete API credentials -''' -Example how to delete particular API user by ID. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.MeApi.DeleteApiCredentials(123456); diff --git a/docs/api/account/OrdersApi.adoc b/docs/api/account/OrdersApi.adoc deleted file mode 100644 index 852436f..0000000 --- a/docs/api/account/OrdersApi.adoc +++ /dev/null @@ -1,36 +0,0 @@ -= Account orders API - - -=== Buy a keyword -''' -Example below shows how to buy a couple keywords. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new KeywordPurchaseRequest { Keywords = { "TEST1", "TEST2" } }; - ResourceId resourceId = Client.OrdersApi.OrderKeywords(request); - -OrdersApi.OrderKeywords(KeywordPurchaseRequest) will return an order ID. - -=== Buy a number -''' -Example below shows how to buy a specific number. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new NumberPurchaseRequest { Numbers = new List { "12132212289" } }; - ResourceId resourceId = Client.OrdersApi.OrderNumbers(request); - -Buy a couple local numbers: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new NumberPurchaseRequest { Zipcode = "90401", LocalCount = 2 }; - ResourceId resourceId = Client.OrdersApi.OrderNumbers(request); - -OrdersApi.OrderNumbers(NumberPurchaseRequest) will return an order ID. - -=== Get particular order -''' -Get specific order by ID. You can set optional 2nd argument to return only certain fields to reduce network traffic. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - long orderId = 123456; - NumberOrder order = Client.OrdersApi.GetOrder(orderId, "id,status"); diff --git a/docs/api/callstexts/CallsApi.adoc b/docs/api/callstexts/CallsApi.adoc deleted file mode 100644 index ed11ac2..0000000 --- a/docs/api/callstexts/CallsApi.adoc +++ /dev/null @@ -1,121 +0,0 @@ -= Calls API - - -=== Find calls -''' -Example how to find all calls sent or received by the user. Use "CampaignId=0" for the campaignId parameter to query for all - calls sent through the POST /calls API. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //No one parameter is required - var request = new FindCallsRequest - { - States = new List { StateType.FINISHED, StateType.READY }, - IntervalBegin = DateTime.UtcNow.AddMonths(-2), - IntervalEnd = DateTime.UtcNow, - Limit = 3 - }; - Page calls = Client.CallsApi.Find(request); - Console.WriteLine("Calls: " + calls); - -=== Send call -''' -Example how to use the /calls API to quickly send individual calls via default campaign. A verified Caller ID and - sufficient credits are required to make a call. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //Only "recipients" param required - var recipient1 = new CallRecipient { ContactId = 463633187003, LiveMessage = "testMessage", TransferDigit = "1", TransferMessage = "transferTestMessage", TransferNumber = "14246525473" }; - var recipient2 = new CallRecipient { ContactId = 463633187003, LiveMessage = "testMessage", TransferDigit = "1", TransferMessageSoundId = 1, TransferNumber = "14246525473" }; - var recipients = new List { recipient1, recipient2 }; - IList calls = Client.CallsApi.Send(recipients, null, "items(id,fromNumber,state)"); - Console.WriteLine("Calls: " + calls); - -In case you want to send call via existing campaign provide campaign id as second parameter for send() method, - see example below. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //Only "recipients" param required - var recipient1 = new CallRecipient { ContactId = 463633187003, LiveMessage = "testMessage" }; - var recipient2 = new CallRecipient { ContactId = 463633187003, LiveMessage = "testMessage" }; - var recipients = new List { recipient1, recipient2 }; - IList calls = Client.CallsApi.Send(recipients, 60000000003); - Console.WriteLine("Calls: " + calls); - -Also you can send call with some default parameters which will be used in case when recipient doesn't have that info specified, - see example below: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //Only "recipients" param required - var recipient1 = new CallRecipient { ContactId = 463633187003, LiveMessage = "testMessage" }; - var recipient2 = new CallRecipient { ContactId = 463633187003, LiveMessage = "testMessage" }; - var recipients = new List { recipient1, recipient2 }; - var request = new SendCallsRequest - { - Recipients = recipients, - CampaignId = 7373471003, - Fields = "items(id, fromNumber, state, campaignId)", - DefaultLiveMessage = "DefaultLiveMessage", - DefaultMachineMessage = "DefaultMachineMessage", - DefaultVoice = CallfireApiClient.Api.Campaigns.Model.Voice.FRENCHCANADIAN1 - }; - IList calls = Client.CallsApi.Send(request); - request = new SendCallsRequest - { - Recipients = recipients, - CampaignId = 7373471003, - Fields = "items(id, fromNumber, state, campaignId)", - DefaultLiveMessageSoundId = 1, - DefaultMachineMessageSoundId = 1, - DefaultVoice = CallfireApiClient.Api.Campaigns.Model.Voice.FRENCHCANADIAN1 - }; - calls = Client.CallsApi.Send(request); - -=== Get call -''' -Example how to return a single Call instance for a given call id. -[source,csharp] - //Only "id" param required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Call call = Client.CallsApi.Get(617067920003, "id,toNumber,state"); - Console.WriteLine("Call: " + call); - -=== Get call recordings -''' -Example how to return call recordings for a given call id. -[source,csharp] - //Only "id" param required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - IList recs = Client.CallsApi.GetCallRecordings(1234, "items(callId)"); - -=== Get call recording by name and call id -''' -Example how to return call recording for a given call by recording name. -[source,csharp] - //"id" and "name" params are required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CallRecording recording = Client.CallsApi.GetCallRecordingByName(1234, "testName", "callId"); - -=== Get mp3 call recording by name and call id -''' -Example how to return mp3 call recording for a given call by recording name. -[source,csharp] - //"id" and "name" params are required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - MemoryStream ms = (MemoryStream)Client.CallsApi.GetCallRecordingMp3ByName(1234, "testName"); - -=== Get call recording by id -''' -Example how to return call recording for a given recording id. -[source,csharp] - //Only "id" param required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CallRecording rec = Client.CallsApi.GetCallRecording(1234, "campaignId"); - -=== Get mp3 call recording by id -''' -Example how to return mp3 call recording for a given recording id. -[source,csharp] - //Only "id" param required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - MemoryStream ms = (MemoryStream)Client.CallsApi.GetCallRecordingMp3(1234); diff --git a/docs/api/callstexts/MediaApi.adoc b/docs/api/callstexts/MediaApi.adoc deleted file mode 100644 index efd9112..0000000 --- a/docs/api/callstexts/MediaApi.adoc +++ /dev/null @@ -1,34 +0,0 @@ -= Media API - - -=== Upload media file -''' -Example how to upload media file to account. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - String soundName = "mp3_file"; - ResourceId resourceId = Client.MediaApi.Upload(mp3FilePath, soundName); - Console.WriteLine("Media file id: " + resourceId); - -=== Get media -''' -Example how to get a single Media instance for a given media file id. This is the metadata - for the media only. No content data is returned from this API. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Media media = Client.MediaApi.Get(213421, "id,created"); - Console.WriteLine("Media file: " + media); - -=== Get media file data -''' -Example how to get media file's data as stream. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - MemoryStream ms = (MemoryStream)Client.MediaApi.GetData(213234, MediaType.MP3); - File.WriteAllBytes("Resources/File-examples/train.mp3", ms.ToArray()); - -Next code sample uses key parameter to get data. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - MemoryStream ms = (MemoryStream)Client.MediaApi.GetData("testKey", MediaType.MP3); - File.WriteAllBytes("Resources/File-examples/train.mp3", ms.ToArray()); diff --git a/docs/api/callstexts/TextsApi.adoc b/docs/api/callstexts/TextsApi.adoc deleted file mode 100644 index 41510a7..0000000 --- a/docs/api/callstexts/TextsApi.adoc +++ /dev/null @@ -1,57 +0,0 @@ -= Texts API - - -=== Find text -''' -Example how to find all texts sent or received by the user. Use "CampaignId=0" parameter to query for all texts sent through - the POST /texts API. If no limit is given then the last 100 texts will be returned. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //No one parameter is required - var request = new FindTextsRequest - { - States = new List { StateType.FINISHED, StateType.READY }, - Results = new List { TextRecord.TextResult.SENT, TextRecord.TextResult.RECEIVED }, - Limit = 2 - }; - Page texts = Client.TextsApi.Find(request); - -=== Send text -''' -Example how to use the /texts API to quickly send individual texts via existing campaign. A verified Caller ID and - sufficient credits are required to send a text. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //Only "recipients" param required - var recipient1 = new TextRecipient { Message = "msg", PhoneNumber = "12132212384" }; - var recipient2 = new TextRecipient { Message = "msg", PhoneNumber = "12132212384" }; - var recipients = new List { recipient1, recipient2 }; - IList texts = Client.TextsApi.Send(recipients); - -In case you want to send text via default campaign use *Send(List recipients, long? campaignId)* method. - -In case you want to send text with default text which will be used in case when recipient doesn't have that info specified, - see example below: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //Only "recipients" param required - var recipient1 = new TextRecipient { Message = "msg", PhoneNumber = "12132212384" }; - var recipient2 = new TextRecipient { Message = "msg", PhoneNumber = "12132212384" }; - var recipients = new List { recipient1, recipient2 }; - var request = new SendTextsRequest - { - Recipients = recipients, - CampaignId = 7415135003, - DefaultMessage = "DefaultLiveMessage", - Fields = "items(id,fromNumber,state)" - }; - IList texts = Client.TextsApi.Send(request); - -=== Get text -''' -Example how to return a single Text instance for a given text id. -[source,csharp] - //Only "id" param required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Text text = Client.TextsApi.Get(600537356003, "id,fromNumber,state"); - diff --git a/docs/api/campaigns/BatchesApi.adoc b/docs/api/campaigns/BatchesApi.adoc deleted file mode 100644 index 8f06c17..0000000 --- a/docs/api/campaigns/BatchesApi.adoc +++ /dev/null @@ -1,22 +0,0 @@ -= Campaign batches API - - -=== Get operation -''' -Returns a single Batch instance for a given batch id. This API is useful for determining the state of - a validating batch. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Batch batch = Client.BatchesApi.Get(1234); - Console.WriteLine("Batch: " + batch); - -=== Update operation -''' -Update a single Batch instance. May only change enabled at this time. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Batch batch = Client.BatchesApi.Get(1234); - batch.Enabled = false; - Client.BatchesApi.Update(batch); - var updated = Client.BatchesApi.Get(1234); - Console.WriteLine("Updated batch: " + updated); diff --git a/docs/api/campaigns/CallBroadcastsApi.adoc b/docs/api/campaigns/CallBroadcastsApi.adoc deleted file mode 100644 index e724e1d..0000000 --- a/docs/api/campaigns/CallBroadcastsApi.adoc +++ /dev/null @@ -1,154 +0,0 @@ -= Call broadcasts API - - -=== Find broadcasts -Find all call campaigns created by the user. Can query on label, name, and the current running status of the campaign. - Returns a paged list of call broadcasts. - Example how to find 2 call broadcasts which have 'campaign' suffix in their names: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var findRequest = new FindBroadcastsRequest - { - Name = "campaign name", - Limit = 2 - }; - var broadcasts = client.CallBroadcastsApi.Find(findRequest); - Console.WriteLine(broadcasts); - -=== Create broadcast -Create a call broadcast campaign using the Call Broadcast API. Send a CallBroadcast in the message body to detail - a call broadcast campaign. 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. - Example how to create call broadcast and then start it: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - 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 - { - new Recipient { PhoneNumber = "12132212384" }, - new Recipient { PhoneNumber = "12132212385" } - }, - ResumeNextDay = true - - }; - // create broadcast with 'start' argument = true to start campaign immediately - var id = client.CallBroadcastsApi.Create(broadcast, true); - -=== Get broadcast -Get call broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var broadcast = client.CallBroadcastsApi.Get(123L); - Console.WriteLine(broadcast); - -=== Update broadcast -After having created an call broadcast campaign, this method lets the user modify the configuration of - a call broadcast campaign. - See example how to add local time restrictions: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var broadcast = client.CallBroadcastsApi.Get(123L); - // time restrictions - broadcast.LocalTimeRestriction = new LocalTimeRestriction - { - BeginHour = 10, - BeginMinute = 10, - EndHour = 22, - EndMinute = 0, - Enabled = true - }; - // update campaign - client.CallBroadcastsApi.Update(broadcast); - -=== Start broadcast -Start call broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.CallBroadcastsApi.Start(123L); - -=== Stop broadcast -Stop call broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.CallBroadcastsApi.Stop(123L); - -=== Archive broadcast -Archive call broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.CallBroadcastsApi.Archive(123L); - -=== Get broadcast calls -Get calls associated with call broadcast ordered by date. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new GetByIdRequest { Id = 1234 }; - var calls = client.CallBroadcastsApi.GetCalls(request); - Console.WriteLine(calls); - -If you want to get calls filtered by batch id please use code like: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new GetBroadcastCallsTextsRequest { Id = 1234, batchId = 12345 }; - var calls = client.CallBroadcastsApi.GetCalls(getCallsRequest); - Console.WriteLine(calls); - -=== Get broadcast stats -Get broadcast statistics. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - String fields = "callsAttempted,callsPlaced,callsDuration"; - var begin = DateTime.Now.AddDays(-5d); - var end = DateTime.Now; - var stats = client.CallBroadcastsApi.GetStats(8624192003L, fields, begin, end); - Console.WriteLine(stats); - -=== Add recipients to a call broadcast -Use this method to add recipients to an already created call broadcast. Post a list of Recipient objects for - them to be immediately added to the call broadcast campaign. These contacts do not go through validation process, - and will be acted upon as they are added. Recipients may be added as a list of contact ids, or list of numbers. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var calls = client.CallBroadcastsApi.AddRecipients(1234, new List - { - new Recipient { PhoneNumber = "12131234567" }, - new Recipient { PhoneNumber = "12131234568" } - }); - Console.WriteLine(calls); - -=== Get all broadcast batches -This method will enable the user to page through all of the batches for a particular call broadcast campaign. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new GetByIdRequest { Id = 1234 }; - var batches = client.CallBroadcastsApi.GetBatches(request); - Console.WriteLine(batches); - -=== Add batch to broadcast -The add batch method allows the user to add additional batches to an already created call broadcast campaign. - The added batch will go through the CallFire validation process, unlike in the recipients version of this API. - Because of this, use the scrubDuplicates flag to remove duplicates from your batch. Batches may be added as a - contact list id, a list of contact ids, or a list of numbers. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new AddBatchRequest - { - CampaignId = 1234, - Name = "new_batch", - Recipients = new List - { - new Recipient { PhoneNumber = "12131234567" }, - new Recipient { PhoneNumber = "12131234568" } - } - }; - var id = client.CallBroadcastsApi.AddBatch(request); diff --git a/docs/api/campaigns/CampaignSoundsApi.adoc b/docs/api/campaigns/CampaignSoundsApi.adoc deleted file mode 100644 index d9caa42..0000000 --- a/docs/api/campaigns/CampaignSoundsApi.adoc +++ /dev/null @@ -1,95 +0,0 @@ -= Campaign Sounds API - - -=== Find campaign sounds -''' -Find all campaign sounds that were created by the user. These are all of the available sounds to be used in campaigns. - Example how to find 3 campaign sounds and filter by name "sample". -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - FindSoundsRequest request = new FindSoundsRequest { Limit = 3, Filter = "sample" }; - Page campaignSounds = Client.CampaignSoundsApi.Find(request); - -=== Get sound metadata -''' -Returns a single CampaignSound instance for a given campaign sound id. This is the meta data to the sounds only. - No audio data is returned from this API. - Example how to get sound metadata by ID only with name, status and lengthInSeconds fields, to get whole object, just - call *campaignSoundsApi.get(id)* method without fields argument: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CampaignSound campaignSound = Client.CampaignSoundsApi.Get(12345, "name,status,lengthInSeconds"); - -=== Delete campaign sound -''' -Example how to delete a single CampaignSound instance for a given campaign sound id. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.CampaignSoundsApi.Delete(12345); - -=== Download MP3 sound -''' -Download the MP3 version of the hosted file. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - MemoryStream ms = (MemoryStream)Client.CampaignSoundsApi.GetMp3(12345); - File.WriteAllBytes("Resources/File-examples/train.mp3", ms.ToArray()); - -=== Download WAV sound -''' -Download the WAV version of the hosted file. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - MemoryStream ms = (MemoryStream)Client.CampaignSoundsApi.GetWav(12345); - File.WriteAllBytes("Resources/File-examples/train.waw", ms.ToArray()); - -=== Add sound via call -''' -Use this API to create a sound via phone call. Supply the required phone number in the CallCreateSound object - inside of the request, and the user will receive a call shortly after with instructions on how to record a - sound over the phone. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CallCreateSound callCreateSound = new CallCreateSound - { - Name = "call_in_sound_" + new DateTime().Millisecond, - ToNumber = "12132212384" - }; - ResourceId resourceId = Client.CampaignSoundsApi.RecordViaPhone(callCreateSound); - Console.WriteLine("Sound id: " + resourceId.Id); - -If you want to see created sound details please use code like: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CallCreateSound callCreateSound = new CallCreateSound - { - Name = "call_in_sound_" + new DateTime().Millisecond, - ToNumber = "12132212384" - }; - CampaignSound sound = Client.CampaignSoundsApi.RecordViaPhoneAndGetSoundDetails(callCreateSound, "id,name"); - -=== Add sound via text-to-speech -''' -Use this API to create a sound file via a supplied string of text. Send the required text in the - TextToSpeech.Message field, and pick a voice in the TextToSpeech.Voice field. Available voices are: - MALE1, FEMALE1 , FEMALE2, SPANISH1, FRENCHCANADIAN1, see Voice enum. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - TextToSpeech tts = new TextToSpeech { Message = "this is TTS message from csharp client" }; - ResourceId resourceId = Client.CampaignSoundsApi.CreateFromTts(tts); - CampaignSound campaignSound = Client.CampaignSoundsApi.Get(resourceId.Id); - Console.WriteLine("Campaign sound: " + campaignSound); - -If you want to see created sound details please use code like: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - TextToSpeech tts = new TextToSpeech { Message = "this is TTS message from csharp client" }; - CampaignSound sound = Client.CampaignSoundsApi.CreateFromTtsAndGetSoundDetails(tts, "id,name"); - -=== Upload sound file -''' -Upload mp3 or wav sound file. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - string mp3FilePath = "Resources/File-examples/train.mp3"; - CampaignSound mp3Resource = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath, "fileName"); diff --git a/docs/api/campaigns/TextAutoRepliesApi.adoc b/docs/api/campaigns/TextAutoRepliesApi.adoc deleted file mode 100644 index 2de5567..0000000 --- a/docs/api/campaigns/TextAutoRepliesApi.adoc +++ /dev/null @@ -1,47 +0,0 @@ -= Text auto replies API - -Auto-replies are text message replies sent to a customer when a customer replies to a text message from a campaign. A -keyword will need to have been purchased before an Auto-Reply can be created. This endpoint contains CRUD operations -to *find, get, create, delete* text auto reply. - - -=== Find operation -Example how to find all configured auto replies for particular number. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new FindTextAutoRepliesRequest { Number = "19206596476" }; - var textAutoReplies = client.TextAutoRepliesApi.Find(request); - Console.WriteLine(textAutoReplies); - -Find all configured auto replies in account: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new FindTextAutoRepliesRequest(); - var textAutoReplies = client.TextAutoRepliesApi.Find(request); - Console.WriteLine(textAutoReplies); - -=== Create operation -Example how to configure auto reply for particular number and text with "vacation" word. -[source,csharp] - CallfireClient client = new CallfireClient("api_login", "api_password"); - var textAutoReply = new TextAutoReply() - { - Number = "19206596476", - Message = "test message", - Match = "test match" - }; - var resourceId = client.TextAutoRepliesApi.Create(textAutoReply); - Console.WriteLine(resourceId); - -=== Get operation -Get particular auto reply by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var textAutoReply = client.TextAutoRepliesApi.Get(12345L); - Console.WriteLine(textAutoReply); - -=== Delete operation -Delete particular auto reply by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.TextAutoRepliesApi.Delete(12345); diff --git a/docs/api/campaigns/TextBroadcastsApi.adoc b/docs/api/campaigns/TextBroadcastsApi.adoc deleted file mode 100644 index ed71e78..0000000 --- a/docs/api/campaigns/TextBroadcastsApi.adoc +++ /dev/null @@ -1,163 +0,0 @@ -= Text broadcasts API - - -=== Find broadcasts -Find all text broadcasts created by the user. Can query on label, name, and the current running status of - the campaign. Returns a paged list of text broadcasts. - Example how to find 2 text broadcasts which have 'campaign' suffix in their names: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new FindBroadcastsRequest - { - Name = "campaign name", - Limit = 1 - }; - var broadcasts = client.TextBroadcastsApi.Find(request); - Console.WriteLine(broadcasts); - -=== Create broadcast -Example how to create text broadcast and then start it. Broadcast will send messages within allowed - hours (10:10 - 22:00) to 2 recipients. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var broadcast = new TextBroadcast - { - Name = "voice_broadcast", - FromNumber = "12131234567", - BigMessageStrategy = BigMessageStrategy.SEND_MULTIPLE, - Message = "test_msg", - LocalTimeRestriction = new LocalTimeRestriction - { - BeginHour = 10, - BeginMinute = 10, - EndHour = 22, - EndMinute = 0, - Enabled = true - }, - Recipients = new List - { - new TextRecipient { PhoneNumber = "12132212384" }, - new TextRecipient { PhoneNumber = "12132212385" } - }, - ResumeNextDay = true - }; - // create broadcast - var id = client.TextBroadcastsApi.Create(broadcast, true); - -=== Get broadcast -Get text broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var broadcast = client.TextBroadcastsApi.Get(123L); - Console.WriteLine(broadcast); - -=== Update broadcast -After having created a text broadcast campaign, this method lets the user modify the configuration of - a text broadcast campaign. - See example how to update name of campaign: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var broadcast = client.TextBroadcastsApi.Get(123L); - broadcast.Name = "New name"; - // update campaign - client.TextBroadcastsApi.Update(broadcast); - -=== Start broadcast -Start text broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.TextBroadcastsApi.Start(123L); - -=== Stop broadcast -Stop text broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.TextBroadcastsApi.Stop(123L); - -=== Archive broadcast -Archive text broadcast by ID. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.TextBroadcastsApi.Archive(123L); - -=== Get broadcast texts -This operation will enable the user to page through all of the texts for a particular text broadcast campaign. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new GetByIdRequest { Id = 123 }; - var texts = client.TextBroadcastsApi.GetTexts(request); - Console.WriteLine(texts); - -If you want to get texts filtered by batch id please use code like: -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var request = new GetBroadcastCallsTextsRequest { Id = 123, batchId = 1234 }; - var texts = client.TextBroadcastsApi.GetTexts(request); - -=== Get broadcast stats -Get broadcast statistics. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - var begin = DateTime.Now.AddDays(-5d); - var end = DateTime.Now; - var stats = client.TextBroadcastsApi.GetStats(8624192003L, null, begin, end); - Console.WriteLine(stats); - -=== Add recipients to a text broadcast -Use this method to add recipients to an already created text broadcast. Post a list of Recipient objects for - them to be immediately added to the text broadcast campaign. These contacts do not go through validation process, - and will be acted upon as they are added. Recipients may be added as a list of contact ids, or list of numbers. -[source,csharp] - CallfireClient client = new CallfireClient("api_login", "api_password"); - var recipients = new List - { - new TextRecipient { PhoneNumber = "12132212384" }, - new TextRecipient { PhoneNumber = "12132212385" } - }; - var texts = client.TextBroadcastsApi.AddRecipients(1234, recipients); - Console.WriteLine(texts); - -=== Get a specific broadcast batch -Returns a single Batch instance for a given text broadcast batch id. -[source,csharp] - CallfireClient client = new CallfireClient("api_login", "api_password"); - var getBatchRequest = new GetByIdRequest { Id = 1234 }; - Batch batch = client.TextBroadcastsApi.GetBatch(batchRequest); - Console.WriteLine(batch); - -=== Get all broadcast batches -This method will enable the user to page through all of the batches for a particular text broadcast campaign. -[source,csharp] - CallfireClient client = new CallfireClient("api_login", "api_password"); - var getBatchesRequest = new GetByIdRequest { Id = 12345 }; - var batches = client.TextBroadcastsApi.GetBatches(getBatchesRequest); - Console.WriteLine(batches); - -=== Update a specific broadcast batch -Update a text broadcast batch. Can only change enabled at this time. -[source,csharp] - CallfireClient client = new CallfireClient("api_login", "api_password"); - var getBatchRequest = new GetByIdRequest { Id = 1234 }; - Batch batch = client.TextBroadcastsApi.GetBatch(getBatchRequest); - batch.Enabled = false; - client.TextBroadcastsApi.UpdateBatch(batch); - -=== Add batch to broadcast -The add batch method allows the user to add additional batches to an already created text broadcast campaign. - The added batch will go through the CallFire validation process, unlike in the recipients version of this API. - Because of this, use the scrubDuplicates flag to remove duplicates from your batch. Batches may be added as a - contact list id, a list of contact ids, or a list of numbers. -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - // add batch - var addBatchRequest = new AddBatchRequest - { - CampaignId = (long)id, - Name = "new_batch", - Recipients = new List - { - new TextRecipient { PhoneNumber = "12132212384" }, - new TextRecipient { PhoneNumber = "12132212385" } - } - }; - var resourceId = Client.TextBroadcastsApi.AddBatch(addBatchRequest); diff --git a/docs/api/contacts/ContactListsApi.adoc b/docs/api/contacts/ContactListsApi.adoc deleted file mode 100644 index 736ff22..0000000 --- a/docs/api/contacts/ContactListsApi.adoc +++ /dev/null @@ -1,75 +0,0 @@ -= Contact lists API - - -=== Find contact lists -''' -Example how to find contact lists (request includes such parameters to filter as Name, Limit, Offset and Fields). -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new FindContactListsRequest { Limit = 1, Offset = 0 }; - Page contactLists = Client.ContactListsApi.Find(request); - Console.WriteLine("Page of contact lists: " + contactLists); - -=== Get contact list -''' -Example how to get contact list by id. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - ContactList contactList = Client.ContactListsApi.Get(1026694003); - Console.WriteLine("Contact list: " + contactList); - -=== Create contact list -''' -Contact lists can be created from existing single contacts (use their ids), contact objects and phone numbers. - Example how to create contact list from plain numbers: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CreateContactListRequest request = new CreateContactListRequest - { - Contacts = new List { "12135678881", "12135678882" }, - Name = "listFromNumbers" - }; - ResourceId resourceId = Client.ContactListsApi.Create(request); - -Second example shows how to create contact list from existing contacts, what we need is just their ids: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CreateContactListRequest request = new CreateContactListRequest - { - Contacts = new List { 123, 456, 789 }, - Name = "listFromIds" - }; - ResourceId resourceId = Client.ContactListsApi.Create(request); - -Next code sample uses *Contact* object in CreateContactListRequest request: -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - CreateContactListRequest request = new CreateContactListRequest - { - Contacts = new List { new Contact { FirstName = "John", HomePhone = "16505044730" } }, - Name = "listFromContacts" - }; - ResourceId resourceId = Client.ContactListsApi.Create(request); - -=== Create contact list from csv -''' -Example how to upload contact lists from CSV file. Max file size is limited to 10 Mb. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - string path = "Resources/File-examples/contacts1.csv"; - ResourceId listId = Client.ContactListsApi.CreateFromCsv("fileList", Path.GetFullPath(path)); - -=== Update contact list -''' -Example how to update contact list. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - UpdateContactListRequest updateListRequest = new UpdateContactListRequest { Id = 1026694003, Name = "sampleListName" }; - Client.ContactListsApi.Update(updateListRequest); - -=== Delete contact list -''' -Example how to delete contact list. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.ContactListsApi.Delete(463633187003); diff --git a/docs/api/contacts/ContactsApi.adoc b/docs/api/contacts/ContactsApi.adoc deleted file mode 100644 index 889dd01..0000000 --- a/docs/api/contacts/ContactsApi.adoc +++ /dev/null @@ -1,61 +0,0 @@ -= Contacts API - - -=== Find contacts -''' -Example how to find contacts by ids, contact list, Limit and Offset value. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new FindContactsRequest - { - Number = new List { "16506190257", "18778973473" }, - Id = new List { 1, 2 }, - Limit = 1, - Offset = 0 - }; - Page contacts = Client.ContactsApi.Find(request); - Console.WriteLine(String.Join(",", contacts)); - -=== Get contact -''' -Example how to get contact by id. Deleted contacts can still be retrieved but will be marked deleted - and will not show up when quering contacts via UI. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Contact contact = Client.ContactsApi.Get(463633187003); - -=== Create contact -''' -Example how to create contacts in the CallFire system. These contacts are not validated on creation. - They will be validated upon being added to a campaign. Example how to create contact with custom fields. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var contact = new Contact - { - HomePhone = "16505044730", - FirstName = "John", - LastName = "Doe", - Properties = new Dictionary { { "age", "30" }, { "customFieldN", "customValue" } } - }; - IList contacts = Client.ContactsApi.Create(new List { contact }); - Console.WriteLine(String.Join(",", contacts)); - -=== Update contact -''' -Example how to update contact. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var contact = new Contact - { - Id = 463633187003, - HomePhone = "16505044730" - }; - Client.ContactsApi.Update(contact); - -=== Delete contact -''' -Example how to delete contact by id. This does not actually delete the contact, it just removes the contact from - any contact lists and marks the contact as deleted so won't show up in queries anymore. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.ContactsApi.Delete(463633187003); diff --git a/docs/api/contacts/DncApi.adoc b/docs/api/contacts/DncApi.adoc deleted file mode 100644 index db6b240..0000000 --- a/docs/api/contacts/DncApi.adoc +++ /dev/null @@ -1,28 +0,0 @@ -= DNCs API - - -=== Find dncs -''' -Example how to find all Do Not Contact (DNC) objects created by the user. - These DoNotContact entries only affect calls/texts/campaigns on this account. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new FindDncContactsRequest(); - Page dncs = Client.DncApi.Find(request); - Console.WriteLine("Page of do not contacts:" + dncs); - -=== Update dnc -''' -Example how to update a Do Not Contact (DNC) contact value for calls and texts. Can toggle whether the DNC is enabled - for calls/texts. They will be validated upon being added to a campaign. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - DoNotContact dncToUpdate = new DoNotContact - { - ListId = 1975140003, - Text = true, - Call = true, - Number = "12563505052" - }; - Client.DncApi.Update(dncToUpdate); - diff --git a/docs/api/keywords/KeywordLeasesApi.adoc b/docs/api/keywords/KeywordLeasesApi.adoc deleted file mode 100644 index 3e6bd32..0000000 --- a/docs/api/keywords/KeywordLeasesApi.adoc +++ /dev/null @@ -1,28 +0,0 @@ -= Keyword leases API - - -=== Find keyword leases -''' -Find all owned keyword leases for a user. A keyword lease is the ownership information involving a keyword. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new CommonFindRequest(); - Page keywordLeases = Client.KeywordLeasesApi.Find(request); - Console.WriteLine("Page of keyword leases: " + keywordLeases); - -=== Get keyword lease -''' -Example how to return a KeywordLease for a given keyword. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - KeywordLease keywordLease = Client.KeywordLeasesApi.Get("CALLFIRE"); - Console.WriteLine("KeywordLease: " + keywordLease); - -=== Update keyword lease -''' -Example how update a keyword lease. Can only set autoRenew to false at this time. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - KeywordLease keywordLease = new KeywordLease { KeywordName = "CALLFIRE", AutoRenew = false }; - Client.KeywordLeasesApi.Update(keywordLease); - diff --git a/docs/api/keywords/KeywordsApi.adoc b/docs/api/keywords/KeywordsApi.adoc deleted file mode 100644 index 0945231..0000000 --- a/docs/api/keywords/KeywordsApi.adoc +++ /dev/null @@ -1,23 +0,0 @@ -= Keywords API - - -=== Find keyword -''' -Example how to find keywords for purchase on the CallFire platform. If a keyword appears in the response, - it is available for purchase. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - List keywordsNames = new List { "ALPHA", "BETA" }; - IList keywords = Client.KeywordsApi.Find(keywordsNames); - foreach (Keyword keyword in keywords) - { - Console.WriteLine(keyword.ToString()); - } - -=== IsAvailable keyword -''' -Example how to find an individual keyword for purchase on the CallFire platform. Returns boolean for availability. -[source,csharp] - //"keyword" param is required - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Boolean isAvaialble = Client.KeywordsApi.IsAvailable("TEST"); diff --git a/docs/api/keywords/KeywordsMain.adoc b/docs/api/keywords/KeywordsMain.adoc deleted file mode 100644 index 5db0a82..0000000 --- a/docs/api/keywords/KeywordsMain.adoc +++ /dev/null @@ -1,3 +0,0 @@ -include::KeywordsApi.adoc[] - -include::KeywordLeasesApi.adoc[] \ No newline at end of file diff --git a/docs/api/numbers/NumberLeasesApi.adoc b/docs/api/numbers/NumberLeasesApi.adoc deleted file mode 100644 index 6e52fc5..0000000 --- a/docs/api/numbers/NumberLeasesApi.adoc +++ /dev/null @@ -1,67 +0,0 @@ -= Number leases API - - -=== Find number leases -''' -Example how to find number leases of particular local numbers for the user. This API is useful for finding all numbers - currently owned by an account. In that case send empty find request: *new FindNumberLeasesRequest()*. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new FindNumberLeasesRequest { City = "REDWOOD CITY" }; - Page leases = Client.NumberLeasesApi.Find(request); - Console.WriteLine(leases); - -=== Get number lease -''' -Example how to return a single NumberLease instance for a given number. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - NumberLease lease = Client.NumberLeasesApi.Get("16502572135"); - Console.WriteLine(lease); - -=== Update number lease -''' -Example how to update a number lease instance. Ability to turn off autoRenew and toggle call/text features for a - particular number. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - NumberLease lease = new NumberLease { PhoneNumber = "16502572135", AutoRenew = true }; - Client.NumberLeasesApi.Update(lease); - -=== Find number leases configs -''' -Example how to find all number lease configs for the user. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new FindNumberLeaseConfigsRequest(); - Page configs = Client.NumberLeasesApi.FindConfigs(request); - Console.WriteLine(configs); - -=== Get number leases config -''' -Example how to return a single NumberConfig instance for a given number. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - NumberConfig config = Client.NumberLeasesApi.GetConfig("16502572135"); - Console.WriteLine(config); - -=== Update number lease config -''' -Example how to update a number lease config. Use this API endpoint to add an Inbound IVR or Call Tracking - feature to a CallFire phone number. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - // create call tracking config - CallTrackingConfig callTrackingConfig = new CallTrackingConfig - { - Screen = true, - Recorded = true, - TransferNumbers = new List { "16502572136", "16502572137" } - }; - NumberConfig config = new NumberConfig - { - Number = "16502572135", - ConfigType = NumberConfig.NumberConfigType.TRACKING, - CallTrackingConfig = callTrackingConfig - }; - Client.NumberLeasesApi.UpdateConfig(config); diff --git a/docs/api/numbers/NumbersApi.adoc b/docs/api/numbers/NumbersApi.adoc deleted file mode 100644 index 85e909d..0000000 --- a/docs/api/numbers/NumbersApi.adoc +++ /dev/null @@ -1,37 +0,0 @@ -= Numbers API - - -=== Find local numbers -''' -Example how to find numbers in the CallFire local numbers catalog that are available for purchase. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //At least one parameter is required - var request = new FindNumbersLocalRequest { Limit = 2, State = "LA" }; - IList numbers = Client.NumbersApi.FindNumbersLocal(request); - Console.WriteLine(numbers); - -=== Find number regions -''' -Use this API to obtain detailed region information that can then be used to query for more specific phone numbers - than a general query. Example below shows how to find number region information for specified state and zip code. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - //At least one parameter is required - var request = new FindNumberRegionsRequest - { - Limit = 2, - State = "IL", - Zipcode = "60640" - }; - Page regions = Client.NumbersApi.FindNumberRegions(request); - Console.WriteLine(regions); - -=== Find numbers tollfree -''' -Example how to find numbers in the CallFire tollfree numbers catalog that are available for purchase. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var request = new CommonFindRequest { Limit = 2, Offset = 1 }; - IList numbers = Client.NumbersApi.FindNumbersTollfree(request); - Console.WriteLine(numbers); diff --git a/docs/api/numbers/NumbersMain.adoc b/docs/api/numbers/NumbersMain.adoc deleted file mode 100644 index 0a415d3..0000000 --- a/docs/api/numbers/NumbersMain.adoc +++ /dev/null @@ -1,3 +0,0 @@ -include::NumbersApi.adoc[] - -include::NumberLeasesApi.adoc[] \ No newline at end of file diff --git a/docs/api/webhooks/SubscriptionsApi.adoc b/docs/api/webhooks/SubscriptionsApi.adoc deleted file mode 100644 index 8451900..0000000 --- a/docs/api/webhooks/SubscriptionsApi.adoc +++ /dev/null @@ -1,55 +0,0 @@ -= Subscriptions API - -=== Find subscriptions -''' -Search for subscriptions on campaign, trigger event, format, fromNumber, toNumber. - Example how to get first 5 subscriptions which are assigned to campaign with id 1000000L and have formatted as JSON. -[source,csharp] - var client = new CallfireClient("api login", "api password"); - var request = new FindSubscriptionsRequest - { - Limit = 5, - CampaignId(1000000L), - Format = (NotificationFormat.JSON) - }; - var subscriptions = client.SubscriptionsApi.Find(request); - -=== Get subscription -''' -Example how to get a single Subscription instance for a given subscription id. -[source,csharp] - var client = new CallfireClient("api login", "api password"); - var subscription = client.SubscriptionApi.Get(12345678L, "id,name,created"); - -=== Create subscription -''' -Example how to create a subscription for campaign. Callfire will query your callback URL with http POST request when - specified campaign has FINISHED. -[source,csharp] - var client = new CallfireClient("api login", "api password"); - var subscription = new Subscription - { - Enabled = true, - Endpoint = "http://www.example.com/endpoint", - NotificationFormat = NotificationFormat.JSON, - BroadcastId = 1400000L, - TriggerEvent = TriggerEvent.CAMPAIGN_FINISHED - } - var id = client.SubscriptionsApi.Create(subscription); - -=== Update subscription -''' -Example how to update the information in a currently existing subscription. Most fields are updatable. -[source,csharp] - var client = new CallfireClient("api login", "api password"); - var subscription = client.SubscriptionsApi.Get(123456L); - subscription.TriggerEvent = TriggerEvent.CAMPAIGN_STARTED; - subscription.Callback = "https://yoursite.com/callback"; - client.SubscriptionsApi.Update(subscription); - -=== Delete subscription -''' -Example how to delete a subscription. Will be removed permanently. -[source,csharp] - var client = new CallfireClient("api login", "api password"); - client.SubscriptionsApi.Delete(12345678L); diff --git a/docs/api/webhooks/WebhooksApi.adoc b/docs/api/webhooks/WebhooksApi.adoc deleted file mode 100644 index a663afa..0000000 --- a/docs/api/webhooks/WebhooksApi.adoc +++ /dev/null @@ -1,77 +0,0 @@ -= Webhooks API - - -=== Find webhooks -''' -Search for webhooks on name, resource, event, callback URL, or whether they are enabled. - Example how to get first 5 webhooks which are *enabled* and assigned to resource *"textBroadcast"*. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var findRequest = new FindWebhooksRequest - { - Limit = 5, - Enabled = true, - Name = "test_name" - }; - Page webhooks = Client.WebhooksApi.Find(findRequest); - Console.WriteLine(webhooks); - -=== Get webhook -''' -Example how to get a single Webhook instance for a given webhook id. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Webhook webhook = Client.WebhooksApi.Get(12345678, "id,name,created"); - Console.WriteLine("Webhook: " + webhook); - -=== Create webhook -''' -Example how to create a webhook for voice campaign. Callfire will query your callback URL with http POST request when - any campaign has STARTED or FINISHED. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var webhook = new Webhook - { - Name = "new webhook", - Resource = ResourceType.TEXT_BROADCAST, - Events = new HashSet { ResourceEvent.STARTED, ResourceEvent.FINISHED }, - Callback = "https://yoursite.com/callback" - }; - ResourceId resource = Client.WebhooksApi.Create(webhook); - Console.WriteLine(resource.Id); - -=== Update webhook -''' -Example how to update the information in a currently existing webhook. Most fields are updatable. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var webhook = new Webhook - { - Id = 12345678, - Name = "new webhook", - Resource = ResourceType.TEXT_BROADCAST, - Events = new HashSet { ResourceEvent.STARTED, ResourceEvent.FINISHED }, - Callback = "https://yoursite.com/callback" - }; - Client.WebhooksApi.Update(webhook); - -=== Delete webhook -''' -Example how to delete a webhook. Will be removed permenantly. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - Client.WebhooksApi.Delete(12345678); - -=== Find webhook resources -''' -Example how to find webhook resources. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var resources = Client.WebhooksApi.FindWebhookResources("items(resource)"); - -=== Find webhook resource -''' -Example how to find webhook resource. -[source,csharp] - CallfireClient Client = new CallfireClient("api_login", "api_password"); - var resource = Client.WebhooksApi.FindWebhookResource(ResourceType.CALL_BROADCAST, "resource"); From bcfcdfa312f776d69fb944562700a54252de7306 Mon Sep 17 00:00:00 2001 From: vmalinovskiy Date: Wed, 23 Nov 2016 09:40:18 +0200 Subject: [PATCH 4/4] vmalinovskiy: remove all docs from project (they are present on developers.callfire.com) --- README.adoc | 4 +- docs/GettingStarted.adoc | 158 --------------------------------------- 2 files changed, 2 insertions(+), 160 deletions(-) delete mode 100644 docs/GettingStarted.adoc diff --git a/README.adoc b/README.adoc index 7afd60e..dfd32a7 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,6 @@ = Callfire API v2 REST client -C# client for Callfire platform API version 2. See link:docs/GettingStarted.adoc[Getting Started] +C# client for Callfire platform API version 2. See link:https://developers.callfire.com/callfire-api-client-csharp.html[Getting Started] page for setup instructions. .*Requirements:* @@ -11,7 +11,7 @@ C# client for Callfire platform API version 2. See link:docs/GettingStarted.adoc * RestSharp >= 105.2.3 .*Table of contents* -* link:docs/GettingStarted.adoc[Getting Started] +* link:https://developers.callfire.com/callfire-api-client-csharp.html[Getting Started] * link:https://developers.callfire.com/docs.html[REST endpoints documentation and api code samples] * Have a question ? ** link:https://developers.callfire.com/chat.html[Public chat room] diff --git a/docs/GettingStarted.adoc b/docs/GettingStarted.adoc deleted file mode 100644 index aaf693c..0000000 --- a/docs/GettingStarted.adoc +++ /dev/null @@ -1,158 +0,0 @@ -= Getting started - -== Installation - -To install CallFire API v2 client, run the following command in the Package Manager Console -[source] -PM> Install-Package CallfireApiClient - -or using nuget console tool: -[source] -$ nuget install CallfireApiClient - -it will install the latest public version, other releases you can find at link:https://github.com/CallFire/callfire-api-client-csharp/releases[releases page]. -After these steps *CallfireApiClient* should appear in your project dependencies along with other transitive ones. - -* Note for Visual Studio installation: to be able to use api client please manually copy callfire-api-client.dll.config from your -solutionFolder\packages\CallfireApiClient.?.?.? folder to target dir. -You can use post-build event for that (https://msdn.microsoft.com/en-us/library/ke5z92ks.aspx). -Command example for post-build event: -[source] -xcopy "$(SolutionDir)packages\CallfireApiClient.?.?.?\lib\callfire-api-client.dll.config" "$(TargetDir)" /i /R /Y - -In case you want to build it yourself: -[source] - $ git clone https://github.com/CallFire/callfire-api-client-csharp.git - $ cd callfire-api-client-csharp - // build on windows platform - $ gradlew.bat clean nugetPack - // build on unix platforms - $ ./gradlew clean nugetPack - -it will produce zip & Nuget packages in *build/dist* directory: -[source] - callfire-api-client.dll - client assembly - callfire-api-client.dll.config - configuration file - callfire-api-client.xml - XML documentation - -then you can install Nuget package locally or unpack zip package into your project's lib directory. - -== Overview -To create client instance just provide API login and password. API credentials should be configured on -link:https://www.callfire.com/ui/manage/access[Account -> Settings -> API Access] page. Client uses HTTPS connection -and Basic Authentication. - -Example how to get account information using client: -[source,csharp] - class MainClass - { - public static void Main(string[] args) - { - var client = new CallfireClient("api_login", "api_password"); - Console.WriteLine(client.MeApi.GetAccount()); - } - } - -.*List of API groups:* -[source,csharp] - var client = new CallfireClient("api_login", "api_password"); - client.MeApi; - client.OrdersApi; - client.BatchesApi; - client.CampaignSoundsApi; - client.MediaApi; - client.ContactsApi; - client.ContactListsApi; - client.NumbersApi; - client.NumberLeasesApi; - client.KeywordsApi; - client.KeywordLeasesApi; - client.DncApi; - client.DncListsApi; - client.CallsApi; - client.TextsApi; - client.TextAutoRepliesApi; - client.TextBroadcastsApi; - client.CallBroadcastsApi; - client.WebhooksApi; - -== Error handling -The CallFire Developers API uses standard HTTP response codes for responses. These HTTP codes indicate whether - or not an API operation is successful. - -Status Code 200 is the desired response code. A standard JSON response will follow. - -Codes in the 400s range detail all of the errors a CallFire Developer could encounter while using the API. Bad - Request, Rate Limit Reached, and Unauthorized are some of the sorts of responses in the 400s block. - -Codes in the 500s range are error responses from the CallFire system. If an error has occurred anywhere in the - execution of a resource that was not due to user input, a 500 response will be returned with a corresponding - JSON error body. In that body will contain a message detailing what went wrong. - -.All API methods throw following exceptions: - * *CallfireClientException* - in case error has occurred in client - * *CallfireApiException* - in case API cannot be queried for some reason and server returned error (this is the base - exception for API errors, some specific HTTP codes have their own exception): - ** *400 - BadRequestException* - The request was formatted improperly - ** *401 - UnauthorizedException* - API Key missing or invalid - ** *403 - AccessForbiddenException* - Insufficient permissions - ** *404 - ResourceNotFoundException* - The resource requested does not exist - ** *500 - InternalServerErrorException* - We had an error! Sorry about that. - ** other error codes will throw CallfireApiException - -*CallfireApiException* has *ApiErrorMessage* property with details of occurred error, here is fields listing: -[source,csharp] - int? HttpStatusCode; - int? InternalCode; - string Message; - string DeveloperMessage; - string HelpLink; - -== Configuration -=== Proxy - -Starting from version 1.1.4 users have possibility to make API calls go through proxy, here is an example how to configure it: -[source,java] - RestApiClient.getClientConfig().Add(ClientConstants.PROXY_ADDRESS_PROPERTY, "localhost:3128"); - RestApiClient.getClientConfig().Add(ClientConstants.PROXY_CREDENTIALS_PROPERTY, "proxyuser:proxypass"); - // now create client - CallfireClient Client = new CallfireClient("api_user", "api_pass"); - Console.WriteLine("account: " + Client.MeApi.GetAccount()); - -*IMPORTANT.* You must add proxy address property and proxy credentials (if needed) before client instantiation! - -Proxy address port is optional, 8080 is used by default. - -== Debug & logging -In case you want to see requests/responses which client sends/receives from Callfire platform you should copy -*system.diagnostics* section from callfire-api-client.dll.config into your application's app.config file, then -it will create callfire-api-client.log file in your work directory with debug output: -[source] -2015/10/21 19:02:47:355 EEST [DEBUG] RestApiClient - GET request to https://api.callfire.com/v2/me/account with params: [] -2015/10/21 19:02:48:722 EEST [DEBUG] RestApiClient - received entity -{ - "id" : 1234567890, - "email" : "john@callfire.com", - "name" : "test", - "firstName" : "John", - "lastName" : "Doe", - "permissions" : [ "ACCOUNT_HOLDER" ] -} - -Source code debugging is available with a help of nuget symbolsource directory. -Recommended configuration for Visual Studio: -http://www.symbolsource.org/Public/Home/VisualStudio - - -== Platform compatibility - -Library was built and tested on OS X with mono 4.2.1 .NET 4.5 and Windows 7 x64 .NET 4.5 platform - - -== Troubleshooting -In case you have an issue, please create a ticket at link:https://github.com/CallFire/callfire-api-client-csharp/issues[Issues] page. -Issue description should contain a brief info (including versions) about platform, IDE, .NET framework where this SDK is used. - -.What you should verify: - * callfire-api-client.dll.config file is placed next to .dll assembly - * System.Configuration is selected in project's references window