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
8 changes: 7 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.11</version>
<version>1.1.12</version>
<title>CallFire API v2 client</title>
<authors>
Vladimir Mikhailov
Expand All @@ -15,6 +15,12 @@
<description>C# client library for integration with Callfire REST API v2 services</description>
<releaseNotes>Callfire API client Changelog
=============================
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
- minor extension of requests objects for upload and find sounds api, get contacts history api and find tollfree numbers api
- temporary turning dnc api off due to full remake of callfire dnc apis

Version 1.1.11 - Nov 18 2016
- added deleteCampaignSound api
- added getCreditsHistory api
Expand Down
6 changes: 6 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Callfire API client Changelog
=============================
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
- minor extension of requests objects for upload and find sounds api, get contacts history api and find tollfree numbers api
- temporary turning dnc api off due to full remake of callfire dnc apis

Version 1.1.11 - Nov 18 2016
- added deleteCampaignSound api
- added getCreditsHistory api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public void FindCalls()
States = { StateType.FINISHED, StateType.READY },
IntervalBegin = DateTime.UtcNow.AddMonths(-2),
IntervalEnd = DateTime.UtcNow,
Limit = 3
Limit = 1
};

Page<Call> calls = Client.CallsApi.Find(request);
Console.WriteLine("Calls: " + calls);

Assert.AreEqual(3, calls.Items.Count);
Assert.AreEqual(1, calls.Items.Count);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ public class CampaignSoundsApiIntegrationTest : AbstractIntegrationTest
[Test]
public void TestFind()
{
FindSoundsRequest request = new FindSoundsRequest { Limit = 3, Filter = "sample" };
FindSoundsRequest request = new FindSoundsRequest
{
Limit = 3,
Filter = "sample",
IncludeScrubbed = true,
IncludePending = true,
IncludeArchived = true
};
Page<CampaignSound> campaignSounds = Client.CampaignSoundsApi.Find(request);

Assert.AreEqual(4, campaignSounds.TotalCount);
Expand Down Expand Up @@ -92,11 +99,17 @@ public void TestUploadMp3WavFilesAndGetThem()
pathToSaveNewFile = existingFilePath.Replace("train.wav", "wav_sound.wav");
File.WriteAllBytes(pathToSaveNewFile, ms.ToArray());

CampaignSound mp3Resource = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath, soundName);
CampaignSound mp3Resource = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath, soundName, "id,name,created,lengthInSeconds,status,duplicate");
Assert.True(mp3Resource.Name.Contains("mp3_test"));
Assert.AreEqual(1, mp3Resource.LengthInSeconds);
Assert.True((bool) mp3Resource.Duplicate);

mp3Resource = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath);
Assert.True((bool)mp3Resource.Duplicate);

mp3Resource = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath, soundName);
Assert.True((bool)mp3Resource.Duplicate);

