Skip to content

Commit 37a87f8

Browse files
authored
Merge pull request #42 from CallFire/develop
vmalinovskiy: minor fixes for get contact history api
2 parents 687a75b + 6ee1612 commit 37a87f8

File tree

11 files changed

+100
-84
lines changed

11 files changed

+100
-84
lines changed

CallfireApiClient.nuspec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?><package>
22
<metadata>
33
<id>CallfireApiClient</id>
4-
<version>1.1.12</version>
4+
<version>1.1.13</version>
55
<title>CallFire API v2 client</title>
66
<authors>
77
Vladimir Mikhailov
@@ -15,6 +15,9 @@
1515
<description>C# client library for integration with Callfire REST API v2 services</description>
1616
<releaseNotes>Callfire API client Changelog
1717
=============================
18+
Version 1.1.13 - Dec 30 2016
19+
- minor fixes for get contacts history api
20+
1821
Version 1.1.12 - Dec 28 2016
1922
- updated CallRecord dto to include originateTime, answerTime, duration, callerName and switchId fields
2023
- updated Webhook dto to include singleUse parameter

Changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Callfire API client Changelog
22
=============================
3+
Version 1.1.13 - Dec 30 2016
4+
- minor fixes for get contacts history api
5+
36
Version 1.1.12 - Dec 28 2016
47
- updated CallRecord dto to include originateTime, answerTime, duration, callerName and switchId fields
58
- updated Webhook dto to include singleUse parameter

src/CallfireApiClient.IntegrationTests/Api/Contacts/ContactsApiIntegrationTest.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void ContactsCRUD()
7373
}
7474

7575
[Test]
76-
public void GetObsoleteContactHistory()
76+
public void GetContactHistory()
7777
{
7878
var request = new GetByIdRequest { Id = 1, Limit = 5 };
7979
var contactHistory = Client.ContactsApi.GetHistory(request);
@@ -82,18 +82,6 @@ public void GetObsoleteContactHistory()
8282
Console.WriteLine("ContactHistory:" + contactHistory);
8383
}
8484

85-
[Test]
86-
public void GetContactHistory()
87-
{
88-
var request = new GetByIdRequest { Id = 1, Limit = 5 };
89-
var contactHistory = Client.ContactsApi.GetHistory(1, 0, 0);
90-
Assert.AreEqual(2, contactHistory.Calls.Count);
91-
92-
contactHistory = Client.ContactsApi.GetHistory(1);
93-
Assert.AreEqual(2, contactHistory.Calls.Count);
94-
95-
Console.WriteLine("ContactHistory:" + contactHistory);
96-
}
9785
}
9886
}
9987

src/CallfireApiClient.IntegrationTests/Api/Numbers/NumbersApiIntegrationTest.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace CallfireApiClient.IntegrationTests.Api.Numbers
99
public class NumbersApiIntegrationTest : AbstractIntegrationTest
1010
{
1111
[Test]
12-
public void FindTollfreeNumbers()
12+
public void FindObsoleteTollfreeNumbers()
1313
{
1414
var request = new CommonFindRequest { Limit = 2 };
1515
var numbers = Client.NumbersApi.FindNumbersTollfree(request);
@@ -18,6 +18,24 @@ public void FindTollfreeNumbers()
1818
Console.WriteLine(numbers);
1919
}
2020

21+
[Test]
22+
public void FindTollfreeNumbers()
23+
{
24+
var request = new FindTollfreeNumbersRequest
25+
{
26+
Limit = 2,
27+
Pattern = "84*",
28+
Fields = "items(number)"
29+
};
30+
var numbers = Client.NumbersApi.FindNumbersTollfree(request);
31+
Assert.AreEqual(2, numbers.Count);
32+
Assert.True(numbers[0].PhoneNumber.Contains("84"));
33+
Assert.True(numbers[1].PhoneNumber.Contains("84"));
34+
Assert.Null(numbers[0].NationalFormat);
35+
Assert.Null(numbers[0].Region);
36+
Console.WriteLine(numbers);
37+
}
38+
2139
[Test]
2240
public void FindNumbersLocal()
2341
{

src/CallfireApiClient.Tests/Api/Contacts/ContactsApiTest.cs

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void Delete()
120120
}
121121

122122
[Test]
123-
public void GetObsoleteContactHistory()
123+
public void GetContactHistory()
124124
{
125125
var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json");
126126
var restRequest = MockRestResponse(expectedJson);
@@ -140,50 +140,5 @@ public void GetObsoleteContactHistory()
140140
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("5")));
141141
}
142142

143-
[Test]
144-
public void GetContactHistoryById()
145-
{
146-
var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json");
147-
var restRequest = MockRestResponse(expectedJson);
148-
149-
var contactHistory = Client.ContactsApi.GetHistory(1);
150-
Assert.That(Serializer.Serialize(contactHistory), Is.EqualTo(expectedJson));
151-
152-
Assert.AreEqual(Method.GET, restRequest.Value.Method);
153-
var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
154-
Assert.IsNull(requestBodyParam);
155-
}
156-
157-
[Test]
158-
public void GetContactHistoryByIdAndLimit()
159-
{
160-
var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json");
161-
var restRequest = MockRestResponse(expectedJson);
162-
163-
var contactHistory = Client.ContactsApi.GetHistory(1, 1);
164-
Assert.That(Serializer.Serialize(contactHistory), Is.EqualTo(expectedJson));
165-
166-
Assert.AreEqual(Method.GET, restRequest.Value.Method);
167-
var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
168-
Assert.IsNull(requestBodyParam);
169-
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("1")));
170-
}
171-
172-
[Test]
173-
public void GetContactHistoryByAllFilters()
174-
{
175-
var expectedJson = GetJsonPayload("/contacts/contactsApi/response/getContactHistory.json");
176-
var restRequest = MockRestResponse(expectedJson);
177-
178-
var contactHistory = Client.ContactsApi.GetHistory(1, 1, 5);
179-
Assert.That(Serializer.Serialize(contactHistory), Is.EqualTo(expectedJson));
180-
181-
Assert.AreEqual(Method.GET, restRequest.Value.Method);
182-
var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
183-
Assert.IsNull(requestBodyParam);
184-
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("1")));
185-
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("5")));
186-
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("5")));
187-
}
188143
}
189144
}

