diff --git a/CallfireApiClient.nuspec b/CallfireApiClient.nuspec index d7f9156..ac31472 100644 --- a/CallfireApiClient.nuspec +++ b/CallfireApiClient.nuspec @@ -1,7 +1,7 @@ CallfireApiClient - 1.1.12 + 1.1.13 CallFire API v2 client Vladimir Mikhailov @@ -15,6 +15,9 @@ C# client library for integration with Callfire REST API v2 services Callfire API client Changelog ============================= +Version 1.1.13 - Dec 30 2016 +- minor fixes for get contacts history api + Version 1.1.12 - Dec 28 2016 - updated CallRecord dto to include originateTime, answerTime, duration, callerName and switchId fields - updated Webhook dto to include singleUse parameter diff --git a/Changelog.txt b/Changelog.txt index 5e93b2a..2938bfa 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,8 @@ Callfire API client Changelog ============================= +Version 1.1.13 - Dec 30 2016 +- minor fixes for get contacts history api + Version 1.1.12 - Dec 28 2016 - updated CallRecord dto to include originateTime, answerTime, duration, callerName and switchId fields - updated Webhook dto to include singleUse parameter diff --git a/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactsApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactsApiIntegrationTest.cs index 9703d65..51d5f55 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactsApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactsApiIntegrationTest.cs @@ -73,7 +73,7 @@ public void ContactsCRUD() } [Test] - public void GetObsoleteContactHistory() + public void GetContactHistory() { var request = new GetByIdRequest { Id = 1, Limit = 5 }; var contactHistory = Client.ContactsApi.GetHistory(request); @@ -82,18 +82,6 @@ public void GetObsoleteContactHistory() Console.WriteLine("ContactHistory:" + contactHistory); } - [Test] - public void GetContactHistory() - { - var request = new GetByIdRequest { Id = 1, Limit = 5 }; - var contactHistory = Client.ContactsApi.GetHistory(1, 0, 0); - Assert.AreEqual(2, contactHistory.Calls.Count); - - contactHistory = Client.ContactsApi.GetHistory(1); - Assert.AreEqual(2, contactHistory.Calls.Count); - - Console.WriteLine("ContactHistory:" + contactHistory); - } } } diff --git a/src/CallfireApiClient.IntegrationTests/Api/Numbers/NumbersApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Numbers/NumbersApiIntegrationTest.cs index 54e4616..8324f58 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Numbers/NumbersApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Numbers/NumbersApiIntegrationTest.cs @@ -9,7 +9,7 @@ namespace CallfireApiClient.IntegrationTests.Api.Numbers public class NumbersApiIntegrationTest : AbstractIntegrationTest { [Test] - public void FindTollfreeNumbers() + public void FindObsoleteTollfreeNumbers() { var request = new CommonFindRequest { Limit = 2 }; var numbers = Client.NumbersApi.FindNumbersTollfree(request); @@ -18,6 +18,24 @@ public void FindTollfreeNumbers() Console.WriteLine(numbers); } + [Test] + public void FindTollfreeNumbers() + { + var request = new FindTollfreeNumbersRequest + { + Limit = 2, + Pattern = "84*", + Fields = "items(number)" + }; + var numbers = Client.NumbersApi.FindNumbersTollfree(request); + Assert.AreEqual(2, numbers.Count); + Assert.True(numbers[0].PhoneNumber.Contains("84")); + Assert.True(numbers[1].PhoneNumber.Contains("84")); + Assert.Null(numbers[0].NationalFormat); + Assert.Null(numbers[0].Region); + Console.WriteLine(numbers); + } + [Test] public void FindNumbersLocal() { diff --git a/src/CallfireApiClient.Tests/Api/Contacts/ContactsApiTest.cs b/src/CallfireApiClient.Tests/Api/Contacts/ContactsApiTest.cs index b0eb3f3..4a3376a 100644 --- a/src/CallfireApiClient.Tests/Api/Contacts/ContactsApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Contacts/ContactsApiTest.cs @@ -120,7 +120,7 @@ public void Delete() } [Test] - public void GetObsoleteContactHistory() + public void GetContactHistory() { var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json"); var restRequest = MockRestResponse(expectedJson); @@ -140,50 +140,5 @@ public void GetObsoleteContactHistory() Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("offset") && p.Value.Equals("5"))); } - [Test] - public void GetContactHistoryById() - { - var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json"); - var restRequest = MockRestResponse(expectedJson); - - var contactHistory = Client.ContactsApi.GetHistory(1); - Assert.That(Serializer.Serialize(contactHistory), Is.EqualTo(expectedJson)); - - Assert.AreEqual(Method.GET, restRequest.Value.Method); - var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); - Assert.IsNull(requestBodyParam); - } - - [Test] - public void GetContactHistoryByIdAndLimit() - { - var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json"); - var restRequest = MockRestResponse(expectedJson); - - var contactHistory = Client.ContactsApi.GetHistory(1, 1); - Assert.That(Serializer.Serialize(contactHistory), Is.EqualTo(expectedJson)); - - Assert.AreEqual(Method.GET, restRequest.Value.Method); - var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); - Assert.IsNull(requestBodyParam); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("limit") && p.Value.Equals("1"))); - } - - [Test] - public void GetContactHistoryByAllFilters() - { - var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json"); - var restRequest = MockRestResponse(expectedJson); - - var contactHistory = Client.ContactsApi.GetHistory(1, 1, 5); - Assert.That(Serializer.Serialize(contactHistory), Is.EqualTo(expectedJson)); - - Assert.AreEqual(Method.GET, restRequest.Value.Method); - var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); - Assert.IsNull(requestBodyParam); - 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("offset") && p.Value.Equals("5"))); - } } } \ No newline at end of file diff --git a/src/CallfireApiClient.Tests/Api/Numbers/NumbersApiTest.cs b/src/CallfireApiClient.Tests/Api/Numbers/NumbersApiTest.cs index 73536d3..e7e23bc 100644 --- a/src/CallfireApiClient.Tests/Api/Numbers/NumbersApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Numbers/NumbersApiTest.cs @@ -82,6 +82,26 @@ public void FindNumbersTollfree() Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("offset") && p.Value.Equals("2"))); } + [Test] + public void FindNumbersTollfreeWithPattern() + { + var expectedJson = GetJsonPayload("/numbers/numbersApi/response/findNumbersTollfree.json"); + var restRequest = MockRestResponse(expectedJson); + + var request = new FindTollfreeNumbersRequest + { + Pattern = "86*", + Limit = 1 + }; + var numbers = Client.NumbersApi.FindNumbersTollfree(request); + Assert.That(Serializer.Serialize(new ListHolder(numbers)), Is.EqualTo(expectedJson)); + + Assert.AreEqual(Method.GET, restRequest.Value.Method); + var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); + Assert.IsNull(requestBodyParam); + Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("pattern") && p.Value.Equals("86*"))); + Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("limit") && p.Value.Equals("1"))); + } } } diff --git a/src/CallfireApiClient/Api/Contacts/ContactsApi.cs b/src/CallfireApiClient/Api/Contacts/ContactsApi.cs index 6e8e419..cb8c21d 100644 --- a/src/CallfireApiClient/Api/Contacts/ContactsApi.cs +++ b/src/CallfireApiClient/Api/Contacts/ContactsApi.cs @@ -120,32 +120,11 @@ public void Delete(long id) /// 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. - [Obsolete] public ContactHistory GetHistory(GetByIdRequest request) { String path = CONTACTS_ITEM_HISTORY_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, request.Id.ToString()); return Client.Get(path, request); } - /// - /// Find all texts and calls attributed to a contact. - /// - /// request to get particular contact's history - /// a list of calls and texts a contact has been involved with. - /// 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 ContactHistory GetHistory(long id, long? limit = null, long? offset = null) - { - String path = CONTACTS_ITEM_HISTORY_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()); - var queryParams = new List>(2); - ClientUtils.AddQueryParamIfSet("limit", limit, queryParams); - ClientUtils.AddQueryParamIfSet("offset", offset, queryParams); - return Client.Get(path, queryParams); - } } } \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Numbers/Model/Request/FindTollfreeNumbersRequest.cs b/src/CallfireApiClient/Api/Numbers/Model/Request/FindTollfreeNumbersRequest.cs new file mode 100644 index 0000000..bbc8317 --- /dev/null +++ b/src/CallfireApiClient/Api/Numbers/Model/Request/FindTollfreeNumbersRequest.cs @@ -0,0 +1,32 @@ +using CallfireApiClient.Api.Common.Model; + +namespace CallfireApiClient.Api.Numbers.Model.Request +{ + /// + /// Contains fields for getting tollfree numbers + /// + public class FindTollfreeNumbersRequest : CallfireModel + { + /// + /// Filter toll free numbers by prefix, pattern must be 3 char long and should end with ''. Examples: 8**, 85, 87 (but 855 will fail because pattern must end with ''). + /// + public string Pattern { get; set; } + + /// + /// Get max number of records per page to return. If items.size() less than limit assume no more items. + /// If value not set, default is 100 + /// + /// Get limit fields returned. Example fields=id,items(name,agents(id)) + /// + public string Fields { get; set; } + + + public override string ToString() + { + return string.Format("[FindRequest: Pattern={0}, Limit={1}, Fields={2}]", Pattern, Limit, Fields); + } + } +} \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Numbers/NumbersApi.cs b/src/CallfireApiClient/Api/Numbers/NumbersApi.cs index d617b6c..a996471 100644 --- a/src/CallfireApiClient/Api/Numbers/NumbersApi.cs +++ b/src/CallfireApiClient/Api/Numbers/NumbersApi.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using CallfireApiClient.Api.Numbers.Model; using CallfireApiClient.Api.Numbers.Model.Request; using CallfireApiClient.Api.Common.Model; @@ -71,6 +72,22 @@ public IList FindNumbersTollfree(CommonFindRequest request) return Client.Get>(NUMBERS_TOLLFREE_PATH, request).Items; } + /// + /// Find numbers in the CallFire tollfree numbers catalog that are available for purchase. + /// + /// request object + /// list of numbers + /// 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 FindNumbersTollfree(FindTollfreeNumbersRequest request) + { + return Client.Get>(NUMBERS_TOLLFREE_PATH, request).Items; + } } } diff --git a/src/CallfireApiClient/CallfireApiClient.csproj b/src/CallfireApiClient/CallfireApiClient.csproj index 7c3c6e6..e60c1d6 100644 --- a/src/CallfireApiClient/CallfireApiClient.csproj +++ b/src/CallfireApiClient/CallfireApiClient.csproj @@ -157,6 +157,7 @@ + diff --git a/src/CallfireApiClient/Properties/AssemblyInfo.cs b/src/CallfireApiClient/Properties/AssemblyInfo.cs index 936f9f8..fde4b36 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.12.*")] +[assembly: AssemblyVersion("1.1.13.*")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing.