Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CallfireApiClient.nuspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><package>
<metadata>
<id>CallfireApiClient</id>
<version>1.1.12</version>
<version>1.1.13</version>
<title>CallFire API v2 client</title>
<authors>
Vladimir Mikhailov
Expand All @@ -15,6 +15,9 @@
<description>C# client library for integration with Callfire REST API v2 services</description>
<releaseNotes>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
Expand Down
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
{
Expand Down
47 changes: 1 addition & 46 deletions src/CallfireApiClient.Tests/Api/Contacts/ContactsApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -140,50 +140,5 @@ public void GetObsoleteContactHistory()
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(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<Parameter>(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<Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("1")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("5")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("5")));
}
}
}
20 changes: 20 additions & 0 deletions src/CallfireApiClient.Tests/Api/Numbers/NumbersApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ public void FindNumbersTollfree()
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(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<Number>(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<Parameter>(p => p.Name.Equals("pattern") && p.Value.Equals("86*")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("1")));
}
}
}

21 changes: 0 additions & 21 deletions src/CallfireApiClient/Api/Contacts/ContactsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,32 +120,11 @@ public void Delete(long id)
/// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
/// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception>
/// <exception cref="CallfireClientException"> in case error has occurred in client.</exception>
[Obsolete]
public ContactHistory GetHistory(GetByIdRequest request)
{
String path = CONTACTS_ITEM_HISTORY_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, request.Id.ToString());
return Client.Get<ContactHistory>(path, request);
}

/// <summary>
/// Find all texts and calls attributed to a contact.
/// </summary>
/// <param name="request">request to get particular contact's history</param>
/// <returns>a list of calls and texts a contact has been involved with.</returns>
/// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception>
/// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception>
/// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception>
/// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception>
/// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
/// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception>
/// <exception cref="CallfireClientException"> in case error has occurred in client.</exception>
public 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<KeyValuePair<string, object>>(2);
ClientUtils.AddQueryParamIfSet("limit", limit, queryParams);
ClientUtils.AddQueryParamIfSet("offset", offset, queryParams);
return Client.Get<ContactHistory>(path, queryParams);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using CallfireApiClient.Api.Common.Model;

namespace CallfireApiClient.Api.Numbers.Model.Request
{
/// <summary>
/// Contains fields for getting tollfree numbers
/// </summary>
public class FindTollfreeNumbersRequest : CallfireModel
{
/// <summary>
/// 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 '').
///</summary>
public string Pattern { get; set; }

/// <summary>
/// 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
/// </summary
public long? Limit { get; set; }

/// <summary>
/// Get limit fields returned. Example fields=id,items(name,agents(id))
///</summary>
public string Fields { get; set; }


public override string ToString()
{
return string.Format("[FindRequest: Pattern={0}, Limit={1}, Fields={2}]", Pattern, Limit, Fields);
}
}
}
19 changes: 18 additions & 1 deletion src/CallfireApiClient/Api/Numbers/NumbersApi.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -71,6 +72,22 @@ public IList<Number> FindNumbersTollfree(CommonFindRequest request)
return Client.Get<ListHolder<Number>>(NUMBERS_TOLLFREE_PATH, request).Items;
}

/// <summary>
/// Find numbers in the CallFire tollfree numbers catalog that are available for purchase.
/// </summary>
/// <param name="request">request object</param>
/// <returns>list of numbers</returns>
/// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception>
/// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception>
/// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception>
/// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception>
/// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
/// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception>
/// <exception cref="CallfireClientException"> in case error has occurred in client.</exception>
public IList<Number> FindNumbersTollfree(FindTollfreeNumbersRequest request)
{
return Client.Get<ListHolder<Number>>(NUMBERS_TOLLFREE_PATH, request).Items;
}
}
}

1 change: 1 addition & 0 deletions src/CallfireApiClient/CallfireApiClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<Compile Include="Api\Numbers\Model\Request\FindNumberLeaseConfigsRequest.cs" />
<Compile Include="Api\Numbers\Model\Request\FindNumberLeasesRequest.cs" />
<Compile Include="Api\Numbers\Model\Request\FindNumberRegionsRequest.cs" />
<Compile Include="Api\Numbers\Model\Request\FindTollfreeNumbersRequest.cs" />
<Compile Include="Api\Numbers\Model\Request\FindNumbersLocalRequest.cs" />
<Compile Include="Api\Numbers\Model\Request\NumberPurchaseRequest.cs" />
<Compile Include="Api\Numbers\NumberLeasesApi.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/CallfireApiClient/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down