src/CallfireApiClient.Tests/Api/Numbers/NumbersApiTest.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ public void FindNumbersTollfree()
8282
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("2")));
8383
}
8484

85+
[Test]
86+
public void FindNumbersTollfreeWithPattern()
87+
{
88+
var expectedJson = GetJsonPayload("/numbers/numbersApi/response/findNumbersTollfree.json");
89+
var restRequest = MockRestResponse(expectedJson);
90+
91+
var request = new FindTollfreeNumbersRequest
92+
{
93+
Pattern = "86*",
94+
Limit = 1
95+
};
96+
var numbers = Client.NumbersApi.FindNumbersTollfree(request);
97+
Assert.That(Serializer.Serialize(new ListHolder<Number>(numbers)), Is.EqualTo(expectedJson));
98+
99+
Assert.AreEqual(Method.GET, restRequest.Value.Method);
100+
var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
101+
Assert.IsNull(requestBodyParam);
102+
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("pattern") && p.Value.Equals("86*")));
103+
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("1")));
104+
}
85105
}
86106
}
87107

src/CallfireApiClient/Api/Contacts/ContactsApi.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,32 +120,11 @@ public void Delete(long id)
120120
/// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
121121
/// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception>
122122
/// <exception cref="CallfireClientException"> in case error has occurred in client.</exception>
123-
[Obsolete]
124123
public ContactHistory GetHistory(GetByIdRequest request)
125124
{
126125
String path = CONTACTS_ITEM_HISTORY_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, request.Id.ToString());
127126
return Client.Get<ContactHistory>(path, request);
128127
}
129128

130-
/// <summary>
131-
/// Find all texts and calls attributed to a contact.
132-
/// </summary>
133-
/// <param name="request">request to get particular contact's history</param>
134-
/// <returns>a list of calls and texts a contact has been involved with.</returns>
135-
/// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception>
136-
/// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception>
137-
/// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception>
138-
/// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception>
139-
/// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
140-
/// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception>
141-
/// <exception cref="CallfireClientException"> in case error has occurred in client.</exception>
142-
public ContactHistory GetHistory(long id, long? limit = null, long? offset = null)
143-
{
144-
String path = CONTACTS_ITEM_HISTORY_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());
145-
var queryParams = new List<KeyValuePair<string, object>>(2);
146-
ClientUtils.AddQueryParamIfSet("limit", limit, queryParams);
147-
ClientUtils.AddQueryParamIfSet("offset", offset, queryParams);
148-
return Client.Get<ContactHistory>(path, queryParams);
149-
}
150129
}
151130
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using CallfireApiClient.Api.Common.Model;
2+
3+
namespace CallfireApiClient.Api.Numbers.Model.Request
4+
{
5+
/// <summary>
6+
/// Contains fields for getting tollfree numbers
7+
/// </summary>
8+
public class FindTollfreeNumbersRequest : CallfireModel
9+
{
10+
/// <summary>
11+
/// 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 '').
12+
///</summary>
13+
public string Pattern { get; set; }
14+
15+
/// <summary>
16+
/// Get max number of records per page to return. If items.size() less than limit assume no more items.
17+
/// If value not set, default is 100
18+
/// </summary
19+
public long? Limit { get; set; }
20+
21+
/// <summary>
22+
/// Get limit fields returned. Example fields=id,items(name,agents(id))
23+
///</summary>
24+
public string Fields { get; set; }
25+
26+
27+
public override string ToString()
28+
{
29+
return string.Format("[FindRequest: Pattern={0}, Limit={1}, Fields={2}]", Pattern, Limit, Fields);
30+
}
31+
}
32+
}

src/CallfireApiClient/Api/Numbers/NumbersApi.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using CallfireApiClient.Api.Numbers.Model;
34
using CallfireApiClient.Api.Numbers.Model.Request;
45
using CallfireApiClient.Api.Common.Model;
@@ -71,6 +72,22 @@ public IList<Number> FindNumbersTollfree(CommonFindRequest request)
7172
return Client.Get<ListHolder<Number>>(NUMBERS_TOLLFREE_PATH, request).Items;
7273
}
7374

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

src/CallfireApiClient/CallfireApiClient.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<Compile Include="Api\Numbers\Model\Request\FindNumberLeaseConfigsRequest.cs" />
158158
<Compile Include="Api\Numbers\Model\Request\FindNumberLeasesRequest.cs" />
159159
<Compile Include="Api\Numbers\Model\Request\FindNumberRegionsRequest.cs" />
160+
<Compile Include="Api\Numbers\Model\Request\FindTollfreeNumbersRequest.cs" />
160161
<Compile Include="Api\Numbers\Model\Request\FindNumbersLocalRequest.cs" />
161162
<Compile Include="Api\Numbers\Model\Request\NumberPurchaseRequest.cs" />
162163
<Compile Include="Api\Numbers\NumberLeasesApi.cs" />

0 commit comments

Comments
 (0)