From 0de7966abd7523c0a7d91a7cec4375827877e4d6 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 21:49:36 +0200 Subject: [PATCH 01/21] Change netcore to 2.2 --- .../GregsStack.PushCrew.Net.Api.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj index 83ac071..be3eca9 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj +++ b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.0 + netcoreapp2.2 false From f20ba9b638ea773a46c45d37571688430ecc2fea Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 21:52:54 +0200 Subject: [PATCH 02/21] Update readme --- PushCrew.Net.sln | 5 ++++- README.md | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/PushCrew.Net.sln b/PushCrew.Net.sln index dbc9c1f..db3e076 100644 --- a/PushCrew.Net.sln +++ b/PushCrew.Net.sln @@ -13,14 +13,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GregsStack.PushCrew.Net.Api EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{45050F49-6359-48E6-B1D1-CBF29026D8D8}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig .gitignore = .gitignore + azure-pipelines.yml = azure-pipelines.yml + GitVersion.yml = GitVersion.yml LICENSE = LICENSE README.md = README.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{130AB2DF-DA26-436C-AEE2-B644473D3AD4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GregsStack.NuGet.Tools", "tools\GregsStack.NuGet.Tools\GregsStack.NuGet.Tools.csproj", "{1597AD92-5743-46A3-9E09-7F91BA6FDC89}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GregsStack.NuGet.Tools", "tools\GregsStack.NuGet.Tools\GregsStack.NuGet.Tools.csproj", "{1597AD92-5743-46A3-9E09-7F91BA6FDC89}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/README.md b/README.md index cdcf1b7..d1320c9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # PushCrew.Net .Net implementation of [PushCrew API](https://api.pushcrew.com) +[![Build Status](https://dev.azure.com/GregsStack/GitHub/_apis/build/status/GregsStack.PushCrew.Net?branchName=master)](https://dev.azure.com/GregsStack/GitHub/_build/latest?definitionId=3&branchName=master) [![codecov](https://codecov.io/gh/GregsStack/PushCrew.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/GregsStack/PushCrew.Net) From d50a85b22e0c79e1d85dff9c0a4e36b4857c45a4 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 22:05:11 +0200 Subject: [PATCH 03/21] Improve pipeline --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4f80d49..dd397fc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -70,7 +70,7 @@ steps: - task: DotNetCoreCLI@2 displayName: 'Pack projects' - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) inputs: command: 'pack' packagesToPack: '$(Solution)' @@ -80,14 +80,14 @@ steps: versionEnvVar: 'GITVERSION_NUGETVERSIONV2' - task: NuGetToolInstaller@1 - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) inputs: versionSpec: '5.1.0' checkLatest: true - task: NuGetCommand@2 displayName: 'Push *.nupkg and *.snupkg to nuget.org' - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) inputs: command: 'push' packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' From e173fe28e945c718cc20c8b30af7951a74021fb9 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 22:16:44 +0200 Subject: [PATCH 04/21] Add altcover to tests --- .../GregsStack.PushCrew.Net.Api.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj index be3eca9..2941103 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj +++ b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj @@ -7,6 +7,7 @@ + From 68d278681d0867c7dcd94881fe1bdfcf87976660 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 22:20:46 +0200 Subject: [PATCH 05/21] Add nuget badge to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d1320c9..7951ab3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # PushCrew.Net .Net implementation of [PushCrew API](https://api.pushcrew.com) + +[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/GregsStack.PushCrew.Net.Api)](https://www.nuget.org/packages/GregsStack.PushCrew.Net.Api) [![Build Status](https://dev.azure.com/GregsStack/GitHub/_apis/build/status/GregsStack.PushCrew.Net?branchName=master)](https://dev.azure.com/GregsStack/GitHub/_build/latest?definitionId=3&branchName=master) [![codecov](https://codecov.io/gh/GregsStack/PushCrew.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/GregsStack/PushCrew.Net) From 973e426bbff93eca78a2c96ab34f58fddf2f924c Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 22:31:40 +0200 Subject: [PATCH 06/21] Resolve codecov dynamically --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dd397fc..e64970a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -65,7 +65,8 @@ steps: - powershell: | $testsDirectory = Join-Path -Path '$(Build.SourcesDirectory)' -ChildPath 'tests' $coverageFile = Get-ChildItem -Path "$testsDirectory" -Recurse -File -Filter 'coverage.xml' | Select-Object -First 1 - & "$ENV:USERPROFILE\.nuget\packages\codecov\1.7.1\tools\codecov.exe" -f "$($coverageFile.FullName)" -t '$(CODECOV_TOKEN)' + $codecovExecutable = Get-ChildItem -Path "$ENV:USERPROFILE\.nuget\packages\codecov" -Recurse -File -Filter "codecov.exe" | Sort-Object -Descending -Property FullName | Select-Object -First 1 + & "$($codecovExecutable.FullName)" -f "$($coverageFile.FullName)" -t '$(CODECOV_TOKEN)' displayName: 'Upload coverage to codecov.io' - task: DotNetCoreCLI@2 From 23a950a2120dd70ba269baea60ca78df48661f7b Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 22:50:04 +0200 Subject: [PATCH 07/21] Add sourcelink --- .../GregsStack.PushCrew.Net.Api.csproj | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj b/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj index 4fc6e7c..edf030c 100644 --- a/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj +++ b/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj @@ -2,10 +2,34 @@ netstandard2.0 + LICENSE + + https://github.com/GregsStack/PushCrew.Net + https://github.com/GregsStack/PushCrew.Net + pushcrew;api-client;api + Gregor Sindl + Copyright © 2019 Gregor Sindl + .Net implementation of PushCrew API (https://api.pushcrew.com) + true + true + true + true + snupkg + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + True + + From 2442c6e35daf9abfe7b44912223a3537841bacd3 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 13 Aug 2019 22:55:29 +0200 Subject: [PATCH 08/21] Prefix github release and tag with 'v' --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e64970a..0045aa7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -104,8 +104,8 @@ steps: action: 'create' target: '$(Build.SourceVersion)' tagSource: 'manual' - tag: '$(Build.BuildNumber)' - title: '$(Build.BuildNumber)' + tag: 'v$(Build.BuildNumber)' + title: 'v$(Build.BuildNumber)' - task: GitHubRelease@0 condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) @@ -115,6 +115,6 @@ steps: action: 'create' target: '$(Build.SourceVersion)' tagSource: 'manual' - tag: '$(Build.BuildNumber)' - title: '$(Build.BuildNumber)' + tag: 'v$(Build.BuildNumber)' + title: 'v$(Build.BuildNumber)' isPreRelease: true \ No newline at end of file From d16f91b52608609f6aff794d4f9150774d50959d Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Sun, 18 Aug 2019 20:42:47 +0200 Subject: [PATCH 09/21] Use IHttpClientFactory --- .../Exceptions/BadRequestException.cs | 19 ++- .../InternalServerErrorException.cs | 18 +- .../Exceptions/PushCrewException.cs | 10 ++ .../Exceptions/UnauthorizedException.cs | 7 + .../Extensions/ServiceCollectionExtension.cs | 23 +++ .../GregsStack.PushCrew.Net.Api.csproj | 1 + .../IPushCrewClient.cs | 27 +++ .../{Client.cs => PushCrewClient.cs} | 158 ++++++++++-------- .../PushCrewConfiguration.cs | 11 ++ .../{ => Response/Models}/DevicePlatform.cs | 2 +- .../{ => Response/Models}/Segment.cs | 2 +- .../{ => Response/Models}/Status.cs | 4 +- .../{ => Response/Models}/Subscriber.cs | 4 +- .../Response/SegmentsResponse.cs | 2 + .../Response/StatusResponse.cs | 4 +- .../Response/SubscribersResponse.cs | 2 + .../GregsStack.PushCrew.Net.Api.Tests.csproj | 1 + .../Sample.cs | 29 ++++ 18 files changed, 245 insertions(+), 79 deletions(-) create mode 100644 src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs create mode 100644 src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs rename src/GregsStack.PushCrew.Net.Api/{Client.cs => PushCrewClient.cs} (52%) create mode 100644 src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs rename src/GregsStack.PushCrew.Net.Api/{ => Response/Models}/DevicePlatform.cs (59%) rename src/GregsStack.PushCrew.Net.Api/{ => Response/Models}/Segment.cs (88%) rename src/GregsStack.PushCrew.Net.Api/{ => Response/Models}/Status.cs (50%) rename src/GregsStack.PushCrew.Net.Api/{ => Response/Models}/Subscriber.cs (95%) create mode 100644 tests/GregsStack.PushCrew.Net.Api.Tests/Sample.cs diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs b/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs index f025e6a..976a4aa 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs +++ b/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs @@ -1,11 +1,28 @@ namespace GregsStack.PushCrew.Net.Api.Exceptions { + using System; using System.Collections.Generic; + using System.Runtime.Serialization; + + using Response.Models; public class BadRequestException : PushCrewException { + /// + public BadRequestException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + var statusString = info.GetString("status"); + if (Enum.TryParse(statusString, true, out Status status)) + { + this.Status = status; + } + + this.InvalidList = (ICollection)(info.GetValue("invalid_list", typeof(ICollection)) ?? new List()); + } + /// - /// To denote whether push request succeeded or not. Values can be or . + /// To denote whether push request succeeded or not. Values can be or . /// public Status Status { get; set; } diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs b/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs index 9a8f712..caf9db8 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs +++ b/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs @@ -1,9 +1,25 @@ namespace GregsStack.PushCrew.Net.Api.Exceptions { + using System; + using System.Runtime.Serialization; + + using Response.Models; + public class InternalServerErrorException : PushCrewException { + /// + public InternalServerErrorException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + var statusString = info.GetString("status"); + if (Enum.TryParse(statusString, true, out Status status)) + { + this.Status = status; + } + } + /// - /// To denote whether push request succeeded or not. Values can be or . + /// To denote whether push request succeeded or not. Values can be or . /// public Status Status { get; set; } } diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs b/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs index 6587cfd..049d024 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs +++ b/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs @@ -1,8 +1,18 @@ namespace GregsStack.PushCrew.Net.Api.Exceptions { using System; + using System.Runtime.Serialization; public class PushCrewException : Exception { + /// Initializes a new instance of the class with serialized data. + /// The that holds the serialized object data about the exception being thrown. + /// The that contains contextual information about the source or destination. + /// The parameter is null. + /// The class name is null or is zero (0). + public PushCrewException(SerializationInfo info, StreamingContext context) + : base(info.GetString("message")) + { + } } } diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/UnauthorizedException.cs b/src/GregsStack.PushCrew.Net.Api/Exceptions/UnauthorizedException.cs index b3ee8d3..3fe3086 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/UnauthorizedException.cs +++ b/src/GregsStack.PushCrew.Net.Api/Exceptions/UnauthorizedException.cs @@ -1,6 +1,13 @@ namespace GregsStack.PushCrew.Net.Api.Exceptions { + using System.Runtime.Serialization; + public class UnauthorizedException : PushCrewException { + /// + public UnauthorizedException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } diff --git a/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs b/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs new file mode 100644 index 0000000..dc68543 --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs @@ -0,0 +1,23 @@ +namespace GregsStack.PushCrew.Net.Api.Extensions +{ + using System; + using System.Net.Http.Headers; + + using Attributes; + + using Microsoft.Extensions.DependencyInjection; + + public static class ServiceCollectionExtension + { + public static IHttpClientBuilder AddPushCrewHttpClient([ValidatedNotNull] this IServiceCollection serviceCollection, [ValidatedNotNull] string apiToken) + { + var validatedServiceCollection = serviceCollection ?? throw new ArgumentNullException(nameof(serviceCollection)); + var validatedApiToken = apiToken ?? throw new ArgumentNullException(nameof(apiToken)); + return validatedServiceCollection.AddHttpClient(PushCrewConfiguration.ClientName, client => + { + client.BaseAddress = PushCrewConfiguration.BaseUri; + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("key", validatedApiToken); + }); + } + } +} diff --git a/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj b/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj index edf030c..111257d 100644 --- a/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj +++ b/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj @@ -19,6 +19,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs b/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs new file mode 100644 index 0000000..e1bb5c9 --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs @@ -0,0 +1,27 @@ +namespace GregsStack.PushCrew.Net.Api +{ + using System.Collections.Generic; + using System.Threading.Tasks; + + using Request; + + using Response; + + public interface IPushCrewClient + { + Task SendAllSubscribersAsync(SendMessageRequest request); + Task SendSubscribersInSegmentAsync(SendMessageRequest request, long segmentId); + Task SendSubscribersAsync(SendMessageRequest request, ICollection subscriberList); + Task SendSubscriberAsync(SendMessageRequest request, string subscriberId); + Task CheckNotificationRequestStatusAsync(string id); + Task ScheduleAllSubscribersAsync(ScheduleMessageRequest request); + Task ScheduleSegmentAsync(ScheduleMessageRequest request, string segmentId); + Task AddSegmentAsync(string name); + Task ListSegmentsAsync(); + Task AddSubscribersToSegmentAsync(string segmentId, ICollection subscriberList); + Task ListSubscribersInSegmentAsync(string segmentId, int page = 1, int perPage = 1024); + Task ListSegmentsOfSubscriberAsync(string subscriberId); + Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest removeSubscriberRequest); + Task DeleteSegmentAsync(long segmentId); + } +} diff --git a/src/GregsStack.PushCrew.Net.Api/Client.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs similarity index 52% rename from src/GregsStack.PushCrew.Net.Api/Client.cs rename to src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs index 2956a44..36d2bcf 100644 --- a/src/GregsStack.PushCrew.Net.Api/Client.cs +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs @@ -5,7 +5,6 @@ using System.Net; using System.Net.Http; using System.Net.Http.Formatting; - using System.Net.Http.Headers; using System.Threading.Tasks; using Converters; @@ -20,24 +19,14 @@ using Response; - public class Client : IDisposable + public class PushCrewClient : IPushCrewClient { - private readonly HttpClient client; + private readonly IHttpClientFactory clientFactory; private readonly JsonMediaTypeFormatter jsonFormatter; - private readonly Uri baseUri; - public Client(string token) - : this(token, new Uri("https://pushcrew.com/api/v1/")) + public PushCrewClient(IHttpClientFactory httpClientFactory) { - } - - public Client(string token, Uri baseUri) - { - var apiToken = token ?? throw new ArgumentNullException(nameof(token)); - this.client = new HttpClient(); - this.client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("key", apiToken); - - this.baseUri = baseUri ?? throw new ArgumentNullException(nameof(baseUri)); + this.clientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); var contractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() }; this.jsonFormatter = new JsonMediaTypeFormatter @@ -52,21 +41,21 @@ public Client(string token, Uri baseUri) this.jsonFormatter.SerializerSettings.Converters.Add(new BooleanConverter()); } - public async Task SendAllSubscribers(SendMessageRequest request) + public async Task SendAllSubscribersAsync(SendMessageRequest request) { - var uri = new Uri(this.baseUri, "send/all"); - return await this.PostAsync(request, uri); + const string relativeUri = "send/all"; + return await this.PostAsync(request, relativeUri); } - public async Task SendSubscribersInSegment(SendMessageRequest request, long segmentId) + public async Task SendSubscribersInSegmentAsync(SendMessageRequest request, long segmentId) { - var uri = new Uri(this.baseUri, $"send/segment/{segmentId}"); - return await this.PostAsync(request, uri); + var relativeUri = $"send/segment/{segmentId}"; + return await this.PostAsync(request, relativeUri); } - public async Task SendSubscribers(SendMessageRequest request, ICollection subscriberList) + public async Task SendSubscribersAsync(SendMessageRequest request, ICollection subscriberList) { - var uri = new Uri(this.baseUri, "send/list"); + const string relativeUri = "send/list"; var validRequest = request ?? throw new ArgumentNullException(nameof(request)); var validSubscriberList = subscriberList ?? throw new ArgumentNullException(nameof(subscriberList)); @@ -74,55 +63,55 @@ public async Task SendSubscribers(SendMessageRequest reques var subscriberRequest = (SendMessageSubscribersRequest)validRequest; subscriberRequest.SubscriberList = JsonConvert.SerializeObject(subscribers); - return await this.PostAsync(subscriberRequest, uri); + return await this.PostAsync(subscriberRequest, relativeUri); } - public async Task SendSubscriber(SendMessageRequest request, string subscriberId) + public async Task SendSubscriberAsync(SendMessageRequest request, string subscriberId) { - var uri = new Uri(this.baseUri, "send/individual"); + const string relativeUri = "send/individual"; var validRequest = request ?? throw new ArgumentNullException(nameof(request)); var validSubscriberId = subscriberId ?? throw new ArgumentNullException(nameof(subscriberId)); var subscriberRequest = (SendMessageSubscriberRequest)validRequest; subscriberRequest.SubscriberId = validSubscriberId; - return await this.PostAsync(subscriberRequest, uri); + return await this.PostAsync(subscriberRequest, relativeUri); } - public async Task CheckNotificationRequestStatus(string id) + public async Task CheckNotificationRequestStatusAsync(string id) { - var uri = new Uri(this.baseUri, $"checkstatus/{id}"); - return await this.GetAsync(uri); + var relativeUri = $"checkstatus/{id}"; + return await this.GetAsync(relativeUri); } - public async Task ScheduleAllSubscribers(ScheduleMessageRequest request) + public async Task ScheduleAllSubscribersAsync(ScheduleMessageRequest request) { - var uri = new Uri(this.baseUri, "send/all"); - return await this.PostAsync(request, uri); + const string relativeUri = "send/all"; + return await this.PostAsync(request, relativeUri); } - public async Task ScheduleSegment(ScheduleMessageRequest request, string segmentId) + public async Task ScheduleSegmentAsync(ScheduleMessageRequest request, string segmentId) { - var uri = new Uri(this.baseUri, $"send/segment/{segmentId}"); - return await this.PostAsync(request, uri); + var relativeUri = $"send/segment/{segmentId}"; + return await this.PostAsync(request, relativeUri); } - public async Task AddSegment(string name) + public async Task AddSegmentAsync(string name) { - var uri = new Uri(this.baseUri, "segments"); + const string relativeUri = "segments"; var dict = new Dictionary { { "name", name } }; - return await this.PostAsync, SegmentResponse>(dict, uri); + return await this.PostAsync, SegmentResponse>(dict, relativeUri); } - public async Task ListSegments() + public async Task ListSegmentsAsync() { - var uri = new Uri(this.baseUri, "segments"); - return await this.GetAsync(uri); + const string relativeUri = "segments"; + return await this.GetAsync(relativeUri); } - public async Task AddSubscribersToSegment(string segmentId, ICollection subscriberList) + public async Task AddSubscribersToSegmentAsync(string segmentId, ICollection subscriberList) { - var uri = new Uri(this.baseUri, $"segments/{segmentId}/subscribers"); + var relativeUri = $"segments/{segmentId}/subscribers"; var validSubscriberList = subscriberList ?? throw new ArgumentNullException(nameof(subscriberList)); var subscribers = new Dictionary> { { "subscriber_list", validSubscriberList } }; @@ -131,57 +120,82 @@ public async Task AddSubscribersToSegment(string segmentId, ICo SubscriberList = JsonConvert.SerializeObject(subscribers) }; - return await this.PostAsync(subscriberRequest, uri); + return await this.PostAsync(subscriberRequest, relativeUri); } - public async Task ListSubscribersInSegment(string segmentId, int page = 1, int perPage = 1024) + public async Task ListSubscribersInSegmentAsync(string segmentId, int page = 1, int perPage = 1024) { - var uri = new Uri(this.baseUri, $"segments/{segmentId}/subscribers?page={page}&per_page={perPage}"); - return await this.GetAsync(uri); + var relativeUri = $"segments/{segmentId}/subscribers?page={page}&per_page={perPage}"; + return await this.GetAsync(relativeUri); } - public async Task ListSegmentsOfSubscriber(string subscriberId) + public async Task ListSegmentsOfSubscriberAsync(string subscriberId) { - var uri = new Uri(this.baseUri, $"subscribers/{subscriberId}/segments"); - return await this.GetAsync(uri); + var relativeUri = $"subscribers/{subscriberId}/segments"; + return await this.GetAsync(relativeUri); } - public async Task RemoveSubscribers(long segmentId, RemoveSubscriberRequest removeSubscriberRequest) + public async Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest removeSubscriberRequest) { - var uri = new Uri(this.baseUri, $"segments/{segmentId}/subscribers"); - var response = await this.client.PutAsync(uri, removeSubscriberRequest, this.jsonFormatter); - await this.VerifyResponse(response); - return await this.ReadAsAsync(response); + var relativeUri = $"segments/{segmentId}/subscribers"; + return await this.PutAsync(removeSubscriberRequest, relativeUri); } - public async Task DeleteSegment(long segmentId) + public async Task DeleteSegmentAsync(long segmentId) + { + var relativeUri = $"segments/{segmentId}"; + return await this.DeleteAsync(relativeUri); + } + + private HttpClient CreateClient() + { + return this.clientFactory.CreateClient(PushCrewConfiguration.ClientName); + } + + private async Task DeleteAsync(string requestUri) + where TResponse : class { - var uri = new Uri(this.baseUri, $"segments/{segmentId}"); - var response = await this.client.DeleteAsync(uri); - await this.VerifyResponse(response); - return await this.ReadAsAsync(response); + var client = this.CreateClient(); + using (var response = await client.DeleteAsync(requestUri)) + { + await this.VerifyResponse(response); + return await this.ReadAsAsync(response); + } } - public void Dispose() + private async Task GetAsync(string requestUri) + where TResponse : class { - this.client?.Dispose(); + var client = this.CreateClient(); + using (var response = await client.GetAsync(requestUri)) + { + await this.VerifyResponse(response); + return await this.ReadAsAsync(response); + } } - private async Task PostAsync(TRequest request, Uri uri) + private async Task PostAsync(TRequest request, string requestUri) where TRequest : class where TResponse : class { - var response = await this.client.PostAsync(uri, request.ToFormUrlEncodedContent()); - await this.VerifyResponse(response); - return await this.ReadAsAsync(response); + var client = this.CreateClient(); + using (var response = await client.PostAsync(requestUri, request.ToFormUrlEncodedContent())) + { + await this.VerifyResponse(response); + return await this.ReadAsAsync(response); + } } - private async Task GetAsync(Uri uri) + private async Task PutAsync(TRequest request, string requestUri) + where TRequest : class where TResponse : class { - var response = await this.client.GetAsync(uri); - await this.VerifyResponse(response); - return await this.ReadAsAsync(response); + var client = this.CreateClient(); + using (var response = await client.PutAsync(requestUri, request, this.jsonFormatter)) + { + await this.VerifyResponse(response); + return await this.ReadAsAsync(response); + } } private async Task VerifyResponse(HttpResponseMessage response) @@ -206,6 +220,8 @@ private async Task VerifyResponse(HttpResponseMessage response) throw exception; } } + + response.EnsureSuccessStatusCode(); } private async Task ReadAsAsync(HttpResponseMessage response) diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs new file mode 100644 index 0000000..14236ce --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs @@ -0,0 +1,11 @@ +namespace GregsStack.PushCrew.Net.Api +{ + using System; + + public static class PushCrewConfiguration + { + public static readonly string ClientName = nameof(PushCrewClient); + + public static readonly Uri BaseUri = new Uri("https://pushcrew.com/api/v1/"); + } +} diff --git a/src/GregsStack.PushCrew.Net.Api/DevicePlatform.cs b/src/GregsStack.PushCrew.Net.Api/Response/Models/DevicePlatform.cs similarity index 59% rename from src/GregsStack.PushCrew.Net.Api/DevicePlatform.cs rename to src/GregsStack.PushCrew.Net.Api/Response/Models/DevicePlatform.cs index 883b761..25ac132 100644 --- a/src/GregsStack.PushCrew.Net.Api/DevicePlatform.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/Models/DevicePlatform.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.PushCrew.Net.Api.Response.Models { public enum DevicePlatform { diff --git a/src/GregsStack.PushCrew.Net.Api/Segment.cs b/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs similarity index 88% rename from src/GregsStack.PushCrew.Net.Api/Segment.cs rename to src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs index a089af4..ba47b63 100644 --- a/src/GregsStack.PushCrew.Net.Api/Segment.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.PushCrew.Net.Api.Response.Models { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Status.cs b/src/GregsStack.PushCrew.Net.Api/Response/Models/Status.cs similarity index 50% rename from src/GregsStack.PushCrew.Net.Api/Status.cs rename to src/GregsStack.PushCrew.Net.Api/Response/Models/Status.cs index c46a476..745e301 100644 --- a/src/GregsStack.PushCrew.Net.Api/Status.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/Models/Status.cs @@ -1,7 +1,9 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.PushCrew.Net.Api.Response.Models { public enum Status { + Unknown, + Success, Failure diff --git a/src/GregsStack.PushCrew.Net.Api/Subscriber.cs b/src/GregsStack.PushCrew.Net.Api/Response/Models/Subscriber.cs similarity index 95% rename from src/GregsStack.PushCrew.Net.Api/Subscriber.cs rename to src/GregsStack.PushCrew.Net.Api/Response/Models/Subscriber.cs index c869d17..7ebf594 100644 --- a/src/GregsStack.PushCrew.Net.Api/Subscriber.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/Models/Subscriber.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.PushCrew.Net.Api.Response.Models { using System; using System.Net; @@ -37,7 +37,7 @@ public class Subscriber public string Platform { get; set; } /// - /// Value can be / . + /// Value can be / . /// Depending upon the device from which the subscriber subscribed. /// public DevicePlatform DevicePlatform { get; set; } diff --git a/src/GregsStack.PushCrew.Net.Api/Response/SegmentsResponse.cs b/src/GregsStack.PushCrew.Net.Api/Response/SegmentsResponse.cs index 1b8c618..02842d2 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/SegmentsResponse.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/SegmentsResponse.cs @@ -2,6 +2,8 @@ namespace GregsStack.PushCrew.Net.Api.Response { using System.Collections.Generic; + using Models; + public class SegmentsResponse : StatusResponse { /// diff --git a/src/GregsStack.PushCrew.Net.Api/Response/StatusResponse.cs b/src/GregsStack.PushCrew.Net.Api/Response/StatusResponse.cs index b77a959..1ae1115 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/StatusResponse.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/StatusResponse.cs @@ -1,9 +1,11 @@ namespace GregsStack.PushCrew.Net.Api.Response { + using Models; + public class StatusResponse { /// - /// To denote whether push request succeeded or not. Values can be or . + /// To denote whether push request succeeded or not. Values can be or . /// public Status Status { get; set; } } diff --git a/src/GregsStack.PushCrew.Net.Api/Response/SubscribersResponse.cs b/src/GregsStack.PushCrew.Net.Api/Response/SubscribersResponse.cs index b4b93e7..44b5631 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/SubscribersResponse.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/SubscribersResponse.cs @@ -3,6 +3,8 @@ namespace GregsStack.PushCrew.Net.Api.Response using System; using System.Collections.Generic; + using Models; + public class SubscribersResponse : StatusResponse { /// diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj index 2941103..630de40 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj +++ b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj @@ -8,6 +8,7 @@ + diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/Sample.cs b/tests/GregsStack.PushCrew.Net.Api.Tests/Sample.cs new file mode 100644 index 0000000..f28c84f --- /dev/null +++ b/tests/GregsStack.PushCrew.Net.Api.Tests/Sample.cs @@ -0,0 +1,29 @@ +namespace GregsStack.PushCrew.Net.Api.Tests +{ + using System.Threading.Tasks; + + using Exceptions; + + using Extensions; + + using Microsoft.Extensions.DependencyInjection; + + using Xunit; + + public class Sample + { + [Fact] + public async Task AnyMethod_BadToken_ThrowsUnauthorizedException() + { + var di = new ServiceCollection(); + + di.AddPushCrewHttpClient("BadToken"); + di.AddTransient(); + + var serviceProvider = di.BuildServiceProvider(); + + var client = serviceProvider.GetRequiredService(); + await Assert.ThrowsAsync(() => client.DeleteSegmentAsync(123)); + } + } +} From c14b47e9c94ec150f4312f709591bf534e99066d Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Sun, 18 Aug 2019 21:18:02 +0200 Subject: [PATCH 10/21] Use correct authorization header --- .../Extensions/ServiceCollectionExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs b/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs index dc68543..f1acdec 100644 --- a/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs +++ b/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs @@ -16,7 +16,7 @@ public static IHttpClientBuilder AddPushCrewHttpClient([ValidatedNotNull] this I return validatedServiceCollection.AddHttpClient(PushCrewConfiguration.ClientName, client => { client.BaseAddress = PushCrewConfiguration.BaseUri; - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("key", validatedApiToken); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(validatedApiToken); }); } } From 00c281ec7e1debe3782bdeb01ef18b847ad6e812 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Sun, 18 Aug 2019 21:19:04 +0200 Subject: [PATCH 11/21] Change segmentId signature to long --- src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs | 6 +++--- src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs | 6 +++--- src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs | 4 ++-- src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs b/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs index e1bb5c9..a0bc260 100644 --- a/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs +++ b/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs @@ -15,11 +15,11 @@ public interface IPushCrewClient Task SendSubscriberAsync(SendMessageRequest request, string subscriberId); Task CheckNotificationRequestStatusAsync(string id); Task ScheduleAllSubscribersAsync(ScheduleMessageRequest request); - Task ScheduleSegmentAsync(ScheduleMessageRequest request, string segmentId); + Task ScheduleSegmentAsync(ScheduleMessageRequest request, long segmentId); Task AddSegmentAsync(string name); Task ListSegmentsAsync(); - Task AddSubscribersToSegmentAsync(string segmentId, ICollection subscriberList); - Task ListSubscribersInSegmentAsync(string segmentId, int page = 1, int perPage = 1024); + Task AddSubscribersToSegmentAsync(long segmentId, ICollection subscriberList); + Task ListSubscribersInSegmentAsync(long segmentId, int page = 1, int perPage = 1024); Task ListSegmentsOfSubscriberAsync(string subscriberId); Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest removeSubscriberRequest); Task DeleteSegmentAsync(long segmentId); diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs index 36d2bcf..de79d8c 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs @@ -90,7 +90,7 @@ public async Task ScheduleAllSubscribersAsync(ScheduleM return await this.PostAsync(request, relativeUri); } - public async Task ScheduleSegmentAsync(ScheduleMessageRequest request, string segmentId) + public async Task ScheduleSegmentAsync(ScheduleMessageRequest request, long segmentId) { var relativeUri = $"send/segment/{segmentId}"; return await this.PostAsync(request, relativeUri); @@ -109,7 +109,7 @@ public async Task ListSegmentsAsync() return await this.GetAsync(relativeUri); } - public async Task AddSubscribersToSegmentAsync(string segmentId, ICollection subscriberList) + public async Task AddSubscribersToSegmentAsync(long segmentId, ICollection subscriberList) { var relativeUri = $"segments/{segmentId}/subscribers"; @@ -123,7 +123,7 @@ public async Task AddSubscribersToSegmentAsync(string segmentId return await this.PostAsync(subscriberRequest, relativeUri); } - public async Task ListSubscribersInSegmentAsync(string segmentId, int page = 1, int perPage = 1024) + public async Task ListSubscribersInSegmentAsync(long segmentId, int page = 1, int perPage = 1024) { var relativeUri = $"segments/{segmentId}/subscribers?page={page}&per_page={perPage}"; return await this.GetAsync(relativeUri); diff --git a/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs b/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs index ba47b63..5f63032 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs @@ -4,11 +4,11 @@ namespace GregsStack.PushCrew.Net.Api.Response.Models public class Segment { - public string Id { get; set; } + public long Id { get; set; } public string Name { get; set; } - public Segment(string id, string name) + public Segment(long id, string name) { this.Id = id; this.Name = name ?? throw new ArgumentNullException(nameof(name)); diff --git a/src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs b/src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs index b7dd1ca..2889356 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs +++ b/src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs @@ -6,7 +6,7 @@ public class SegmentResponse : StatusResponse /// To identify the segment newly created. /// The same ID is used to add/remove subscribers to/from the segment through the API. /// - public string SegmentId { get; set; } + public long SegmentId { get; set; } /// /// Present in case of failure. Used to denote reason of failure. From 1a0faa44f94860fd4bef5c5597f91f4e2c44c479 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Sun, 18 Aug 2019 22:42:42 +0200 Subject: [PATCH 12/21] Handle SerializationException of SerializationInfo --- .../Exceptions/BadRequestException.cs | 6 +++-- .../InternalServerErrorException.cs | 4 ++- .../Exceptions/PushCrewException.cs | 4 ++- .../Extensions/SerializationInfoExtension.cs | 27 +++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/GregsStack.PushCrew.Net.Api/Extensions/SerializationInfoExtension.cs diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs b/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs index 976a4aa..1356b46 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs +++ b/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using System.Runtime.Serialization; + using Extensions; + using Response.Models; public class BadRequestException : PushCrewException @@ -12,13 +14,13 @@ public class BadRequestException : PushCrewException public BadRequestException(SerializationInfo info, StreamingContext context) : base(info, context) { - var statusString = info.GetString("status"); + var statusString = info.GetSafeString("status"); if (Enum.TryParse(statusString, true, out Status status)) { this.Status = status; } - this.InvalidList = (ICollection)(info.GetValue("invalid_list", typeof(ICollection)) ?? new List()); + this.InvalidList = info.GetSafeValue("invalid_list", new List()); } /// diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs b/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs index caf9db8..aa404b9 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs +++ b/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs @@ -3,6 +3,8 @@ using System; using System.Runtime.Serialization; + using Extensions; + using Response.Models; public class InternalServerErrorException : PushCrewException @@ -11,7 +13,7 @@ public class InternalServerErrorException : PushCrewException public InternalServerErrorException(SerializationInfo info, StreamingContext context) : base(info, context) { - var statusString = info.GetString("status"); + var statusString = info.GetSafeString("status"); if (Enum.TryParse(statusString, true, out Status status)) { this.Status = status; diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs b/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs index 049d024..0ecf5cf 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs +++ b/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs @@ -3,6 +3,8 @@ using System; using System.Runtime.Serialization; + using Extensions; + public class PushCrewException : Exception { /// Initializes a new instance of the class with serialized data. @@ -11,7 +13,7 @@ public class PushCrewException : Exception /// The parameter is null. /// The class name is null or is zero (0). public PushCrewException(SerializationInfo info, StreamingContext context) - : base(info.GetString("message")) + : base(info.GetSafeString("message") ?? info.GetSafeString("error")) { } } diff --git a/src/GregsStack.PushCrew.Net.Api/Extensions/SerializationInfoExtension.cs b/src/GregsStack.PushCrew.Net.Api/Extensions/SerializationInfoExtension.cs new file mode 100644 index 0000000..f484bf2 --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/Extensions/SerializationInfoExtension.cs @@ -0,0 +1,27 @@ +namespace GregsStack.PushCrew.Net.Api.Extensions +{ + using System; + using System.Runtime.Serialization; + + using Attributes; + + public static class SerializationInfoExtension + { + public static T GetSafeValue([ValidatedNotNull] this SerializationInfo info, [ValidatedNotNull] string name, T defaultValue = default) + { + var serializationInfo = info ?? throw new ArgumentNullException(nameof(info)); + var elementName = name ?? throw new ArgumentNullException(nameof(name)); + + try + { + return (T)serializationInfo.GetValue(elementName, typeof(T)); + } + catch (SerializationException) + { + return defaultValue; + } + } + + public static string GetSafeString([ValidatedNotNull] this SerializationInfo info, [ValidatedNotNull] string name, string defaultValue = default) => info.GetSafeValue(name, defaultValue); + } +} From d08b56413c13ca9c5386c91a932559418c91f1af Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Sun, 18 Aug 2019 22:48:15 +0200 Subject: [PATCH 13/21] Update Codecov --- tools/GregsStack.NuGet.Tools/GregsStack.NuGet.Tools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/GregsStack.NuGet.Tools/GregsStack.NuGet.Tools.csproj b/tools/GregsStack.NuGet.Tools/GregsStack.NuGet.Tools.csproj index 6fabe92..4293885 100644 --- a/tools/GregsStack.NuGet.Tools/GregsStack.NuGet.Tools.csproj +++ b/tools/GregsStack.NuGet.Tools/GregsStack.NuGet.Tools.csproj @@ -6,7 +6,7 @@ - + From 0ed62c1f442ee4ba4d85ec7f84cbaaebbb8be5c9 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 20 Aug 2019 20:48:09 +0200 Subject: [PATCH 14/21] Use props instead of fields --- src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs index 14236ce..0c6ac39 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs @@ -4,8 +4,8 @@ public static class PushCrewConfiguration { - public static readonly string ClientName = nameof(PushCrewClient); + public static string ClientName { get; } = nameof(PushCrewClient); - public static readonly Uri BaseUri = new Uri("https://pushcrew.com/api/v1/"); + public static Uri BaseUri { get; } = new Uri("https://pushcrew.com/api/v1/"); } } From 68dffc72ee3372b6cdceabfced28e54bce6e6003 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 20 Aug 2019 21:29:24 +0200 Subject: [PATCH 15/21] Split PushCrewClient --- .../PushCrewClient.CheckStatus.cs | 15 +++ .../PushCrewClient.Segments.cs | 60 +++++++++ .../PushCrewClient.Send.cs | 66 ++++++++++ .../PushCrewClient.Subscribers.cs | 15 +++ .../PushCrewClient.cs | 114 +----------------- 5 files changed, 157 insertions(+), 113 deletions(-) create mode 100644 src/GregsStack.PushCrew.Net.Api/PushCrewClient.CheckStatus.cs create mode 100644 src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs create mode 100644 src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs create mode 100644 src/GregsStack.PushCrew.Net.Api/PushCrewClient.Subscribers.cs diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.CheckStatus.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.CheckStatus.cs new file mode 100644 index 0000000..5ba28ba --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.CheckStatus.cs @@ -0,0 +1,15 @@ +namespace GregsStack.PushCrew.Net.Api +{ + using System.Threading.Tasks; + + using Response; + + public partial class PushCrewClient + { + public async Task CheckNotificationRequestStatusAsync(string id) + { + var relativeUri = $"checkstatus/{id}"; + return await this.GetAsync(relativeUri); + } + } +} diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs new file mode 100644 index 0000000..2a98b45 --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs @@ -0,0 +1,60 @@ +namespace GregsStack.PushCrew.Net.Api +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + + using Newtonsoft.Json; + + using Request; + + using Response; + + public partial class PushCrewClient + { + private const string SegmentsRelativeUri = "segments"; + + public async Task AddSegmentAsync(string name) + { + var dict = new Dictionary { { "name", name } }; + return await this.PostAsync, SegmentResponse>(dict, SegmentsRelativeUri); + } + + public async Task ListSegmentsAsync() + { + return await this.GetAsync(SegmentsRelativeUri); + } + + public async Task AddSubscribersToSegmentAsync(long segmentId, ICollection subscriberList) + { + var relativeUri = $"{SegmentsRelativeUri}/{segmentId}/subscribers"; + + var validSubscriberList = subscriberList ?? throw new ArgumentNullException(nameof(subscriberList)); + var subscribers = new Dictionary> { { "subscriber_list", validSubscriberList } }; + var subscriberRequest = new SendMessageSubscribersRequest + { + SubscriberList = JsonConvert.SerializeObject(subscribers) + }; + + return await this.PostAsync(subscriberRequest, relativeUri); + } + + public async Task ListSubscribersInSegmentAsync(long segmentId, int page = 1, int perPage = 1024) + { + var relativeUri = $"{SegmentsRelativeUri}/{segmentId}/subscribers?page={page}&per_page={perPage}"; + return await this.GetAsync(relativeUri); + } + + public async Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest removeSubscriberRequest) + { + var relativeUri = $"{SegmentsRelativeUri}/{segmentId}/subscribers"; + return await this.PutAsync(removeSubscriberRequest, relativeUri); + } + + public async Task DeleteSegmentAsync(long segmentId) + { + var relativeUri = $"{SegmentsRelativeUri}/{segmentId}"; + return await this.DeleteAsync(relativeUri); + } + } +} diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs new file mode 100644 index 0000000..85f467d --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs @@ -0,0 +1,66 @@ +namespace GregsStack.PushCrew.Net.Api +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + + using Newtonsoft.Json; + + using Request; + + using Response; + + public partial class PushCrewClient + { + private const string SendRelativeUri = "send"; + + public async Task SendAllSubscribersAsync(SendMessageRequest request) + { + var relativeUri = $"{SendRelativeUri}/all"; + return await this.PostAsync(request, relativeUri); + } + + public async Task SendSubscribersInSegmentAsync(SendMessageRequest request, long segmentId) + { + var relativeUri = $"{SendRelativeUri}/segment/{segmentId}"; + return await this.PostAsync(request, relativeUri); + } + + public async Task SendSubscribersAsync(SendMessageRequest request, ICollection subscriberList) + { + var relativeUri = $"{SendRelativeUri}/list"; + + var validRequest = request ?? throw new ArgumentNullException(nameof(request)); + var validSubscriberList = subscriberList ?? throw new ArgumentNullException(nameof(subscriberList)); + var subscribers = new Dictionary> { { "subscriber_list", validSubscriberList } }; + var subscriberRequest = (SendMessageSubscribersRequest)validRequest; + subscriberRequest.SubscriberList = JsonConvert.SerializeObject(subscribers); + + return await this.PostAsync(subscriberRequest, relativeUri); + } + + public async Task SendSubscriberAsync(SendMessageRequest request, string subscriberId) + { + var relativeUri = $"{SendRelativeUri}/individual"; + + var validRequest = request ?? throw new ArgumentNullException(nameof(request)); + var validSubscriberId = subscriberId ?? throw new ArgumentNullException(nameof(subscriberId)); + var subscriberRequest = (SendMessageSubscriberRequest)validRequest; + subscriberRequest.SubscriberId = validSubscriberId; + + return await this.PostAsync(subscriberRequest, relativeUri); + } + + public async Task ScheduleAllSubscribersAsync(ScheduleMessageRequest request) + { + var relativeUri = $"{SendRelativeUri}/all"; + return await this.PostAsync(request, relativeUri); + } + + public async Task ScheduleSegmentAsync(ScheduleMessageRequest request, long segmentId) + { + var relativeUri = $"{SendRelativeUri}/segment/{segmentId}"; + return await this.PostAsync(request, relativeUri); + } + } +} diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Subscribers.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Subscribers.cs new file mode 100644 index 0000000..a87bfe6 --- /dev/null +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Subscribers.cs @@ -0,0 +1,15 @@ +namespace GregsStack.PushCrew.Net.Api +{ + using System.Threading.Tasks; + + using Response; + + public partial class PushCrewClient + { + public async Task ListSegmentsOfSubscriberAsync(string subscriberId) + { + var relativeUri = $"subscribers/{subscriberId}/segments"; + return await this.GetAsync(relativeUri); + } + } +} diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs index de79d8c..1b9b959 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs @@ -1,7 +1,6 @@ namespace GregsStack.PushCrew.Net.Api { using System; - using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Net.Http.Formatting; @@ -11,15 +10,10 @@ using Exceptions; - using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; - using Request; - - using Response; - - public class PushCrewClient : IPushCrewClient + public partial class PushCrewClient : IPushCrewClient { private readonly IHttpClientFactory clientFactory; private readonly JsonMediaTypeFormatter jsonFormatter; @@ -41,112 +35,6 @@ public PushCrewClient(IHttpClientFactory httpClientFactory) this.jsonFormatter.SerializerSettings.Converters.Add(new BooleanConverter()); } - public async Task SendAllSubscribersAsync(SendMessageRequest request) - { - const string relativeUri = "send/all"; - return await this.PostAsync(request, relativeUri); - } - - public async Task SendSubscribersInSegmentAsync(SendMessageRequest request, long segmentId) - { - var relativeUri = $"send/segment/{segmentId}"; - return await this.PostAsync(request, relativeUri); - } - - public async Task SendSubscribersAsync(SendMessageRequest request, ICollection subscriberList) - { - const string relativeUri = "send/list"; - - var validRequest = request ?? throw new ArgumentNullException(nameof(request)); - var validSubscriberList = subscriberList ?? throw new ArgumentNullException(nameof(subscriberList)); - var subscribers = new Dictionary> { { "subscriber_list", validSubscriberList } }; - var subscriberRequest = (SendMessageSubscribersRequest)validRequest; - subscriberRequest.SubscriberList = JsonConvert.SerializeObject(subscribers); - - return await this.PostAsync(subscriberRequest, relativeUri); - } - - public async Task SendSubscriberAsync(SendMessageRequest request, string subscriberId) - { - const string relativeUri = "send/individual"; - - var validRequest = request ?? throw new ArgumentNullException(nameof(request)); - var validSubscriberId = subscriberId ?? throw new ArgumentNullException(nameof(subscriberId)); - var subscriberRequest = (SendMessageSubscriberRequest)validRequest; - subscriberRequest.SubscriberId = validSubscriberId; - - return await this.PostAsync(subscriberRequest, relativeUri); - } - - public async Task CheckNotificationRequestStatusAsync(string id) - { - var relativeUri = $"checkstatus/{id}"; - return await this.GetAsync(relativeUri); - } - - public async Task ScheduleAllSubscribersAsync(ScheduleMessageRequest request) - { - const string relativeUri = "send/all"; - return await this.PostAsync(request, relativeUri); - } - - public async Task ScheduleSegmentAsync(ScheduleMessageRequest request, long segmentId) - { - var relativeUri = $"send/segment/{segmentId}"; - return await this.PostAsync(request, relativeUri); - } - - public async Task AddSegmentAsync(string name) - { - const string relativeUri = "segments"; - var dict = new Dictionary { { "name", name } }; - return await this.PostAsync, SegmentResponse>(dict, relativeUri); - } - - public async Task ListSegmentsAsync() - { - const string relativeUri = "segments"; - return await this.GetAsync(relativeUri); - } - - public async Task AddSubscribersToSegmentAsync(long segmentId, ICollection subscriberList) - { - var relativeUri = $"segments/{segmentId}/subscribers"; - - var validSubscriberList = subscriberList ?? throw new ArgumentNullException(nameof(subscriberList)); - var subscribers = new Dictionary> { { "subscriber_list", validSubscriberList } }; - var subscriberRequest = new SendMessageSubscribersRequest - { - SubscriberList = JsonConvert.SerializeObject(subscribers) - }; - - return await this.PostAsync(subscriberRequest, relativeUri); - } - - public async Task ListSubscribersInSegmentAsync(long segmentId, int page = 1, int perPage = 1024) - { - var relativeUri = $"segments/{segmentId}/subscribers?page={page}&per_page={perPage}"; - return await this.GetAsync(relativeUri); - } - - public async Task ListSegmentsOfSubscriberAsync(string subscriberId) - { - var relativeUri = $"subscribers/{subscriberId}/segments"; - return await this.GetAsync(relativeUri); - } - - public async Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest removeSubscriberRequest) - { - var relativeUri = $"segments/{segmentId}/subscribers"; - return await this.PutAsync(removeSubscriberRequest, relativeUri); - } - - public async Task DeleteSegmentAsync(long segmentId) - { - var relativeUri = $"segments/{segmentId}"; - return await this.DeleteAsync(relativeUri); - } - private HttpClient CreateClient() { return this.clientFactory.CreateClient(PushCrewConfiguration.ClientName); From 78dd994e0f983ab675444988dc96872cb958b807 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 20 Aug 2019 22:13:26 +0200 Subject: [PATCH 16/21] Refactor HttpClient request execution --- .../PushCrewClient.cs | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs index 1b9b959..29dbb1c 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs @@ -35,57 +35,40 @@ public PushCrewClient(IHttpClientFactory httpClientFactory) this.jsonFormatter.SerializerSettings.Converters.Add(new BooleanConverter()); } - private HttpClient CreateClient() - { - return this.clientFactory.CreateClient(PushCrewConfiguration.ClientName); - } - private async Task DeleteAsync(string requestUri) - where TResponse : class - { - var client = this.CreateClient(); - using (var response = await client.DeleteAsync(requestUri)) - { - await this.VerifyResponse(response); - return await this.ReadAsAsync(response); - } - } + where TResponse : class => + await this.ExecuteAsync(httpClient => httpClient.DeleteAsync(requestUri)); private async Task GetAsync(string requestUri) - where TResponse : class - { - var client = this.CreateClient(); - using (var response = await client.GetAsync(requestUri)) - { - await this.VerifyResponse(response); - return await this.ReadAsAsync(response); - } - } + where TResponse : class => + await this.ExecuteAsync(httpClient => httpClient.GetAsync(requestUri)); private async Task PostAsync(TRequest request, string requestUri) where TRequest : class - where TResponse : class - { - var client = this.CreateClient(); - using (var response = await client.PostAsync(requestUri, request.ToFormUrlEncodedContent())) - { - await this.VerifyResponse(response); - return await this.ReadAsAsync(response); - } - } + where TResponse : class => + await this.ExecuteAsync(httpClient => httpClient.PostAsync(requestUri, request.ToFormUrlEncodedContent())); private async Task PutAsync(TRequest request, string requestUri) where TRequest : class + where TResponse : class => + await this.ExecuteAsync(httpClient => httpClient.PutAsync(requestUri, request, this.jsonFormatter)); + + private async Task ExecuteAsync(Func> requestAsync) where TResponse : class { var client = this.CreateClient(); - using (var response = await client.PutAsync(requestUri, request, this.jsonFormatter)) + using (var response = await requestAsync(client)) { await this.VerifyResponse(response); return await this.ReadAsAsync(response); } } + private HttpClient CreateClient() + { + return this.clientFactory.CreateClient(PushCrewConfiguration.ClientName); + } + private async Task VerifyResponse(HttpResponseMessage response) { switch (response.StatusCode) From 1795ebec59cf792264cfd424cefb28c7a3a46768 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 20 Aug 2019 22:17:51 +0200 Subject: [PATCH 17/21] Update altcover --- .../GregsStack.PushCrew.Net.Api.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj index 630de40..c500a10 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj +++ b/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj @@ -7,7 +7,7 @@ - + From e24e2113e4ffbc3d9cc84c112d991954790b962c Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 20 Aug 2019 22:27:59 +0200 Subject: [PATCH 18/21] Unify method signature --- src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs | 10 +++++----- .../PushCrewClient.Segments.cs | 9 +++------ src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs | 8 ++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs b/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs index a0bc260..9f60480 100644 --- a/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs +++ b/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs @@ -10,18 +10,18 @@ public interface IPushCrewClient { Task SendAllSubscribersAsync(SendMessageRequest request); - Task SendSubscribersInSegmentAsync(SendMessageRequest request, long segmentId); - Task SendSubscribersAsync(SendMessageRequest request, ICollection subscriberList); - Task SendSubscriberAsync(SendMessageRequest request, string subscriberId); + Task SendSubscribersInSegmentAsync(long segmentId, SendMessageRequest request); + Task SendSubscribersAsync(ICollection subscriberList, SendMessageRequest request); + Task SendSubscriberAsync(string subscriberId, SendMessageRequest request); Task CheckNotificationRequestStatusAsync(string id); Task ScheduleAllSubscribersAsync(ScheduleMessageRequest request); - Task ScheduleSegmentAsync(ScheduleMessageRequest request, long segmentId); + Task ScheduleSegmentAsync(long segmentId, ScheduleMessageRequest request); Task AddSegmentAsync(string name); Task ListSegmentsAsync(); Task AddSubscribersToSegmentAsync(long segmentId, ICollection subscriberList); Task ListSubscribersInSegmentAsync(long segmentId, int page = 1, int perPage = 1024); Task ListSegmentsOfSubscriberAsync(string subscriberId); - Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest removeSubscriberRequest); + Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest request); Task DeleteSegmentAsync(long segmentId); } } diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs index 2a98b45..c5db98f 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs @@ -20,10 +20,7 @@ public async Task AddSegmentAsync(string name) return await this.PostAsync, SegmentResponse>(dict, SegmentsRelativeUri); } - public async Task ListSegmentsAsync() - { - return await this.GetAsync(SegmentsRelativeUri); - } + public async Task ListSegmentsAsync() => await this.GetAsync(SegmentsRelativeUri); public async Task AddSubscribersToSegmentAsync(long segmentId, ICollection subscriberList) { @@ -45,10 +42,10 @@ public async Task ListSubscribersInSegmentAsync(long segmen return await this.GetAsync(relativeUri); } - public async Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest removeSubscriberRequest) + public async Task RemoveSubscribersAsync(long segmentId, RemoveSubscriberRequest request) { var relativeUri = $"{SegmentsRelativeUri}/{segmentId}/subscribers"; - return await this.PutAsync(removeSubscriberRequest, relativeUri); + return await this.PutAsync(request, relativeUri); } public async Task DeleteSegmentAsync(long segmentId) diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs index 85f467d..ab281a4 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs +++ b/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs @@ -20,13 +20,13 @@ public async Task SendAllSubscribersAsync(SendMessageReques return await this.PostAsync(request, relativeUri); } - public async Task SendSubscribersInSegmentAsync(SendMessageRequest request, long segmentId) + public async Task SendSubscribersInSegmentAsync(long segmentId, SendMessageRequest request) { var relativeUri = $"{SendRelativeUri}/segment/{segmentId}"; return await this.PostAsync(request, relativeUri); } - public async Task SendSubscribersAsync(SendMessageRequest request, ICollection subscriberList) + public async Task SendSubscribersAsync(ICollection subscriberList, SendMessageRequest request) { var relativeUri = $"{SendRelativeUri}/list"; @@ -39,7 +39,7 @@ public async Task SendSubscribersAsync(SendMessageRequest r return await this.PostAsync(subscriberRequest, relativeUri); } - public async Task SendSubscriberAsync(SendMessageRequest request, string subscriberId) + public async Task SendSubscriberAsync(string subscriberId, SendMessageRequest request) { var relativeUri = $"{SendRelativeUri}/individual"; @@ -57,7 +57,7 @@ public async Task ScheduleAllSubscribersAsync(ScheduleM return await this.PostAsync(request, relativeUri); } - public async Task ScheduleSegmentAsync(ScheduleMessageRequest request, long segmentId) + public async Task ScheduleSegmentAsync(long segmentId, ScheduleMessageRequest request) { var relativeUri = $"{SendRelativeUri}/segment/{segmentId}"; return await this.PostAsync(request, relativeUri); From 52fcc5e2f4d58dafadee6502a8d0211052a4ae22 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 3 Sep 2019 22:00:59 +0200 Subject: [PATCH 19/21] Rename PushCrew to VwoEngage --- PushCrew.Net.sln => VwoEngage.Net.sln | 4 ++-- .../Attributes/ValidatedNotNullAttribute.cs | 2 +- .../Converters/BooleanConverter.cs | 2 +- .../Converters/FormUrlEncodedContentConverter.cs | 2 +- .../Converters/TimeSpanConverter.cs | 2 +- .../Exceptions/BadRequestException.cs | 2 +- .../Exceptions/InternalServerErrorException.cs | 2 +- .../Exceptions/PushCrewException.cs | 2 +- .../Exceptions/UnauthorizedException.cs | 2 +- .../Extensions/SerializationInfoExtension.cs | 2 +- .../Extensions/ServiceCollectionExtension.cs | 2 +- .../GregsStack.PushCrew.Net.Api.csproj | 4 ++++ .../GregsStack.VwoEngage.Net.Api.csproj} | 8 ++++---- .../IPushCrewClient.cs | 2 +- .../PushCrewClient.CheckStatus.cs | 2 +- .../PushCrewClient.Segments.cs | 2 +- .../PushCrewClient.Send.cs | 2 +- .../PushCrewClient.Subscribers.cs | 2 +- .../PushCrewClient.cs | 2 +- .../PushCrewConfiguration.cs | 2 +- .../Request/RemoveSubscriberRequest.cs | 2 +- .../Request/ScheduleMessageRequest.cs | 2 +- .../Request/SendMessageRequest.cs | 2 +- .../Request/SendMessageSubscriberRequest.cs | 2 +- .../Request/SendMessageSubscribersRequest.cs | 2 +- .../Response/Models/DevicePlatform.cs | 2 +- .../Response/Models/Segment.cs | 2 +- .../Response/Models/Status.cs | 2 +- .../Response/Models/Subscriber.cs | 2 +- .../Response/NotificationStatusResponse.cs | 2 +- .../Response/ScheduleMessageResponse.cs | 2 +- .../Response/SegmentResponse.cs | 2 +- .../Response/SegmentsResponse.cs | 2 +- .../Response/SendMessageResponse.cs | 2 +- .../Response/StatusResponse.cs | 2 +- .../Response/SubscribersResponse.cs | 2 +- .../ClientTests.cs | 2 +- .../Converters/FormUrlEncodedContentConverterTests.cs | 2 +- .../GregsStack.VwoEngage.Net.Api.Tests.csproj} | 4 ++-- .../Sample.cs | 2 +- 40 files changed, 48 insertions(+), 44 deletions(-) rename PushCrew.Net.sln => VwoEngage.Net.sln (94%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Attributes/ValidatedNotNullAttribute.cs (64%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Converters/BooleanConverter.cs (93%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Converters/FormUrlEncodedContentConverter.cs (96%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Converters/TimeSpanConverter.cs (95%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Exceptions/BadRequestException.cs (95%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Exceptions/InternalServerErrorException.cs (94%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Exceptions/PushCrewException.cs (94%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Exceptions/UnauthorizedException.cs (85%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Extensions/SerializationInfoExtension.cs (94%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Extensions/ServiceCollectionExtension.cs (94%) create mode 100644 src/GregsStack.VwoEngage.Net.Api/GregsStack.PushCrew.Net.Api.csproj rename src/{GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj => GregsStack.VwoEngage.Net.Api/GregsStack.VwoEngage.Net.Api.csproj} (76%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/IPushCrewClient.cs (97%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/PushCrewClient.CheckStatus.cs (89%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/PushCrewClient.Segments.cs (98%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/PushCrewClient.Send.cs (98%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/PushCrewClient.Subscribers.cs (89%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/PushCrewClient.cs (98%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/PushCrewConfiguration.cs (85%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Request/RemoveSubscriberRequest.cs (84%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Request/ScheduleMessageRequest.cs (98%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Request/SendMessageRequest.cs (98%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Request/SendMessageSubscriberRequest.cs (81%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Request/SendMessageSubscribersRequest.cs (82%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/Models/DevicePlatform.cs (59%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/Models/Segment.cs (88%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/Models/Status.cs (62%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/Models/Subscriber.cs (98%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/NotificationStatusResponse.cs (91%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/ScheduleMessageResponse.cs (89%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/SegmentResponse.cs (90%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/SegmentsResponse.cs (93%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/SendMessageResponse.cs (88%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/StatusResponse.cs (86%) rename src/{GregsStack.PushCrew.Net.Api => GregsStack.VwoEngage.Net.Api}/Response/SubscribersResponse.cs (96%) rename tests/{GregsStack.PushCrew.Net.Api.Tests => GregsStack.VwoEngage.Net.Api.Tests}/ClientTests.cs (73%) rename tests/{GregsStack.PushCrew.Net.Api.Tests => GregsStack.VwoEngage.Net.Api.Tests}/Converters/FormUrlEncodedContentConverterTests.cs (87%) rename tests/{GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj => GregsStack.VwoEngage.Net.Api.Tests/GregsStack.VwoEngage.Net.Api.Tests.csproj} (80%) rename tests/{GregsStack.PushCrew.Net.Api.Tests => GregsStack.VwoEngage.Net.Api.Tests}/Sample.cs (93%) diff --git a/PushCrew.Net.sln b/VwoEngage.Net.sln similarity index 94% rename from PushCrew.Net.sln rename to VwoEngage.Net.sln index db3e076..3e203c6 100644 --- a/PushCrew.Net.sln +++ b/VwoEngage.Net.sln @@ -5,11 +5,11 @@ VisualStudioVersion = 16.0.29123.89 MinimumVisualStudioVersion = 15.0.26124.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2384891B-7AE9-408A-9DB0-AB41ED0F41C2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GregsStack.PushCrew.Net.Api", "src\GregsStack.PushCrew.Net.Api\GregsStack.PushCrew.Net.Api.csproj", "{CABE94FF-0D04-4C74-B62B-02785FBADEFD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GregsStack.VwoEngage.Net.Api", "src\GregsStack.VwoEngage.Net.Api\GregsStack.VwoEngage.Net.Api.csproj", "{CABE94FF-0D04-4C74-B62B-02785FBADEFD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BB3C3681-2D2A-4F08-B7CE-68461C0643B6}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GregsStack.PushCrew.Net.Api.Tests", "tests\GregsStack.PushCrew.Net.Api.Tests\GregsStack.PushCrew.Net.Api.Tests.csproj", "{8EDEE3E3-7899-49AC-9271-F685890D83F0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GregsStack.VwoEngage.Net.Api.Tests", "tests\GregsStack.VwoEngage.Net.Api.Tests\GregsStack.VwoEngage.Net.Api.Tests.csproj", "{8EDEE3E3-7899-49AC-9271-F685890D83F0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{45050F49-6359-48E6-B1D1-CBF29026D8D8}" ProjectSection(SolutionItems) = preProject diff --git a/src/GregsStack.PushCrew.Net.Api/Attributes/ValidatedNotNullAttribute.cs b/src/GregsStack.VwoEngage.Net.Api/Attributes/ValidatedNotNullAttribute.cs similarity index 64% rename from src/GregsStack.PushCrew.Net.Api/Attributes/ValidatedNotNullAttribute.cs rename to src/GregsStack.VwoEngage.Net.Api/Attributes/ValidatedNotNullAttribute.cs index d26c410..eb2a6e4 100644 --- a/src/GregsStack.PushCrew.Net.Api/Attributes/ValidatedNotNullAttribute.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Attributes/ValidatedNotNullAttribute.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Attributes +namespace GregsStack.VwoEngage.Net.Api.Attributes { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Converters/BooleanConverter.cs b/src/GregsStack.VwoEngage.Net.Api/Converters/BooleanConverter.cs similarity index 93% rename from src/GregsStack.PushCrew.Net.Api/Converters/BooleanConverter.cs rename to src/GregsStack.VwoEngage.Net.Api/Converters/BooleanConverter.cs index 4c14f86..9bebbed 100644 --- a/src/GregsStack.PushCrew.Net.Api/Converters/BooleanConverter.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Converters/BooleanConverter.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Converters +namespace GregsStack.VwoEngage.Net.Api.Converters { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Converters/FormUrlEncodedContentConverter.cs b/src/GregsStack.VwoEngage.Net.Api/Converters/FormUrlEncodedContentConverter.cs similarity index 96% rename from src/GregsStack.PushCrew.Net.Api/Converters/FormUrlEncodedContentConverter.cs rename to src/GregsStack.VwoEngage.Net.Api/Converters/FormUrlEncodedContentConverter.cs index 1247c61..df80d31 100644 --- a/src/GregsStack.PushCrew.Net.Api/Converters/FormUrlEncodedContentConverter.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Converters/FormUrlEncodedContentConverter.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Converters +namespace GregsStack.VwoEngage.Net.Api.Converters { using System; using System.Collections.Generic; diff --git a/src/GregsStack.PushCrew.Net.Api/Converters/TimeSpanConverter.cs b/src/GregsStack.VwoEngage.Net.Api/Converters/TimeSpanConverter.cs similarity index 95% rename from src/GregsStack.PushCrew.Net.Api/Converters/TimeSpanConverter.cs rename to src/GregsStack.VwoEngage.Net.Api/Converters/TimeSpanConverter.cs index 1b0ac35..36d787e 100644 --- a/src/GregsStack.PushCrew.Net.Api/Converters/TimeSpanConverter.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Converters/TimeSpanConverter.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Converters +namespace GregsStack.VwoEngage.Net.Api.Converters { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/BadRequestException.cs similarity index 95% rename from src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs rename to src/GregsStack.VwoEngage.Net.Api/Exceptions/BadRequestException.cs index 1356b46..7eb4a4e 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/BadRequestException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/BadRequestException.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Exceptions +namespace GregsStack.VwoEngage.Net.Api.Exceptions { using System; using System.Collections.Generic; diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/InternalServerErrorException.cs similarity index 94% rename from src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs rename to src/GregsStack.VwoEngage.Net.Api/Exceptions/InternalServerErrorException.cs index aa404b9..61ec9c3 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/InternalServerErrorException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/InternalServerErrorException.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Exceptions +namespace GregsStack.VwoEngage.Net.Api.Exceptions { using System; using System.Runtime.Serialization; diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/PushCrewException.cs similarity index 94% rename from src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs rename to src/GregsStack.VwoEngage.Net.Api/Exceptions/PushCrewException.cs index 0ecf5cf..40f8b50 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/PushCrewException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/PushCrewException.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Exceptions +namespace GregsStack.VwoEngage.Net.Api.Exceptions { using System; using System.Runtime.Serialization; diff --git a/src/GregsStack.PushCrew.Net.Api/Exceptions/UnauthorizedException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/UnauthorizedException.cs similarity index 85% rename from src/GregsStack.PushCrew.Net.Api/Exceptions/UnauthorizedException.cs rename to src/GregsStack.VwoEngage.Net.Api/Exceptions/UnauthorizedException.cs index 3fe3086..16bdbb3 100644 --- a/src/GregsStack.PushCrew.Net.Api/Exceptions/UnauthorizedException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/UnauthorizedException.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Exceptions +namespace GregsStack.VwoEngage.Net.Api.Exceptions { using System.Runtime.Serialization; diff --git a/src/GregsStack.PushCrew.Net.Api/Extensions/SerializationInfoExtension.cs b/src/GregsStack.VwoEngage.Net.Api/Extensions/SerializationInfoExtension.cs similarity index 94% rename from src/GregsStack.PushCrew.Net.Api/Extensions/SerializationInfoExtension.cs rename to src/GregsStack.VwoEngage.Net.Api/Extensions/SerializationInfoExtension.cs index f484bf2..cf0b5e0 100644 --- a/src/GregsStack.PushCrew.Net.Api/Extensions/SerializationInfoExtension.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Extensions/SerializationInfoExtension.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Extensions +namespace GregsStack.VwoEngage.Net.Api.Extensions { using System; using System.Runtime.Serialization; diff --git a/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs b/src/GregsStack.VwoEngage.Net.Api/Extensions/ServiceCollectionExtension.cs similarity index 94% rename from src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs rename to src/GregsStack.VwoEngage.Net.Api/Extensions/ServiceCollectionExtension.cs index f1acdec..1fac71e 100644 --- a/src/GregsStack.PushCrew.Net.Api/Extensions/ServiceCollectionExtension.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Extensions/ServiceCollectionExtension.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Extensions +namespace GregsStack.VwoEngage.Net.Api.Extensions { using System; using System.Net.Http.Headers; diff --git a/src/GregsStack.VwoEngage.Net.Api/GregsStack.PushCrew.Net.Api.csproj b/src/GregsStack.VwoEngage.Net.Api/GregsStack.PushCrew.Net.Api.csproj new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/src/GregsStack.VwoEngage.Net.Api/GregsStack.PushCrew.Net.Api.csproj @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj b/src/GregsStack.VwoEngage.Net.Api/GregsStack.VwoEngage.Net.Api.csproj similarity index 76% rename from src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj rename to src/GregsStack.VwoEngage.Net.Api/GregsStack.VwoEngage.Net.Api.csproj index 111257d..adaae44 100644 --- a/src/GregsStack.PushCrew.Net.Api/GregsStack.PushCrew.Net.Api.csproj +++ b/src/GregsStack.VwoEngage.Net.Api/GregsStack.VwoEngage.Net.Api.csproj @@ -4,12 +4,12 @@ netstandard2.0 LICENSE - https://github.com/GregsStack/PushCrew.Net - https://github.com/GregsStack/PushCrew.Net - pushcrew;api-client;api + https://github.com/GregsStack/VwoEngage.Net + https://github.com/GregsStack/VwoEngage.Net + pushcrew;api-client;api;pushcrew-api;vwo;engage;vwo-engage; Gregor Sindl Copyright © 2019 Gregor Sindl - .Net implementation of PushCrew API (https://api.pushcrew.com) + .Net implementation of VWO Engage (former PushCrew) API (https://api.pushcrew.com) true true true diff --git a/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs b/src/GregsStack.VwoEngage.Net.Api/IPushCrewClient.cs similarity index 97% rename from src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs rename to src/GregsStack.VwoEngage.Net.Api/IPushCrewClient.cs index 9f60480..f26c9ae 100644 --- a/src/GregsStack.PushCrew.Net.Api/IPushCrewClient.cs +++ b/src/GregsStack.VwoEngage.Net.Api/IPushCrewClient.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.VwoEngage.Net.Api { using System.Collections.Generic; using System.Threading.Tasks; diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.CheckStatus.cs b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.CheckStatus.cs similarity index 89% rename from src/GregsStack.PushCrew.Net.Api/PushCrewClient.CheckStatus.cs rename to src/GregsStack.VwoEngage.Net.Api/PushCrewClient.CheckStatus.cs index 5ba28ba..202aaca 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.CheckStatus.cs +++ b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.CheckStatus.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.VwoEngage.Net.Api { using System.Threading.Tasks; diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Segments.cs similarity index 98% rename from src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs rename to src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Segments.cs index c5db98f..d75d8e2 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Segments.cs +++ b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Segments.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.VwoEngage.Net.Api { using System; using System.Collections.Generic; diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Send.cs similarity index 98% rename from src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs rename to src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Send.cs index ab281a4..51440b5 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Send.cs +++ b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Send.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.VwoEngage.Net.Api { using System; using System.Collections.Generic; diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Subscribers.cs b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Subscribers.cs similarity index 89% rename from src/GregsStack.PushCrew.Net.Api/PushCrewClient.Subscribers.cs rename to src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Subscribers.cs index a87bfe6..c36091f 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.Subscribers.cs +++ b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Subscribers.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.VwoEngage.Net.Api { using System.Threading.Tasks; diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.cs similarity index 98% rename from src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs rename to src/GregsStack.VwoEngage.Net.Api/PushCrewClient.cs index 29dbb1c..9275864 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewClient.cs +++ b/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.VwoEngage.Net.Api { using System; using System.Net; diff --git a/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs b/src/GregsStack.VwoEngage.Net.Api/PushCrewConfiguration.cs similarity index 85% rename from src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs rename to src/GregsStack.VwoEngage.Net.Api/PushCrewConfiguration.cs index 0c6ac39..3c4e342 100644 --- a/src/GregsStack.PushCrew.Net.Api/PushCrewConfiguration.cs +++ b/src/GregsStack.VwoEngage.Net.Api/PushCrewConfiguration.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api +namespace GregsStack.VwoEngage.Net.Api { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Request/RemoveSubscriberRequest.cs b/src/GregsStack.VwoEngage.Net.Api/Request/RemoveSubscriberRequest.cs similarity index 84% rename from src/GregsStack.PushCrew.Net.Api/Request/RemoveSubscriberRequest.cs rename to src/GregsStack.VwoEngage.Net.Api/Request/RemoveSubscriberRequest.cs index ee80648..bd56a38 100644 --- a/src/GregsStack.PushCrew.Net.Api/Request/RemoveSubscriberRequest.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Request/RemoveSubscriberRequest.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Request +namespace GregsStack.VwoEngage.Net.Api.Request { using System.Collections.Generic; diff --git a/src/GregsStack.PushCrew.Net.Api/Request/ScheduleMessageRequest.cs b/src/GregsStack.VwoEngage.Net.Api/Request/ScheduleMessageRequest.cs similarity index 98% rename from src/GregsStack.PushCrew.Net.Api/Request/ScheduleMessageRequest.cs rename to src/GregsStack.VwoEngage.Net.Api/Request/ScheduleMessageRequest.cs index cfeb8df..1154222 100644 --- a/src/GregsStack.PushCrew.Net.Api/Request/ScheduleMessageRequest.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Request/ScheduleMessageRequest.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Request +namespace GregsStack.VwoEngage.Net.Api.Request { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Request/SendMessageRequest.cs b/src/GregsStack.VwoEngage.Net.Api/Request/SendMessageRequest.cs similarity index 98% rename from src/GregsStack.PushCrew.Net.Api/Request/SendMessageRequest.cs rename to src/GregsStack.VwoEngage.Net.Api/Request/SendMessageRequest.cs index e5cfc56..e848a75 100644 --- a/src/GregsStack.PushCrew.Net.Api/Request/SendMessageRequest.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Request/SendMessageRequest.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Request +namespace GregsStack.VwoEngage.Net.Api.Request { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Request/SendMessageSubscriberRequest.cs b/src/GregsStack.VwoEngage.Net.Api/Request/SendMessageSubscriberRequest.cs similarity index 81% rename from src/GregsStack.PushCrew.Net.Api/Request/SendMessageSubscriberRequest.cs rename to src/GregsStack.VwoEngage.Net.Api/Request/SendMessageSubscriberRequest.cs index 9257ced..34683a7 100644 --- a/src/GregsStack.PushCrew.Net.Api/Request/SendMessageSubscriberRequest.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Request/SendMessageSubscriberRequest.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Request +namespace GregsStack.VwoEngage.Net.Api.Request { public class SendMessageSubscriberRequest : SendMessageRequest { diff --git a/src/GregsStack.PushCrew.Net.Api/Request/SendMessageSubscribersRequest.cs b/src/GregsStack.VwoEngage.Net.Api/Request/SendMessageSubscribersRequest.cs similarity index 82% rename from src/GregsStack.PushCrew.Net.Api/Request/SendMessageSubscribersRequest.cs rename to src/GregsStack.VwoEngage.Net.Api/Request/SendMessageSubscribersRequest.cs index d3f7ff2..f45a054 100644 --- a/src/GregsStack.PushCrew.Net.Api/Request/SendMessageSubscribersRequest.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Request/SendMessageSubscribersRequest.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Request +namespace GregsStack.VwoEngage.Net.Api.Request { public class SendMessageSubscribersRequest : SendMessageRequest { diff --git a/src/GregsStack.PushCrew.Net.Api/Response/Models/DevicePlatform.cs b/src/GregsStack.VwoEngage.Net.Api/Response/Models/DevicePlatform.cs similarity index 59% rename from src/GregsStack.PushCrew.Net.Api/Response/Models/DevicePlatform.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/Models/DevicePlatform.cs index 25ac132..3a5b8f5 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/Models/DevicePlatform.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/Models/DevicePlatform.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response.Models +namespace GregsStack.VwoEngage.Net.Api.Response.Models { public enum DevicePlatform { diff --git a/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs b/src/GregsStack.VwoEngage.Net.Api/Response/Models/Segment.cs similarity index 88% rename from src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/Models/Segment.cs index 5f63032..7bc94f5 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/Models/Segment.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/Models/Segment.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response.Models +namespace GregsStack.VwoEngage.Net.Api.Response.Models { using System; diff --git a/src/GregsStack.PushCrew.Net.Api/Response/Models/Status.cs b/src/GregsStack.VwoEngage.Net.Api/Response/Models/Status.cs similarity index 62% rename from src/GregsStack.PushCrew.Net.Api/Response/Models/Status.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/Models/Status.cs index 745e301..d0250bd 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/Models/Status.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/Models/Status.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response.Models +namespace GregsStack.VwoEngage.Net.Api.Response.Models { public enum Status { diff --git a/src/GregsStack.PushCrew.Net.Api/Response/Models/Subscriber.cs b/src/GregsStack.VwoEngage.Net.Api/Response/Models/Subscriber.cs similarity index 98% rename from src/GregsStack.PushCrew.Net.Api/Response/Models/Subscriber.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/Models/Subscriber.cs index 7ebf594..87bb597 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/Models/Subscriber.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/Models/Subscriber.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response.Models +namespace GregsStack.VwoEngage.Net.Api.Response.Models { using System; using System.Net; diff --git a/src/GregsStack.PushCrew.Net.Api/Response/NotificationStatusResponse.cs b/src/GregsStack.VwoEngage.Net.Api/Response/NotificationStatusResponse.cs similarity index 91% rename from src/GregsStack.PushCrew.Net.Api/Response/NotificationStatusResponse.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/NotificationStatusResponse.cs index db66802..52f1413 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/NotificationStatusResponse.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/NotificationStatusResponse.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response +namespace GregsStack.VwoEngage.Net.Api.Response { public class NotificationStatusResponse : StatusResponse { diff --git a/src/GregsStack.PushCrew.Net.Api/Response/ScheduleMessageResponse.cs b/src/GregsStack.VwoEngage.Net.Api/Response/ScheduleMessageResponse.cs similarity index 89% rename from src/GregsStack.PushCrew.Net.Api/Response/ScheduleMessageResponse.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/ScheduleMessageResponse.cs index bc5734f..2d8c273 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/ScheduleMessageResponse.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/ScheduleMessageResponse.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response +namespace GregsStack.VwoEngage.Net.Api.Response { public class ScheduleMessageResponse : StatusResponse { diff --git a/src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs b/src/GregsStack.VwoEngage.Net.Api/Response/SegmentResponse.cs similarity index 90% rename from src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/SegmentResponse.cs index 2889356..0268442 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/SegmentResponse.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/SegmentResponse.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response +namespace GregsStack.VwoEngage.Net.Api.Response { public class SegmentResponse : StatusResponse { diff --git a/src/GregsStack.PushCrew.Net.Api/Response/SegmentsResponse.cs b/src/GregsStack.VwoEngage.Net.Api/Response/SegmentsResponse.cs similarity index 93% rename from src/GregsStack.PushCrew.Net.Api/Response/SegmentsResponse.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/SegmentsResponse.cs index 02842d2..f50973e 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/SegmentsResponse.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/SegmentsResponse.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response +namespace GregsStack.VwoEngage.Net.Api.Response { using System.Collections.Generic; diff --git a/src/GregsStack.PushCrew.Net.Api/Response/SendMessageResponse.cs b/src/GregsStack.VwoEngage.Net.Api/Response/SendMessageResponse.cs similarity index 88% rename from src/GregsStack.PushCrew.Net.Api/Response/SendMessageResponse.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/SendMessageResponse.cs index 9512ded..c0ce377 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/SendMessageResponse.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/SendMessageResponse.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response +namespace GregsStack.VwoEngage.Net.Api.Response { public class SendMessageResponse : StatusResponse { diff --git a/src/GregsStack.PushCrew.Net.Api/Response/StatusResponse.cs b/src/GregsStack.VwoEngage.Net.Api/Response/StatusResponse.cs similarity index 86% rename from src/GregsStack.PushCrew.Net.Api/Response/StatusResponse.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/StatusResponse.cs index 1ae1115..70c82ed 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/StatusResponse.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/StatusResponse.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response +namespace GregsStack.VwoEngage.Net.Api.Response { using Models; diff --git a/src/GregsStack.PushCrew.Net.Api/Response/SubscribersResponse.cs b/src/GregsStack.VwoEngage.Net.Api/Response/SubscribersResponse.cs similarity index 96% rename from src/GregsStack.PushCrew.Net.Api/Response/SubscribersResponse.cs rename to src/GregsStack.VwoEngage.Net.Api/Response/SubscribersResponse.cs index 44b5631..a99aaba 100644 --- a/src/GregsStack.PushCrew.Net.Api/Response/SubscribersResponse.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Response/SubscribersResponse.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Response +namespace GregsStack.VwoEngage.Net.Api.Response { using System; using System.Collections.Generic; diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/ClientTests.cs b/tests/GregsStack.VwoEngage.Net.Api.Tests/ClientTests.cs similarity index 73% rename from tests/GregsStack.PushCrew.Net.Api.Tests/ClientTests.cs rename to tests/GregsStack.VwoEngage.Net.Api.Tests/ClientTests.cs index 3750689..5337b3a 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/ClientTests.cs +++ b/tests/GregsStack.VwoEngage.Net.Api.Tests/ClientTests.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Tests +namespace GregsStack.VwoEngage.Net.Api.Tests { using Xunit; diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/Converters/FormUrlEncodedContentConverterTests.cs b/tests/GregsStack.VwoEngage.Net.Api.Tests/Converters/FormUrlEncodedContentConverterTests.cs similarity index 87% rename from tests/GregsStack.PushCrew.Net.Api.Tests/Converters/FormUrlEncodedContentConverterTests.cs rename to tests/GregsStack.VwoEngage.Net.Api.Tests/Converters/FormUrlEncodedContentConverterTests.cs index b689c43..6419f40 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/Converters/FormUrlEncodedContentConverterTests.cs +++ b/tests/GregsStack.VwoEngage.Net.Api.Tests/Converters/FormUrlEncodedContentConverterTests.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Tests.Converters +namespace GregsStack.VwoEngage.Net.Api.Tests.Converters { using System; diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj b/tests/GregsStack.VwoEngage.Net.Api.Tests/GregsStack.VwoEngage.Net.Api.Tests.csproj similarity index 80% rename from tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj rename to tests/GregsStack.VwoEngage.Net.Api.Tests/GregsStack.VwoEngage.Net.Api.Tests.csproj index c500a10..ce16744 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/GregsStack.PushCrew.Net.Api.Tests.csproj +++ b/tests/GregsStack.VwoEngage.Net.Api.Tests/GregsStack.VwoEngage.Net.Api.Tests.csproj @@ -7,7 +7,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/tests/GregsStack.PushCrew.Net.Api.Tests/Sample.cs b/tests/GregsStack.VwoEngage.Net.Api.Tests/Sample.cs similarity index 93% rename from tests/GregsStack.PushCrew.Net.Api.Tests/Sample.cs rename to tests/GregsStack.VwoEngage.Net.Api.Tests/Sample.cs index f28c84f..3cf3647 100644 --- a/tests/GregsStack.PushCrew.Net.Api.Tests/Sample.cs +++ b/tests/GregsStack.VwoEngage.Net.Api.Tests/Sample.cs @@ -1,4 +1,4 @@ -namespace GregsStack.PushCrew.Net.Api.Tests +namespace GregsStack.VwoEngage.Net.Api.Tests { using System.Threading.Tasks; From 073e6b5fa5fdc8b9a2fb2b1052ae7f9f9c0357e4 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 3 Sep 2019 22:07:03 +0200 Subject: [PATCH 20/21] Rename all classes to VwoEngage --- .../Exceptions/BadRequestException.cs | 4 ++-- .../Exceptions/InternalServerErrorException.cs | 4 ++-- .../Exceptions/UnauthorizedException.cs | 4 ++-- .../{PushCrewException.cs => VwoEngageException.cs} | 6 +++--- .../Extensions/ServiceCollectionExtension.cs | 4 ++-- .../{IPushCrewClient.cs => IVwoEngageClient.cs} | 2 +- ...Client.CheckStatus.cs => VwoEngageClient.CheckStatus.cs} | 2 +- ...shCrewClient.Segments.cs => VwoEngageClient.Segments.cs} | 2 +- .../{PushCrewClient.Send.cs => VwoEngageClient.Send.cs} | 2 +- ...Client.Subscribers.cs => VwoEngageClient.Subscribers.cs} | 2 +- .../{PushCrewClient.cs => VwoEngageClient.cs} | 6 +++--- .../{PushCrewConfiguration.cs => VwoEngageConfiguration.cs} | 4 ++-- tests/GregsStack.VwoEngage.Net.Api.Tests/Sample.cs | 4 ++-- 13 files changed, 23 insertions(+), 23 deletions(-) rename src/GregsStack.VwoEngage.Net.Api/Exceptions/{PushCrewException.cs => VwoEngageException.cs} (81%) rename src/GregsStack.VwoEngage.Net.Api/{IPushCrewClient.cs => IVwoEngageClient.cs} (97%) rename src/GregsStack.VwoEngage.Net.Api/{PushCrewClient.CheckStatus.cs => VwoEngageClient.CheckStatus.cs} (89%) rename src/GregsStack.VwoEngage.Net.Api/{PushCrewClient.Segments.cs => VwoEngageClient.Segments.cs} (98%) rename src/GregsStack.VwoEngage.Net.Api/{PushCrewClient.Send.cs => VwoEngageClient.Send.cs} (98%) rename src/GregsStack.VwoEngage.Net.Api/{PushCrewClient.Subscribers.cs => VwoEngageClient.Subscribers.cs} (90%) rename src/GregsStack.VwoEngage.Net.Api/{PushCrewClient.cs => VwoEngageClient.cs} (94%) rename src/GregsStack.VwoEngage.Net.Api/{PushCrewConfiguration.cs => VwoEngageConfiguration.cs} (57%) diff --git a/src/GregsStack.VwoEngage.Net.Api/Exceptions/BadRequestException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/BadRequestException.cs index 7eb4a4e..1996b74 100644 --- a/src/GregsStack.VwoEngage.Net.Api/Exceptions/BadRequestException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/BadRequestException.cs @@ -8,9 +8,9 @@ using Response.Models; - public class BadRequestException : PushCrewException + public class BadRequestException : VwoEngageException { - /// + /// public BadRequestException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/GregsStack.VwoEngage.Net.Api/Exceptions/InternalServerErrorException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/InternalServerErrorException.cs index 61ec9c3..9191464 100644 --- a/src/GregsStack.VwoEngage.Net.Api/Exceptions/InternalServerErrorException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/InternalServerErrorException.cs @@ -7,9 +7,9 @@ using Response.Models; - public class InternalServerErrorException : PushCrewException + public class InternalServerErrorException : VwoEngageException { - /// + /// public InternalServerErrorException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/GregsStack.VwoEngage.Net.Api/Exceptions/UnauthorizedException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/UnauthorizedException.cs index 16bdbb3..3000349 100644 --- a/src/GregsStack.VwoEngage.Net.Api/Exceptions/UnauthorizedException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/UnauthorizedException.cs @@ -2,9 +2,9 @@ { using System.Runtime.Serialization; - public class UnauthorizedException : PushCrewException + public class UnauthorizedException : VwoEngageException { - /// + /// public UnauthorizedException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/GregsStack.VwoEngage.Net.Api/Exceptions/PushCrewException.cs b/src/GregsStack.VwoEngage.Net.Api/Exceptions/VwoEngageException.cs similarity index 81% rename from src/GregsStack.VwoEngage.Net.Api/Exceptions/PushCrewException.cs rename to src/GregsStack.VwoEngage.Net.Api/Exceptions/VwoEngageException.cs index 40f8b50..cd76490 100644 --- a/src/GregsStack.VwoEngage.Net.Api/Exceptions/PushCrewException.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Exceptions/VwoEngageException.cs @@ -5,14 +5,14 @@ using Extensions; - public class PushCrewException : Exception + public class VwoEngageException : Exception { - /// Initializes a new instance of the class with serialized data. + /// Initializes a new instance of the class with serialized data. /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. /// The parameter is null. /// The class name is null or is zero (0). - public PushCrewException(SerializationInfo info, StreamingContext context) + public VwoEngageException(SerializationInfo info, StreamingContext context) : base(info.GetSafeString("message") ?? info.GetSafeString("error")) { } diff --git a/src/GregsStack.VwoEngage.Net.Api/Extensions/ServiceCollectionExtension.cs b/src/GregsStack.VwoEngage.Net.Api/Extensions/ServiceCollectionExtension.cs index 1fac71e..a15f90f 100644 --- a/src/GregsStack.VwoEngage.Net.Api/Extensions/ServiceCollectionExtension.cs +++ b/src/GregsStack.VwoEngage.Net.Api/Extensions/ServiceCollectionExtension.cs @@ -13,9 +13,9 @@ public static IHttpClientBuilder AddPushCrewHttpClient([ValidatedNotNull] this I { var validatedServiceCollection = serviceCollection ?? throw new ArgumentNullException(nameof(serviceCollection)); var validatedApiToken = apiToken ?? throw new ArgumentNullException(nameof(apiToken)); - return validatedServiceCollection.AddHttpClient(PushCrewConfiguration.ClientName, client => + return validatedServiceCollection.AddHttpClient(VwoEngageConfiguration.ClientName, client => { - client.BaseAddress = PushCrewConfiguration.BaseUri; + client.BaseAddress = VwoEngageConfiguration.BaseUri; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(validatedApiToken); }); } diff --git a/src/GregsStack.VwoEngage.Net.Api/IPushCrewClient.cs b/src/GregsStack.VwoEngage.Net.Api/IVwoEngageClient.cs similarity index 97% rename from src/GregsStack.VwoEngage.Net.Api/IPushCrewClient.cs rename to src/GregsStack.VwoEngage.Net.Api/IVwoEngageClient.cs index f26c9ae..0e12e5a 100644 --- a/src/GregsStack.VwoEngage.Net.Api/IPushCrewClient.cs +++ b/src/GregsStack.VwoEngage.Net.Api/IVwoEngageClient.cs @@ -7,7 +7,7 @@ using Response; - public interface IPushCrewClient + public interface IVwoEngageClient { Task SendAllSubscribersAsync(SendMessageRequest request); Task SendSubscribersInSegmentAsync(long segmentId, SendMessageRequest request); diff --git a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.CheckStatus.cs b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.CheckStatus.cs similarity index 89% rename from src/GregsStack.VwoEngage.Net.Api/PushCrewClient.CheckStatus.cs rename to src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.CheckStatus.cs index 202aaca..e3c0074 100644 --- a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.CheckStatus.cs +++ b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.CheckStatus.cs @@ -4,7 +4,7 @@ using Response; - public partial class PushCrewClient + public partial class VwoEngageClient { public async Task CheckNotificationRequestStatusAsync(string id) { diff --git a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Segments.cs b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Segments.cs similarity index 98% rename from src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Segments.cs rename to src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Segments.cs index d75d8e2..069abb4 100644 --- a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Segments.cs +++ b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Segments.cs @@ -10,7 +10,7 @@ using Response; - public partial class PushCrewClient + public partial class VwoEngageClient { private const string SegmentsRelativeUri = "segments"; diff --git a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Send.cs b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Send.cs similarity index 98% rename from src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Send.cs rename to src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Send.cs index 51440b5..f4838b5 100644 --- a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Send.cs +++ b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Send.cs @@ -10,7 +10,7 @@ using Response; - public partial class PushCrewClient + public partial class VwoEngageClient { private const string SendRelativeUri = "send"; diff --git a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Subscribers.cs b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Subscribers.cs similarity index 90% rename from src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Subscribers.cs rename to src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Subscribers.cs index c36091f..39b1aea 100644 --- a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.Subscribers.cs +++ b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.Subscribers.cs @@ -4,7 +4,7 @@ using Response; - public partial class PushCrewClient + public partial class VwoEngageClient { public async Task ListSegmentsOfSubscriberAsync(string subscriberId) { diff --git a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.cs b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.cs similarity index 94% rename from src/GregsStack.VwoEngage.Net.Api/PushCrewClient.cs rename to src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.cs index 9275864..dd26094 100644 --- a/src/GregsStack.VwoEngage.Net.Api/PushCrewClient.cs +++ b/src/GregsStack.VwoEngage.Net.Api/VwoEngageClient.cs @@ -13,12 +13,12 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; - public partial class PushCrewClient : IPushCrewClient + public partial class VwoEngageClient : IVwoEngageClient { private readonly IHttpClientFactory clientFactory; private readonly JsonMediaTypeFormatter jsonFormatter; - public PushCrewClient(IHttpClientFactory httpClientFactory) + public VwoEngageClient(IHttpClientFactory httpClientFactory) { this.clientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); @@ -66,7 +66,7 @@ private async Task ExecuteAsync(Func(); + di.AddTransient(); var serviceProvider = di.BuildServiceProvider(); - var client = serviceProvider.GetRequiredService(); + var client = serviceProvider.GetRequiredService(); await Assert.ThrowsAsync(() => client.DeleteSegmentAsync(123)); } } From d331b1fc0a009116a7944954503248c7915fb918 Mon Sep 17 00:00:00 2001 From: Gregor Sindl Date: Tue, 3 Sep 2019 22:11:21 +0200 Subject: [PATCH 21/21] Update Readme.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7951ab3..b4db27b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# PushCrew.Net -.Net implementation of [PushCrew API](https://api.pushcrew.com) +# VwoEngage.Net +.Net implementation of [VWO Engage](https://vwo.com/engage/) (former [PushCrew API](https://api.pushcrew.com)) -[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/GregsStack.PushCrew.Net.Api)](https://www.nuget.org/packages/GregsStack.PushCrew.Net.Api) -[![Build Status](https://dev.azure.com/GregsStack/GitHub/_apis/build/status/GregsStack.PushCrew.Net?branchName=master)](https://dev.azure.com/GregsStack/GitHub/_build/latest?definitionId=3&branchName=master) -[![codecov](https://codecov.io/gh/GregsStack/PushCrew.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/GregsStack/PushCrew.Net) +[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/GregsStack.VwoEngage.Net.Api)](https://www.nuget.org/packages/GregsStack.VwoEngage.Net.Api) +[![Build Status](https://dev.azure.com/GregsStack/GitHub/_apis/build/status/GregsStack.VwoEngage.Net?branchName=master)](https://dev.azure.com/GregsStack/GitHub/_build/latest?definitionId=4&branchName=master) +[![codecov](https://codecov.io/gh/GregsStack/VwoEngage.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/GregsStack/VwoEngage.Net)