From 1b76aadb7c100e37fb62a03220093d70d6d2fdca Mon Sep 17 00:00:00 2001 From: vmalinovskiy Date: Thu, 4 May 2017 09:06:17 +0300 Subject: [PATCH 1/2] vmalinovskiy: removed subscriptions api, fixed findWebhooksRequest to use enums, tiny tests fixes --- CallfireApiClient.nuspec | 7 +- Changelog.txt | 5 + .../CallBroadcastsApiIntegrationTest.cs | 4 +- .../TextBroadcastsApiIntegrationTest.cs | 2 +- .../Api/Contacts/DncApiIntegrationTest.cs | 11 ++ .../SubscriptionsApiIntegrationTest.cs | 53 --------- .../CallfireApiClient.IntegrationTests.csproj | 2 +- .../Api/Campaigns/CallBroadcastsApiTest.cs | 2 +- .../Api/Campaigns/TextBroadcastsApiTest.cs | 2 +- .../Api/Webhooks/SubscriptionsApiTest.cs | 110 ----------------- .../Api/Webhooks/WebhooksApiTest.cs | 4 +- .../CallfireApiClient.Tests.csproj | 1 - .../Request/GetBroadcastCallsTextsRequest.cs | 4 +- .../Request/AddContactListContactsRequest.cs | 2 - .../Model/Request/AddContactsRequest.cs | 4 +- .../Api/Webhooks/Model/NotificationFormat.cs | 14 --- .../Model/Request/FindSubscriptionsRequest.cs | 25 ---- .../Model/Request/FindWebhooksRequest.cs | 4 +- .../Api/Webhooks/Model/Subscription.cs | 35 ------ .../Api/Webhooks/Model/TriggerEvent.cs | 17 --- .../Api/Webhooks/SubscriptionsApi.cs | 112 ------------------ .../CallfireApiClient.csproj | 5 - src/CallfireApiClient/CallfireClient.cs | 4 - .../Properties/AssemblyInfo.cs | 2 +- 24 files changed, 38 insertions(+), 393 deletions(-) delete mode 100644 src/CallfireApiClient.IntegrationTests/Api/Webhooks/SubscriptionsApiIntegrationTest.cs delete mode 100644 src/CallfireApiClient.Tests/Api/Webhooks/SubscriptionsApiTest.cs delete mode 100644 src/CallfireApiClient/Api/Webhooks/Model/NotificationFormat.cs delete mode 100644 src/CallfireApiClient/Api/Webhooks/Model/Request/FindSubscriptionsRequest.cs delete mode 100644 src/CallfireApiClient/Api/Webhooks/Model/Subscription.cs delete mode 100644 src/CallfireApiClient/Api/Webhooks/Model/TriggerEvent.cs delete mode 100644 src/CallfireApiClient/Api/Webhooks/SubscriptionsApi.cs diff --git a/CallfireApiClient.nuspec b/CallfireApiClient.nuspec index 3a6d2c0..f0fe84e 100644 --- a/CallfireApiClient.nuspec +++ b/CallfireApiClient.nuspec @@ -1,7 +1,7 @@ CallfireApiClient - 1.1.16 + 1.1.17 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.17 - May 4 2017 +- removed subscriptions api (not supported from v2 api client) +- fixed findWebhooks api to use enums instead strings +- trivial tests fixes + Version 1.1.16 - Mar 28 2017 - fixed DayOfWeek enum for scheduler diff --git a/Changelog.txt b/Changelog.txt index ba34303..28359df 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,10 @@ Callfire API client Changelog ============================= +Version 1.1.17 - May 4 2017 +- removed subscriptions api (not supported from v2 api client) +- fixed findWebhooks api to use enums instead strings +- trivial tests fixes + Version 1.1.16 - Mar 28 2017 - fixed DayOfWeek enum for scheduler diff --git a/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CallBroadcastsApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CallBroadcastsApiIntegrationTest.cs index c28f145..8264614 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CallBroadcastsApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Campaigns/CallBroadcastsApiIntegrationTest.cs @@ -105,7 +105,7 @@ public void StartStopArchiveCampaign() new Recipient { PhoneNumber = "14246525473" } } }; - var id = Client.CallBroadcastsApi.Create(broadcast, true); + var id = Client.CallBroadcastsApi.Create(broadcast, false); CallBroadcast campaign = Client.CallBroadcastsApi.Get(id.Id); System.Console.WriteLine(campaign); @@ -134,7 +134,7 @@ public void GetBroadcastCalls() long testBatchId = (long) calls.Items[0].BatchId; - getCallsRequest = new GetBroadcastCallsTextsRequest { Id = 1, batchId = testBatchId }; + getCallsRequest = new GetBroadcastCallsTextsRequest { Id = 1, BatchId = testBatchId }; calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest); System.Console.WriteLine(calls); Assert.AreEqual(calls.Items[0].BatchId, testBatchId); diff --git a/src/CallfireApiClient.IntegrationTests/Api/Campaigns/TextBroadcastsApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Campaigns/TextBroadcastsApiIntegrationTest.cs index 77c2096..89480de 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Campaigns/TextBroadcastsApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Campaigns/TextBroadcastsApiIntegrationTest.cs @@ -103,7 +103,7 @@ public void GetBroadcastTexts() long testBatchId = (long)texts.Items[0].BatchId; - request = new GetBroadcastCallsTextsRequest { Id = broadcastId.Id, batchId = testBatchId }; + request = new GetBroadcastCallsTextsRequest { Id = broadcastId.Id, BatchId = testBatchId }; texts = Client.TextBroadcastsApi.GetTexts(request); Assert.AreEqual(texts.Items[0].BatchId, testBatchId); } diff --git a/src/CallfireApiClient.IntegrationTests/Api/Contacts/DncApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Contacts/DncApiIntegrationTest.cs index c765cec..5c49ebd 100644 --- a/src/CallfireApiClient.IntegrationTests/Api/Contacts/DncApiIntegrationTest.cs +++ b/src/CallfireApiClient.IntegrationTests/Api/Contacts/DncApiIntegrationTest.cs @@ -14,6 +14,15 @@ public class DncApiIntegrationTest : AbstractIntegrationTest [Test] public void FindDncs() { + CreateDncsRequest crRequest = new CreateDncsRequest() + { + Call = true, + Text = true, + Numbers = new List { "12135551189" }, + Source = "testSourceForGetDncByNumber" + }; + Client.DncApi.Create(crRequest); + var request = new FindDncNumbersRequest() { Text = true, @@ -26,6 +35,8 @@ public void FindDncs() Assert.NotNull(dncs); Assert.AreEqual(dncs.Items.Count, 1); + + Client.DncApi.Delete("12135551189"); } [Test] diff --git a/src/CallfireApiClient.IntegrationTests/Api/Webhooks/SubscriptionsApiIntegrationTest.cs b/src/CallfireApiClient.IntegrationTests/Api/Webhooks/SubscriptionsApiIntegrationTest.cs deleted file mode 100644 index 166294a..0000000 --- a/src/CallfireApiClient.IntegrationTests/Api/Webhooks/SubscriptionsApiIntegrationTest.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using NUnit.Framework; -using CallfireApiClient.Api.Webhooks.Model; -using CallfireApiClient.Api.Webhooks.Model.Request; - -namespace CallfireApiClient.IntegrationTests.Api.Webhooks -{ - [TestFixture] - public class SubscriptionsApiIntegrationTest : AbstractIntegrationTest - { - [Test] - public void CrudOperations() - { - var subscription = new Subscription - { - TriggerEvent = TriggerEvent.CAMPAIGN_FINISHED, - NotificationFormat = NotificationFormat.JSON, - Endpoint = "http://your-site.com/endpoint" - }; - var resourceId1 = Client.SubscriptionsApi.Create(subscription); - Assert.NotNull(resourceId1.Id); - subscription.NotificationFormat = NotificationFormat.SOAP; - var resourceId2 = Client.SubscriptionsApi.Create(subscription); - - var findRequest = new FindSubscriptionsRequest - { - Limit = 30, - Format = NotificationFormat.SOAP, - Fields = "items(id,notificationFormat)" - }; - var page = Client.SubscriptionsApi.Find(findRequest); - Assert.That(page.Items, Has.Count.GreaterThan(0)); - - subscription = page.Items[0]; - Assert.Null(subscription.Endpoint); - Assert.Null(page.Items[0].TriggerEvent); - Assert.NotNull(subscription.Id); - Assert.AreEqual(NotificationFormat.SOAP, page.Items[0].NotificationFormat); - - subscription.Endpoint = subscription.Endpoint + "1"; - Client.SubscriptionsApi.Update(subscription); - var updated = Client.SubscriptionsApi.Get((long)subscription.Id); - Assert.AreEqual(subscription.Endpoint, updated.Endpoint); - - Client.SubscriptionsApi.Delete((long)resourceId1.Id); - Client.SubscriptionsApi.Delete((long)resourceId2.Id); - - Assert.Throws(() => Client.SubscriptionsApi.Get((long)resourceId1.Id)); - Assert.Throws(() => Client.SubscriptionsApi.Get((long)resourceId2.Id)); - } - } -} - diff --git a/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj b/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj index 7009c81..b07329b 100644 --- a/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj +++ b/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj @@ -42,6 +42,7 @@ + @@ -57,7 +58,6 @@ - diff --git a/src/CallfireApiClient.Tests/Api/Campaigns/CallBroadcastsApiTest.cs b/src/CallfireApiClient.Tests/Api/Campaigns/CallBroadcastsApiTest.cs index bdb5d85..f98d186 100644 --- a/src/CallfireApiClient.Tests/Api/Campaigns/CallBroadcastsApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Campaigns/CallBroadcastsApiTest.cs @@ -229,7 +229,7 @@ public void GetCallsWithGetByIdAndBatchIdRequest() Offset = 5, Fields = FIELDS, Id = 11, - batchId = 13 + BatchId = 13 }; var calls = Client.CallBroadcastsApi.GetCalls(request); Assert.That(Serializer.Serialize(calls), Is.EqualTo(expectedJson)); diff --git a/src/CallfireApiClient.Tests/Api/Campaigns/TextBroadcastsApiTest.cs b/src/CallfireApiClient.Tests/Api/Campaigns/TextBroadcastsApiTest.cs index 6717af2..f398a78 100644 --- a/src/CallfireApiClient.Tests/Api/Campaigns/TextBroadcastsApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Campaigns/TextBroadcastsApiTest.cs @@ -168,7 +168,7 @@ public void GetTextsWithGetByIdAndBatchIdRequest() Offset = 5, Fields = FIELDS, Id = 11, - batchId = 13 + BatchId = 13 }; var texts = Client.TextBroadcastsApi.GetTexts(request); Assert.That(Serializer.Serialize(texts), Is.EqualTo(expectedJson)); diff --git a/src/CallfireApiClient.Tests/Api/Webhooks/SubscriptionsApiTest.cs b/src/CallfireApiClient.Tests/Api/Webhooks/SubscriptionsApiTest.cs deleted file mode 100644 index af6f644..0000000 --- a/src/CallfireApiClient.Tests/Api/Webhooks/SubscriptionsApiTest.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using NUnit.Framework; -using CallfireApiClient.Api.Webhooks.Model; -using RestSharp; -using System.Linq; -using CallfireApiClient.Api.Webhooks.Model.Request; - -namespace CallfireApiClient.Tests.Api.Webhooks -{ - [TestFixture] - public class SubscriptionsApiTest : AbstractApiTest - { - [Test] - public void Create() - { - var responseJson = GetJsonPayload("/webhooks/subscriptionsApi/response/createSubscription.json"); - var requestJson = GetJsonPayload("/webhooks/subscriptionsApi/request/createSubscription.json"); - var restRequest = MockRestResponse(responseJson); - - var subscription = new Subscription - { - Enabled = true, - Endpoint = "http://www.example.com/endpoint", - NotificationFormat = NotificationFormat.JSON, - BroadcastId = 14L, - TriggerEvent = TriggerEvent.CAMPAIGN_STARTED - }; - var id = Client.SubscriptionsApi.Create(subscription); - Assert.That(Serializer.Serialize(id), 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 Find() - { - var expectedJson = GetJsonPayload("/webhooks/subscriptionsApi/response/findSubscriptions.json"); - var restRequest = MockRestResponse(expectedJson); - - var request = new FindSubscriptionsRequest - { - Limit = 5, - Offset = 0, - CampaignId = 111, - Format = NotificationFormat.JSON - }; - var webhooks = Client.SubscriptionsApi.Find(request); - Assert.That(Serializer.Serialize(webhooks), 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("5"))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("offset") && p.Value.Equals("0"))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("campaignId") && p.Value.Equals("111"))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("format") && p.Value.Equals("JSON"))); - - } - - [Test] - public void Get() - { - var expectedJson = GetJsonPayload("/webhooks/subscriptionsApi/response/getSubscription.json"); - var restRequest = MockRestResponse(expectedJson); - - var webhook = Client.SubscriptionsApi.Get(11L); - Assert.That(restRequest.Value.Parameters, Has.No.Some.Matches(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS))); - Assert.That(Serializer.Serialize(webhook), Is.EqualTo(expectedJson)); - - Client.SubscriptionsApi.Get(11L, FIELDS); - 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 Update() - { - var expectedJson = GetJsonPayload("/webhooks/subscriptionsApi/request/updateSubscription.json"); - var restRequest = MockRestResponse(expectedJson); - - var subscription = new Subscription - { - Id = 11L, - BroadcastId = 15L, - TriggerEvent = TriggerEvent.CAMPAIGN_FINISHED - }; - Client.SubscriptionsApi.Update(subscription); - - Assert.AreEqual(Method.PUT, restRequest.Value.Method); - var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); - Assert.AreEqual(requestBodyParam.Value, expectedJson); - Assert.That(restRequest.Value.Resource, Is.StringEnding("/11")); - } - - [Test] - public void Delete() - { - var restRequest = MockRestResponse(); - - Client.WebhooksApi.Delete(11L); - - Assert.AreEqual(Method.DELETE, restRequest.Value.Method); - Assert.That(restRequest.Value.Resource, Is.StringEnding("/11")); - } - } -} - diff --git a/src/CallfireApiClient.Tests/Api/Webhooks/WebhooksApiTest.cs b/src/CallfireApiClient.Tests/Api/Webhooks/WebhooksApiTest.cs index 66d9f9f..41d228b 100644 --- a/src/CallfireApiClient.Tests/Api/Webhooks/WebhooksApiTest.cs +++ b/src/CallfireApiClient.Tests/Api/Webhooks/WebhooksApiTest.cs @@ -45,7 +45,7 @@ public void Find() Limit = 5, Offset = 0, Enabled = false, - Resource = "resource" + Resource = ResourceType.TEXT_BROADCAST }; var webhooks = Client.WebhooksApi.Find(request); Assert.That(Serializer.Serialize(webhooks), Is.EqualTo(expectedJson)); @@ -55,7 +55,7 @@ public void Find() Assert.IsNull(requestBodyParam); Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("limit") && p.Value.Equals("5"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("offset") && p.Value.Equals("0"))); - Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("resource") && p.Value.Equals("resource"))); + Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("resource") && p.Value.Equals(ResourceType.TEXT_BROADCAST.ToString()))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches(p => p.Name.Equals("enabled") && p.Value.Equals("False"))); } diff --git a/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj b/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj index d9cb97a..22ad72a 100644 --- a/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj +++ b/src/CallfireApiClient.Tests/CallfireApiClient.Tests.csproj @@ -72,7 +72,6 @@ - diff --git a/src/CallfireApiClient/Api/Campaigns/Model/Request/GetBroadcastCallsTextsRequest.cs b/src/CallfireApiClient/Api/Campaigns/Model/Request/GetBroadcastCallsTextsRequest.cs index dd5dfff..e7e8781 100644 --- a/src/CallfireApiClient/Api/Campaigns/Model/Request/GetBroadcastCallsTextsRequest.cs +++ b/src/CallfireApiClient/Api/Campaigns/Model/Request/GetBroadcastCallsTextsRequest.cs @@ -7,11 +7,11 @@ namespace CallfireApiClient.Api.Common.Model.Request /// public class GetBroadcastCallsTextsRequest : GetByIdRequest { - public long? batchId { get; set; } + public long? BatchId { get; set; } public override string ToString() { - return string.Format("{0} [GetBroadcastCallsTextsRequest: batchId={1}]", base.ToString(), batchId); + return string.Format("{0} [GetBroadcastCallsTextsRequest: batchId={1}]", base.ToString(), BatchId); } } } \ No newline at end of file diff --git a/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactListContactsRequest.cs b/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactListContactsRequest.cs index c4fd0eb..a5765e4 100644 --- a/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactListContactsRequest.cs +++ b/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactListContactsRequest.cs @@ -7,8 +7,6 @@ public class AddContactListContactsRequest : AddContactsRequest [JsonIgnore] public long? ContactListId { get; set; } - public string ContactNumbersField { get; set; } - public override string ToString() { return string.Format("[AddContactListItemsRequest: {0}, ContactListId={1}, ContactNumbersField={2}]", diff --git a/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactsRequest.cs b/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactsRequest.cs index 1e6c562..ae3ac7a 100644 --- a/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactsRequest.cs +++ b/src/CallfireApiClient/Api/Contacts/Model/Request/AddContactsRequest.cs @@ -17,6 +17,8 @@ public class AddContactsRequest : CallfireModel [JsonIgnore] public List Contacts { get; set; } + public string ContactNumbersField { get; set; } + [OnSerializing] private void OnSerializing(StreamingContext context) { @@ -46,7 +48,7 @@ private void OnSerializing(StreamingContext context) public override string ToString() { - return string.Format("[AddContactsRequest: Contacts={0}]", Contacts?.ToPrettyString()); + return string.Format("[AddContactsRequest: Contacts={0}, ContactNumbersField={1}]", Contacts?.ToPrettyString(), ContactNumbersField); } } diff --git a/src/CallfireApiClient/Api/Webhooks/Model/NotificationFormat.cs b/src/CallfireApiClient/Api/Webhooks/Model/NotificationFormat.cs deleted file mode 100644 index 1d7146c..0000000 --- a/src/CallfireApiClient/Api/Webhooks/Model/NotificationFormat.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace CallfireApiClient.Api.Webhooks.Model -{ - public enum NotificationFormat - { - JSON, - XML, - SOAP, - EMAIL, - LEGACY, - } -} - diff --git a/src/CallfireApiClient/Api/Webhooks/Model/Request/FindSubscriptionsRequest.cs b/src/CallfireApiClient/Api/Webhooks/Model/Request/FindSubscriptionsRequest.cs deleted file mode 100644 index 716ba8b..0000000 --- a/src/CallfireApiClient/Api/Webhooks/Model/Request/FindSubscriptionsRequest.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using CallfireApiClient.Api.Common.Model.Request; - -namespace CallfireApiClient.Api.Webhooks.Model.Request -{ - public class FindSubscriptionsRequest : FindRequest - { - public long? CampaignId { get; set; } - - public TriggerEvent? Trigger { get; set; } - - public NotificationFormat? Format { get; set; } - - public string FromNumber { get; set; } - - public string ToNumber { get; set; } - - public override string ToString() - { - return string.Format("[FindSubscriptionsRequest: CampaignId={0}, Trigger={1}, Format={2}, FromNumber={3}, ToNumber={4}]", - CampaignId, Trigger, Format, FromNumber, ToNumber); - } - } -} - diff --git a/src/CallfireApiClient/Api/Webhooks/Model/Request/FindWebhooksRequest.cs b/src/CallfireApiClient/Api/Webhooks/Model/Request/FindWebhooksRequest.cs index 475e6db..6ded051 100644 --- a/src/CallfireApiClient/Api/Webhooks/Model/Request/FindWebhooksRequest.cs +++ b/src/CallfireApiClient/Api/Webhooks/Model/Request/FindWebhooksRequest.cs @@ -7,9 +7,9 @@ public class FindWebhooksRequest : FindRequest { public string Name { get; set; } - public string Resource { get; set; } + public ResourceType? Resource { get; set; } - public string Event { get; set; } + public ResourceEvent? Event { get; set; } public string Callback { get; set; } diff --git a/src/CallfireApiClient/Api/Webhooks/Model/Subscription.cs b/src/CallfireApiClient/Api/Webhooks/Model/Subscription.cs deleted file mode 100644 index 8b2a700..0000000 --- a/src/CallfireApiClient/Api/Webhooks/Model/Subscription.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using CallfireApiClient.Api.Common.Model; - -namespace CallfireApiClient.Api.Webhooks.Model -{ - public class Subscription : CallfireModel - { - public long? Id { get; set; } - - public bool? Enabled { get; set; } - - public string Endpoint { get; set; } - - public bool? NonStrictSsl { get; set; } - - public NotificationFormat? NotificationFormat { get; set; } - - public TriggerEvent? TriggerEvent { get; set; } - - public long? BroadcastId { get; set; } - - public long? BatchId { get; set; } - - public string FromNumber { get; set; } - - public string ToNumber { get; set; } - - public override string ToString() - { - return string.Format("[Subscription: Id={0}, Enabled={1}, Endpoint={2}, NonStrictSsl={3}, NotificationFormat={4}, TriggerEvent={5}, BroadcastId={6}, BatchId={7}, FromNumber={8}, ToNumber={9}]", - Id, Enabled, Endpoint, NonStrictSsl, NotificationFormat, TriggerEvent, BroadcastId, BatchId, FromNumber, ToNumber); - } - } -} - diff --git a/src/CallfireApiClient/Api/Webhooks/Model/TriggerEvent.cs b/src/CallfireApiClient/Api/Webhooks/Model/TriggerEvent.cs deleted file mode 100644 index b6eaf1d..0000000 --- a/src/CallfireApiClient/Api/Webhooks/Model/TriggerEvent.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace CallfireApiClient.Api.Webhooks.Model -{ - public enum TriggerEvent - { - UNDEFINED_EVENT, - INBOUND_CALL_FINISHED, - INBOUND_TEXT_FINISHED, - OUTBOUND_CALL_FINISHED, - OUTBOUND_TEXT_FINISHED, - CAMPAIGN_STARTED, - CAMPAIGN_STOPPED, - CAMPAIGN_FINISHED, - } -} - diff --git a/src/CallfireApiClient/Api/Webhooks/SubscriptionsApi.cs b/src/CallfireApiClient/Api/Webhooks/SubscriptionsApi.cs deleted file mode 100644 index efa8285..0000000 --- a/src/CallfireApiClient/Api/Webhooks/SubscriptionsApi.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using CallfireApiClient.Api.Common.Model; -using CallfireApiClient.Api.Webhooks.Model; -using CallfireApiClient.Api.Webhooks.Model.Request; - -namespace CallfireApiClient.Api.Webhooks -{ - public class SubscriptionsApi - { - private const string SUBSCRIPTIONS_PATH = "/subscriptions"; - private const string SUBSCRIPTIONS_ITEM_PATH = "/subscriptions/{}"; - - private readonly RestApiClient Client; - - internal SubscriptionsApi(RestApiClient client) - { - Client = client; - } - - /// - /// Find all subscriptions for the user. - /// Search for subscriptions on campaign id, resource, event, from number, to number, or whether they are enabled. - /// - /// request object with different fields to filter - /// paged list with subscriptions - /// 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(FindSubscriptionsRequest request) - { - return Client.Get>(SUBSCRIPTIONS_PATH, request); - } - - /// - /// Get subscription by id. - /// - /// id of subscription - /// limit fields returned. Example fields=id,name - /// subscription 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 Subscription Get(long id, string fields = null) - { - var queryParams = ClientUtils.BuildQueryParams("fields", fields); - var path = SUBSCRIPTIONS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()); - return Client.Get(path, queryParams); - } - - /// - /// Create a Subscription for notification in the CallFire system. Use the subscriptions API to receive - /// notifications of important CallFire events. Select the resource to listen to, and then choose - /// the events for that resource to receive notifications on. When an event triggers, - /// a POST will be made to the callback URL with a payload of notification information. - /// - /// subscription to create - /// ResourceId object with id of created subscription - /// 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(Subscription subscription) - { - return Client.Post(SUBSCRIPTIONS_PATH, subscription); - } - - /// - /// Update subscription - /// - /// subscription to update - /// 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 Update(Subscription subscription) - { - string path = SUBSCRIPTIONS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, subscription.Id.ToString()); - Client.Put(path, subscription); - } - - /// - /// Delete subscription by id - /// - /// id of subscription - /// 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(SUBSCRIPTIONS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString())); - } - } -} - diff --git a/src/CallfireApiClient/CallfireApiClient.csproj b/src/CallfireApiClient/CallfireApiClient.csproj index 2dba78b..31ab939 100644 --- a/src/CallfireApiClient/CallfireApiClient.csproj +++ b/src/CallfireApiClient/CallfireApiClient.csproj @@ -188,11 +188,6 @@ - - - - - diff --git a/src/CallfireApiClient/CallfireClient.cs b/src/CallfireApiClient/CallfireClient.cs index 747d7aa..9f0d667 100644 --- a/src/CallfireApiClient/CallfireClient.cs +++ b/src/CallfireApiClient/CallfireClient.cs @@ -41,7 +41,6 @@ public void SetClientConfig(ClientConfig config) readonly Lazy _TextBroadcastsApi; readonly Lazy _CallBroadcastsApi; readonly Lazy _MediaApi; - readonly Lazy _SubscriptionsApi; readonly Lazy _WebhooksApi; public MeApi MeApi { get { return _MeApi.Value; } } @@ -60,8 +59,6 @@ public void SetClientConfig(ClientConfig config) public NumberLeasesApi NumberLeasesApi { get { return _NumberLeasesApi.Value; } } - public SubscriptionsApi SubscriptionsApi { get { return _SubscriptionsApi.Value; } } - public WebhooksApi WebhooksApi { get { return _WebhooksApi.Value; } } public KeywordsApi KeywordsApi { get { return _KeywordsApi.Value; } } @@ -94,7 +91,6 @@ public CallfireClient(string username, string password) _ContactListsApi = new Lazy(() => new ContactListsApi(RestApiClient)); _NumbersApi = new Lazy(() => new NumbersApi(RestApiClient)); _NumberLeasesApi = new Lazy(() => new NumberLeasesApi(RestApiClient)); - _SubscriptionsApi = new Lazy(() => new SubscriptionsApi(RestApiClient)); _WebhooksApi = new Lazy(() => new WebhooksApi(RestApiClient)); _KeywordsApi = new Lazy(() => new KeywordsApi(RestApiClient)); _KeywordLeasesApi = new Lazy(() => new KeywordLeasesApi(RestApiClient)); diff --git a/src/CallfireApiClient/Properties/AssemblyInfo.cs b/src/CallfireApiClient/Properties/AssemblyInfo.cs index 6559c95..daff52e 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.16.*")] +[assembly: AssemblyVersion("1.1.17.*")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. From c4027d90967dd5d5afe3dc3b8d2060093d25b9d2 Mon Sep 17 00:00:00 2001 From: vmalinovskiy Date: Thu, 4 May 2017 09:26:35 +0300 Subject: [PATCH 2/2] vmalinovskiy: removed excess line from proj file --- .../CallfireApiClient.IntegrationTests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj b/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj index b07329b..7ad47ca 100644 --- a/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj +++ b/src/CallfireApiClient.IntegrationTests/CallfireApiClient.IntegrationTests.csproj @@ -42,7 +42,6 @@ -