Skip to content

Commit

Permalink
Merge branch 'feature/log_diagnostic_even_when_exception_occurs' into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
Jericho committed Apr 19, 2019
2 parents c47835a + 2d3a2cc commit d65e4b7
Show file tree
Hide file tree
Showing 73 changed files with 785 additions and 724 deletions.
1 change: 0 additions & 1 deletion Source/StrongGrid.IntegrationTests/ConsoleLogProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// Inspired by: https://github.com/damianh/LibLog/blob/master/src/LibLog.Example.ColoredConsoleLogProvider/ColoredConsoleLogProvider.cs
public class ConsoleLogProvider : ILogProvider
{

public Logger GetLogger(string name)
{
return (logLevel, messageFunc, exception, formatParameters) =>
Expand Down
14 changes: 7 additions & 7 deletions Source/StrongGrid.IntegrationTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ static async Task<int> Main()
var debugHttpMessagesToConsole = false;
// -----------------------------------------------------------------------------

var proxy = useFiddler ? new WebProxy("http://localhost:8888") : null;
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
var client = new Client(apiKey, proxy);

if (debugHttpMessagesToConsole)
{
LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());
}

var proxy = useFiddler ? new WebProxy("http://localhost:8888") : null;
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
var client = new Client(apiKey, proxy);

var source = new CancellationTokenSource();
Console.CancelKeyPress += (s, e) =>
{
Expand Down Expand Up @@ -83,9 +83,9 @@ static async Task<int> Main()
Teammates,
Templates,
User,
WebhookSettings,
WebhookStats,
SenderAuthentication
//WebhookSettings,
//WebhookStats,
//SenderAuthentication
};

// Execute the async tests in parallel (with max degree of parallelism)
Expand Down
4 changes: 2 additions & 2 deletions Source/StrongGrid.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{7F08B680-E39D-4201-A60A-22814CA5ABF4}"
EndProject
Expand Down
14 changes: 7 additions & 7 deletions Source/StrongGrid/Resources/AccessManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal AccessManagement(Pathoschild.Http.Client.IClient client)
/// <returns>
/// The <see cref="Alert" />.
/// </returns>
public Task<AccessEntry[]> GetAccessHistoryAsync(int limit = 20, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<AccessEntry[]> GetAccessHistoryAsync(int limit = 20, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"{_endpoint}/activity")
Expand All @@ -58,7 +58,7 @@ public Task<AccessEntry[]> GetAccessHistoryAsync(int limit = 20, string onBehalf
/// <returns>
/// An array of <see cref="WhitelistedIp" />.
/// </returns>
public Task<WhitelistedIp[]> GetWhitelistedIpAddressesAsync(string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<WhitelistedIp[]> GetWhitelistedIpAddressesAsync(string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"{_endpoint}/whitelist")
Expand All @@ -76,7 +76,7 @@ public Task<WhitelistedIp[]> GetWhitelistedIpAddressesAsync(string onBehalfOf =
/// <returns>
/// The <see cref="Alert" />.
/// </returns>
public async Task<WhitelistedIp> AddIpAddressToWhitelistAsync(string ip, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<WhitelistedIp> AddIpAddressToWhitelistAsync(string ip, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = new JObject
{
Expand Down Expand Up @@ -104,7 +104,7 @@ public async Task<WhitelistedIp> AddIpAddressToWhitelistAsync(string ip, string
/// <returns>
/// The <see cref="Alert" />.
/// </returns>
public Task<WhitelistedIp[]> AddIpAddressesToWhitelistAsync(IEnumerable<string> ips, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<WhitelistedIp[]> AddIpAddressesToWhitelistAsync(IEnumerable<string> ips, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var ipsJsonArray = new JArray();
foreach (var ip in ips)
Expand Down Expand Up @@ -134,7 +134,7 @@ public Task<WhitelistedIp[]> AddIpAddressesToWhitelistAsync(IEnumerable<string>
/// <returns>
/// The async task.
/// </returns>
public Task RemoveIpAddressFromWhitelistAsync(long id, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task RemoveIpAddressFromWhitelistAsync(long id, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.DeleteAsync($"{_endpoint}/whitelist/{id}")
Expand All @@ -152,7 +152,7 @@ public Task RemoveIpAddressFromWhitelistAsync(long id, string onBehalfOf = null,
/// <returns>
/// The async task.
/// </returns>
public Task RemoveIpAddressesFromWhitelistAsync(IEnumerable<long> ids, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task RemoveIpAddressesFromWhitelistAsync(IEnumerable<long> ids, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = new JObject
{
Expand All @@ -176,7 +176,7 @@ public Task RemoveIpAddressesFromWhitelistAsync(IEnumerable<long> ids, string on
/// <returns>
/// The <see cref="Alert" />.
/// </returns>
public Task<WhitelistedIp> GetWhitelistedIpAddressAsync(long id, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<WhitelistedIp> GetWhitelistedIpAddressAsync(long id, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"{_endpoint}/whitelist/{id}")
Expand Down
10 changes: 5 additions & 5 deletions Source/StrongGrid/Resources/Alerts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal Alerts(Pathoschild.Http.Client.IClient client)
/// <returns>
/// The <see cref="Alert" />.
/// </returns>
public Task<Alert> GetAsync(long alertId, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<Alert> GetAsync(long alertId, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"{_endpoint}/{alertId}")
Expand All @@ -55,7 +55,7 @@ public Task<Alert> GetAsync(long alertId, string onBehalfOf = null, Cancellation
/// <returns>
/// An array of <see cref="Alert" />.
/// </returns>
public Task<Alert[]> GetAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<Alert[]> GetAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync(_endpoint)
Expand All @@ -76,7 +76,7 @@ public Task<Alert[]> GetAllAsync(string onBehalfOf = null, CancellationToken can
/// <returns>
/// The <see cref="Alert" />.
/// </returns>
public Task<Alert> CreateAsync(AlertType type, Parameter<string> emailTo = default(Parameter<string>), Parameter<Frequency?> frequency = default(Parameter<Frequency?>), Parameter<int?> percentage = default(Parameter<int?>), string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<Alert> CreateAsync(AlertType type, Parameter<string> emailTo = default, Parameter<Frequency?> frequency = default, Parameter<int?> percentage = default, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = CreateJObject(type, emailTo, frequency, percentage);
return _client
Expand All @@ -96,7 +96,7 @@ public Task<Alert> CreateAsync(AlertType type, Parameter<string> emailTo = defau
/// <returns>
/// The async task.
/// </returns>
public Task DeleteAsync(long alertId, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task DeleteAsync(long alertId, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.DeleteAsync($"{_endpoint}/{alertId}")
Expand All @@ -117,7 +117,7 @@ public Task DeleteAsync(long alertId, string onBehalfOf = null, CancellationToke
/// <returns>
/// The <see cref="Alert" />.
/// </returns>
public Task<Alert> UpdateAsync(long alertId, Parameter<AlertType?> type = default(Parameter<AlertType?>), Parameter<string> emailTo = default(Parameter<string>), Parameter<Frequency?> frequency = default(Parameter<Frequency?>), Parameter<int?> percentage = default(Parameter<int?>), string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<Alert> UpdateAsync(long alertId, Parameter<AlertType?> type = default, Parameter<string> emailTo = default, Parameter<Frequency?> frequency = default, Parameter<int?> percentage = default, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = CreateJObject(type, emailTo, frequency, percentage);
return _client
Expand Down
16 changes: 8 additions & 8 deletions Source/StrongGrid/Resources/ApiKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal ApiKeys(Pathoschild.Http.Client.IClient client)
/// <returns>
/// The <see cref="ApiKey" />.
/// </returns>
public Task<ApiKey> GetAsync(string keyId, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<ApiKey> GetAsync(string keyId, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"{_endpoint}/{keyId}")
Expand All @@ -61,7 +61,7 @@ public Task<ApiKey> GetAsync(string keyId, string onBehalfOf = null, Cancellatio
/// The response does not include the permissions associated with each api key.
/// In order to get the permission for a given key, you need to <see cref="GetAsync(string, string, CancellationToken)">retrieve keys one at a time</see>.
/// </remarks>
public Task<ApiKey[]> GetAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<ApiKey[]> GetAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync(_endpoint)
Expand All @@ -80,7 +80,7 @@ public Task<ApiKey[]> GetAllAsync(string onBehalfOf = null, CancellationToken ca
/// <returns>
/// The <see cref="ApiKey" />.
/// </returns>
public Task<ApiKey> CreateAsync(string name, Parameter<IEnumerable<string>> scopes = default(Parameter<IEnumerable<string>>), string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<ApiKey> CreateAsync(string name, Parameter<IEnumerable<string>> scopes = default, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = CreateJObject(name, scopes);
return _client
Expand All @@ -100,7 +100,7 @@ public Task<ApiKey> CreateAsync(string name, Parameter<IEnumerable<string>> scop
/// <returns>
/// The async task.
/// </returns>
public Task DeleteAsync(string keyId, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task DeleteAsync(string keyId, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.DeleteAsync($"{_endpoint}/{keyId}")
Expand All @@ -118,7 +118,7 @@ public Task DeleteAsync(string keyId, string onBehalfOf = null, CancellationToke
/// <param name="onBehalfOf">The user to impersonate.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The <see cref="ApiKey"/>.</returns>
public Task<ApiKey> UpdateAsync(string keyId, string name, Parameter<IEnumerable<string>> scopes = default(Parameter<IEnumerable<string>>), string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<ApiKey> UpdateAsync(string keyId, string name, Parameter<IEnumerable<string>> scopes = default, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = CreateJObject(name, scopes);
return (scopes.HasValue && (scopes.Value ?? Enumerable.Empty<string>()).Any() ? _client.PutAsync($"{_endpoint}/{keyId}") : _client.PatchAsync($"{_endpoint}/{keyId}"))
Expand All @@ -137,7 +137,7 @@ public Task<ApiKey> UpdateAsync(string keyId, string name, Parameter<IEnumerable
/// <returns>
/// The <see cref="ApiKey" />.
/// </returns>
public Task<ApiKey> CreateWithBillingPermissionsAsync(string name, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<ApiKey> CreateWithBillingPermissionsAsync(string name, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var scopes = new[]
{
Expand All @@ -162,7 +162,7 @@ public Task<ApiKey> CreateWithBillingPermissionsAsync(string name, string onBeha
/// If you specify an API Key when instanciating the <see cref="Client" />, the new API Key will inherit the permissions of that API Key.
/// If you specify a username and password when instanciating the <see cref="Client" />, the new API Key will inherit the permissions of that user.
/// </remarks>
public async Task<ApiKey> CreateWithAllPermissionsAsync(string name, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<ApiKey> CreateWithAllPermissionsAsync(string name, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var scopes = await _client.GetCurrentScopes(true, cancellationToken).ConfigureAwait(false);
var superApiKey = await this.CreateAsync(name, scopes, onBehalfOf, cancellationToken).ConfigureAwait(false);
Expand All @@ -182,7 +182,7 @@ public async Task<ApiKey> CreateWithAllPermissionsAsync(string name, string onBe
/// If you specify an API Key when instanciating the <see cref="Client" />, the new API Key will inherit the "read" permissions of that API Key.
/// If you specify a username and password when instanciating the <see cref="Client" />, the new API Key will inherit the "read" permissions of that user.
/// </remarks>
public async Task<ApiKey> CreateWithReadOnlyPermissionsAsync(string name, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<ApiKey> CreateWithReadOnlyPermissionsAsync(string name, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var scopes = await _client.GetCurrentScopes(true, cancellationToken).ConfigureAwait(false);
scopes = scopes.Where(s => s.EndsWith(".read", System.StringComparison.OrdinalIgnoreCase)).ToArray();
Expand Down
14 changes: 7 additions & 7 deletions Source/StrongGrid/Resources/Batches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal Batches(Pathoschild.Http.Client.IClient client)
/// <returns>
/// The batch id.
/// </returns>
public Task<string> GenerateBatchIdAsync(CancellationToken cancellationToken = default(CancellationToken))
public Task<string> GenerateBatchIdAsync(CancellationToken cancellationToken = default)
{
return _client
.PostAsync(_endpoint)
Expand All @@ -50,7 +50,7 @@ public Task<string> GenerateBatchIdAsync(CancellationToken cancellationToken = d
/// <returns>
/// <c>true</c> if the batch id is valid; otherwise, <c>false</c>.
/// </returns>
public async Task<bool> ValidateBatchIdAsync(string batchId, CancellationToken cancellationToken = default(CancellationToken))
public async Task<bool> ValidateBatchIdAsync(string batchId, CancellationToken cancellationToken = default)
{
try
{
Expand All @@ -77,7 +77,7 @@ public async Task<bool> ValidateBatchIdAsync(string batchId, CancellationToken c
/// <returns>
/// The async task.
/// </returns>
public Task Cancel(string batchId, CancellationToken cancellationToken = default(CancellationToken))
public Task Cancel(string batchId, CancellationToken cancellationToken = default)
{
var data = new JObject
{
Expand All @@ -99,7 +99,7 @@ public Task Cancel(string batchId, CancellationToken cancellationToken = default
/// <returns>
/// The async task.
/// </returns>
public Task Pause(string batchId, CancellationToken cancellationToken = default(CancellationToken))
public Task Pause(string batchId, CancellationToken cancellationToken = default)
{
var data = new JObject
{
Expand All @@ -120,7 +120,7 @@ public Task Pause(string batchId, CancellationToken cancellationToken = default(
/// <returns>
/// An array of <see cref="BatchInfo" />.
/// </returns>
public Task<BatchInfo[]> GetAllAsync(CancellationToken cancellationToken = default(CancellationToken))
public Task<BatchInfo[]> GetAllAsync(CancellationToken cancellationToken = default)
{
return _client
.GetAsync("user/scheduled_sends")
Expand All @@ -136,7 +136,7 @@ public Task<BatchInfo[]> GetAllAsync(CancellationToken cancellationToken = defau
/// <returns>
/// A <see cref="BatchInfo" />.
/// </returns>
public async Task<BatchInfo> GetAsync(string batchId, CancellationToken cancellationToken = default(CancellationToken))
public async Task<BatchInfo> GetAsync(string batchId, CancellationToken cancellationToken = default)
{
var result = await _client
.GetAsync($"user/scheduled_sends/{batchId}")
Expand All @@ -157,7 +157,7 @@ public async Task<BatchInfo> GetAsync(string batchId, CancellationToken cancella
/// <returns>
/// The async task.
/// </returns>
public Task Resume(string batchId, CancellationToken cancellationToken = default(CancellationToken))
public Task Resume(string batchId, CancellationToken cancellationToken = default)
{
return _client
.DeleteAsync($"{_endpoint}/{batchId}")
Expand Down
10 changes: 5 additions & 5 deletions Source/StrongGrid/Resources/Blocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal Blocks(Pathoschild.Http.Client.IClient client)
/// <returns>
/// An array of <see cref="Block">Blocks</see>.
/// </returns>
public Task<Block[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<Block[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync(_endpoint)
Expand All @@ -66,7 +66,7 @@ public Task<Block[]> GetAllAsync(DateTime? startDate = null, DateTime? endDate =
/// <returns>
/// The <see cref="Block" />.
/// </returns>
public Task<Block[]> GetAsync(string emailAddress, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<Block[]> GetAsync(string emailAddress, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.GetAsync($"{_endpoint}/{emailAddress}")
Expand All @@ -83,7 +83,7 @@ public Task<Block[]> GetAsync(string emailAddress, string onBehalfOf = null, Can
/// <returns>
/// The async task.
/// </returns>
public Task DeleteAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task DeleteAllAsync(string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = new JObject
{
Expand All @@ -106,7 +106,7 @@ public Task DeleteAllAsync(string onBehalfOf = null, CancellationToken cancellat
/// <returns>
/// The async task.
/// </returns>
public Task DeleteMultipleAsync(IEnumerable<string> emailAddresses, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task DeleteMultipleAsync(IEnumerable<string> emailAddresses, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
var data = new JObject
{
Expand All @@ -129,7 +129,7 @@ public Task DeleteMultipleAsync(IEnumerable<string> emailAddresses, string onBeh
/// <returns>
/// The async task.
/// </returns>
public Task DeleteAsync(string emailAddress, string onBehalfOf = null, CancellationToken cancellationToken = default(CancellationToken))
public Task DeleteAsync(string emailAddress, string onBehalfOf = null, CancellationToken cancellationToken = default)
{
return _client
.DeleteAsync($"{_endpoint}/{emailAddress}")
Expand Down

0 comments on commit d65e4b7

Please sign in to comment.