CampaignSound wavResource = Client.CampaignSoundsApi.UploadAndGetSoundDetails(wavFilePath);
Assert.NotNull(wavResource.Id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,19 @@ public void CrudOperations()
[Test]
public void StartStopArchiveCampaign()
{
var campaign = Client.TextBroadcastsApi.Get(8729792003);
var broadcast = new TextBroadcast
{
Name = "text_broadcast",
Message = "test_msg",
Recipients = new List<TextRecipient>
{
new TextRecipient { PhoneNumber = "14246525473" }
}
};

ResourceId id = Client.TextBroadcastsApi.Create(broadcast, false);

var campaign = Client.TextBroadcastsApi.Get(id.Id);
Console.WriteLine(campaign);
Assert.NotNull(campaign);
// start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,27 @@ public void ContactsCRUD()
}

[Test]
public void GetContactHistory()
public void GetObsoleteContactHistory()
{
var request = new GetByIdRequest { Id = 1, Limit = 5 };
var contactHistory = Client.ContactsApi.GetHistory(request);
Assert.AreEqual(2, contactHistory.Calls.Count);

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 @@ -3,63 +3,110 @@
using CallfireApiClient.Api.Contacts.Model;
using CallfireApiClient.Api.Contacts.Model.Request;
using CallfireApiClient.Api.Common.Model;
using System.Collections.Generic;

namespace CallfireApiClient.IntegrationTests.Api.Contacts
{
[TestFixture]
public class DncApiIntegrationTest : AbstractIntegrationTest
{
//TODO vmalinovskiy: uncomment when dnc apis will be tested and available on docs site
/*
[Test]
public void FindDncs()
{
var request = new FindDncContactsRequest();
var request = new FindDncNumbersRequest()
{
Text = true,
Limit = 1,
Numbers = new List<string> { "12135551189" }
};

Page<DoNotContact> dncs = Client.DncApi.Find(request);
Console.WriteLine("Page of credentials:" + dncs);

Assert.NotNull(dncs);
Assert.GreaterOrEqual(dncs.Items.Count, 0);
Assert.AreEqual(dncs.Items.Count, 1);
}

[Test]
public void UpdateDnc()
public void CrudAndGetDnc()
{
long listId = 2021478003;
string number = "13234324554";
string prefix = "13234";

DoNotContact dncToUpdate = new DoNotContact
CreateDncsRequest crRequest = new CreateDncsRequest()
{
ListId = listId,
Text = true,
Call = true,
Number = number
Text = true,
Numbers = new List<string> { "12135551188" },
Source = "testSource"
};
Client.DncApi.Update(dncToUpdate);
Client.DncApi.Create(crRequest);

DoNotContact dnc = Client.DncApi.Get("12135551188");
Assert.AreEqual(dnc.Number, "12135551188");
Assert.AreEqual(dnc.Call, true);
Assert.AreEqual(dnc.Text, true);

var request = new FindDncContactsRequest
UpdateDncRequest updRequest = new UpdateDncRequest()
{
DncListId = listId,
Prefix = prefix,
CallDnc = true,
TextDnc = true,
Limit = 1,
Offset = 0
Call = true,
Text = false,
Number = "12135551188"
};
Page<DoNotContact> dnc = Client.DncApi.Find(request);
Assert.NotNull(dnc);
Assert.AreEqual(dnc.Items.Count, 1);
Assert.AreEqual(dnc.Items[0].ListId, listId);
Assert.AreEqual(dnc.Items[0].Number, number);
Assert.AreEqual(dnc.Items[0].Text, true);
Assert.AreEqual(dnc.Items[0].Call, true);
Client.DncApi.Update(updRequest);

dnc = Client.DncApi.Get("12135551188");
Assert.AreEqual(dnc.Call, true);
Assert.AreEqual(dnc.Text, false);

Client.DncApi.Delete("12135551188");

//get back initial db stage as before test
dncToUpdate.Text = true;
dncToUpdate.Call = true;
Client.DncApi.Update(dncToUpdate);
dnc = Client.DncApi.Get("12135551188");
Assert.AreEqual(dnc.Call, false);
Assert.AreEqual(dnc.Text, false);
}

}
[Test]
public void DeleteDncsFromSource()
{
CreateDncsRequest crRequest = new CreateDncsRequest()
{
Call = true,
Text = true,
Numbers = new List<string> { "12135551189" },
Source = "testSourceForDeleteDncs"
};
Client.DncApi.Create(crRequest);

FindDncNumbersRequest request = new FindDncNumbersRequest()
{
Source = "testSourceForDeleteDncs"
};
Page<DoNotContact> dncContacts = Client.DncApi.Find(request);
Assert.True(dncContacts.Items.Count > 0);

}
Client.DncApi.DeleteDncsFromSource("testSourceForDeleteDncs");

dncContacts = Client.DncApi.Find(request);
Assert.True(dncContacts.Items.Count == 0);
}

[Test]
public void FindUniversalDncs()
{
FindUniversalDncsRequest request = new FindUniversalDncsRequest()
{
ToNumber = "12135551188",
FromNumber = "18442800143"
};

var uDncs = Client.DncApi.FindUniversalDncs(request);
Assert.AreEqual("18442800143", uDncs[0].FromNumber);
Assert.AreEqual("12135551188", uDncs[0].ToNumber);
Assert.NotNull(uDncs[0].InboundCall);
Assert.NotNull(uDncs[0].InboundText);
Assert.NotNull(uDncs[0].OutboundCall);
Assert.NotNull(uDncs[0].OutboundText);
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public void CrudOperations()
Name = "test_name1",
Callback = "test_callback",
Resource = ResourceType.TEXT_BROADCAST,
Events = new HashSet<ResourceEvent> { ResourceEvent.STARTED }
Events = new HashSet<ResourceEvent> { ResourceEvent.STARTED },
SingleUse = true
};
var resourceId1 = api.Create(webhook);
Assert.NotNull(resourceId1.Id);
Expand All @@ -28,7 +29,7 @@ public void CrudOperations()
{
Limit = 30L,
Name = "test_name1",
Fields = "items(id,callback,name,resource,events)"
Fields = "items(id,callback,name,resource,events,singleUse)"
};
var page = api.Find(findRequest);
Assert.That(page.Items.Count > 1);
Expand All @@ -37,12 +38,15 @@ public void CrudOperations()
Assert.AreEqual(ResourceType.TEXT_BROADCAST, page.Items[0].Resource);
Assert.AreEqual(1, page.Items[0].Events.Count);
Assert.NotNull(page.Items[0].Id);
Assert.True(page.Items[0].SingleUse.GetValueOrDefault());

webhook = page.Items[0];
webhook.Name = "test_name2";
webhook.SingleUse = false;
api.Update(webhook);
Webhook updated = api.Get((long)webhook.Id);
Assert.AreEqual(webhook.Resource, updated.Resource);
Assert.False(page.Items[0].SingleUse.GetValueOrDefault());

api.Delete((long)resourceId1.Id);
api.Delete((long)resourceId2.Id);
Expand Down
36 changes: 33 additions & 3 deletions src/CallfireApiClient.Tests/Api/Campaigns/CampaignSoundsApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public void TestFind()
{
Limit = 5,
Offset = 0,
Filter = "1234"
Filter = "1234",
IncludeArchived = true,
IncludePending = true,
IncludeScrubbed = true
};

Page<CampaignSound> sounds = Client.CampaignSoundsApi.Find(request);
Expand All @@ -31,6 +34,9 @@ public void TestFind()
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("5")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("0")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("filter") && p.Value.Equals("1234")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("includeArchived") && p.Value.Equals("True")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("includePending") && p.Value.Equals("True")));
Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("includeScrubbed") && p.Value.Equals("True")));
}

[Test]
Expand Down Expand Up @@ -68,7 +74,6 @@ public void TestGet()

Assert.That(Serializer.Serialize(campaignSound), Is.EqualTo(expectedJson));
Assert.AreEqual(Method.GET, restRequest.Value.Method);
Assert.That(restRequest.Value.Parameters, Has.None.Matches<Parameter>(p => p.Name.Equals("FIELDS") && p.Value.Equals(FIELDS)));
Assert.That(restRequest.Value.Resource, Is.StringEnding("/11"));
}

Expand All @@ -86,7 +91,19 @@ public void TestUpload()
}

[Test]
public void TestUploadAndGetSoundDetails()
public void TestUploadAndGetSoundDetailsWithoutFileName()
{
string expectedJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSoundWithDetails.json");
var restRequest = MockRestResponse(expectedJson);

string mp3FilePath = "Resources/File-examples/train.mp3";
CampaignSound sound = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath);
Assert.That(Serializer.Serialize(sound), Is.EqualTo(expectedJson));
Assert.AreEqual(Method.POST, restRequest.Value.Method);
}

[Test]
public void TestUploadAndGetSoundDetailsWithFileName()
{
string expectedJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSoundWithDetails.json");
var restRequest = MockRestResponse(expectedJson);
Expand All @@ -97,6 +114,19 @@ public void TestUploadAndGetSoundDetails()
Assert.AreEqual(Method.POST, restRequest.Value.Method);
}

[Test]
public void TestUploadAndGetSoundDetailsWithFileNameAndFields()
{
string expectedJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSoundWithDetails.json");
var restRequest = MockRestResponse(expectedJson);

string mp3FilePath = "Resources/File-examples/train.mp3";
CampaignSound sound = Client.CampaignSoundsApi.UploadAndGetSoundDetails(mp3FilePath, "fname", FIELDS);
Assert.That(restRequest.Value.Parameters, Has.None.Matches<Parameter>(p => p.Name.Equals("FIELDS") && p.Value.Equals(FIELDS)));
Assert.That(Serializer.Serialize(sound), Is.EqualTo(expectedJson));
Assert.AreEqual(Method.POST, restRequest.Value.Method);
}

[Test]
public void TestRecordViaPhone()
{
Expand Down
Loading