Skip to content
This repository was archived by the owner on Jul 29, 2022. It is now read-only.

Commit d0c7a45

Browse files
committed
Merge branch 'release/7.2.0'
2 parents 62f0352 + 462721f commit d0c7a45

File tree

13 files changed

+2596
-101
lines changed

13 files changed

+2596
-101
lines changed

GitReleaseManager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
create:
2-
include-footer: true
2+
include-footer: false
33
footer-heading: Where to get it
44
footer-content: You can download this release from [nuget.org](https://www.nuget.org/packages/CakeMail.RestClient/{milestone})
55
footer-includes-milestone: true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Pre-release packages are available on my MyGet feed:
3030
- `IF`, `ELSEIF`, `ELSE` and `ENDIF` must be upper case which means that ``[IF `myfield` = "myValue"]`` is valid but ``[if `myfield` = "myValue"]`` is not.
3131
- square bracket is the delimeter which means that ``[IF `myfield` = "myValue"]`` is valid but ``{IF `myfield` = "myValue"}`` is not.
3232
- the name of the data field must be surrounded by back ticks (not to be confused with single quotes) which means that ``[IF `firstname` = "Bob"]`` is valid but ``[IF 'firstname' = "Bob"]`` is not.
33-
- you can only compare a field to a constant value which means that ``[IF `firstname` = "Bob"]`` is valid but ``[IF `firstname` = `nickname`]`` is not.
33+
- you can only compare a field to a constant value and you can't compare a field to another field which means that ``[IF `firstname` = "Bob"]`` is valid but ``[IF `firstname` = `nickname`]`` is not.
3434
- the constant value must be surrounded with double quotes when it's a string which means that ``[IF `firstname` = "Bob"]`` is valid but ``[IF `firstname` = 'Bob']`` is not.
35-
- the constant value must not be surrounded by any quotes is a numeric valu when it's a numeric value which means that ``[IF `age` >= 18]`` is valid.
35+
- the constant value must not be surrounded by any quotes when it's a numeric value which means that ``[IF `age` >= 18]`` is valid.
3636
- the data field must be on the left side of the comparison which means that ``[IF `gender` = \"Male\"]`` is valid but ``[IF \"Male\" = `gender`]`` is not.
3737
- you can have multiple conditions seperated by `AND` or `OR` which means that ``IF `firstname` = "Bob" AND `lastname` = "Smith"]`` is valid.
3838
- the acceptable operators when comparing a field to a string value: `<`, `<=`, `=`, `!=`, `>=`, `>`, `LIKE` and `NOT LIKE`
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
namespace CakeMail.RestClient.IntegrationTests
2+
{
3+
using Logging;
4+
using System;
5+
using System.Globalization;
6+
7+
// Inspired by: https://github.com/damianh/LibLog/blob/master/src/LibLog.Example.ColoredConsoleLogProvider/ColoredConsoleLogProvider.cs
8+
public class ConsoleLogProvider : ILogProvider
9+
{
10+
11+
public Logger GetLogger(string name)
12+
{
13+
return (logLevel, messageFunc, exception, formatParameters) =>
14+
{
15+
if (messageFunc == null)
16+
{
17+
return true; // All log levels are enabled
18+
}
19+
20+
var message = string.Format(CultureInfo.InvariantCulture, messageFunc(), formatParameters);
21+
if (exception != null)
22+
{
23+
message = message + "|" + exception;
24+
}
25+
Console.WriteLine("{0} | {1} | {2} | {3}", DateTime.UtcNow, logLevel, name, message);
26+
27+
return true;
28+
};
29+
}
30+
31+
public IDisposable OpenNestedContext(string message)
32+
{
33+
return NullDisposable.Instance;
34+
}
35+
36+
public IDisposable OpenMappedContext(string key, string value)
37+
{
38+
return NullDisposable.Instance;
39+
}
40+
41+
private class NullDisposable : IDisposable
42+
{
43+
internal static readonly IDisposable Instance = new NullDisposable();
44+
45+
public void Dispose()
46+
{ }
47+
}
48+
}
49+
}
Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,61 @@
1-
using System;
1+
using CakeMail.RestClient.Logging;
2+
using System;
23

34
namespace CakeMail.RestClient.IntegrationTests
45
{
56
public class Program
67
{
78
public static void Main()
89
{
9-
Console.WriteLine("{0} Executing all CakeMail API methods ... {0}", new string('=', 10));
10+
// -----------------------------------------------------------------------------
11+
12+
// Do you want to proxy requests through Fiddler (useful for debugging)?
13+
var useFiddler = false;
14+
15+
// As an alternative to Fiddler, you can display debug information about
16+
// every HTTP request/response in the console. This is useful for debugging
17+
// purposes but the amount of information can be overwhelming.
18+
var debugHttpMessagesToConsole = true;
19+
// -----------------------------------------------------------------------------
20+
21+
var proxy = useFiddler ? new WebProxy("http://localhost:8888") : null;
22+
var apiKey = Environment.GetEnvironmentVariable("CAKEMAIL_APIKEY");
23+
var userName = Environment.GetEnvironmentVariable("CAKEMAIL_USERNAME");
24+
var password = Environment.GetEnvironmentVariable("CAKEMAIL_PASSWORD");
25+
var overrideClientId = Environment.GetEnvironmentVariable("CAKEMAIL_OVERRIDECLIENTID");
26+
27+
if (debugHttpMessagesToConsole)
28+
{
29+
LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());
30+
}
1031

1132
try
1233
{
13-
ExecuteAllMethods();
34+
var client = new CakeMailRestClient(apiKey, proxy);
35+
var loginInfo = client.Users.LoginAsync(userName, password).Result;
36+
var clientId = string.IsNullOrEmpty(overrideClientId) ? loginInfo.ClientId : long.Parse(overrideClientId);
37+
var userKey = loginInfo.UserKey;
38+
39+
TimezonesTests.ExecuteAllMethods(client).Wait();
40+
CountriesTests.ExecuteAllMethods(client).Wait();
41+
ClientsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
42+
UsersTests.ExecuteAllMethods(client, userKey, clientId).Wait();
43+
PermissionsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
44+
CampaignsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
45+
ListsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
46+
TemplatesTests.ExecuteAllMethods(client, userKey, clientId).Wait();
47+
SuppressionListsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
48+
RelaysTests.ExecuteAllMethods(client, userKey, clientId).Wait();
49+
TriggersTests.ExecuteAllMethods(client, userKey, clientId).Wait();
50+
MailingsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
1451
}
1552
catch (Exception e)
1653
{
17-
Console.WriteLine("");
18-
Console.WriteLine("");
19-
Console.WriteLine("An error has occured: {0}", (e.InnerException ?? e).Message);
54+
Console.WriteLine("\n\n**************************************************");
55+
Console.WriteLine("**************************************************");
56+
Console.WriteLine($"AN EXCEPTION OCCURED: {(e.InnerException ?? e).Message}");
57+
Console.WriteLine("**************************************************");
58+
Console.WriteLine("**************************************************");
2059
}
2160
finally
2261
{
@@ -25,46 +64,11 @@ public static void Main()
2564
{
2665
Console.ReadKey();
2766
}
28-
29-
Console.WriteLine("");
30-
Console.WriteLine("Press any key...");
67+
Console.WriteLine("\n\n*************************");
68+
Console.WriteLine("All tests completed");
69+
Console.WriteLine("Press any key to exit");
3170
Console.ReadKey();
3271
}
3372
}
34-
35-
private static void ExecuteAllMethods()
36-
{
37-
// -----------------------------------------------------------------------------
38-
39-
// Do you want to proxy requests through Fiddler (useful for debugging)?
40-
var useFiddler = false;
41-
42-
// -----------------------------------------------------------------------------
43-
44-
45-
var proxy = useFiddler ? new WebProxy("http://localhost:8888") : null;
46-
var apiKey = Environment.GetEnvironmentVariable("CAKEMAIL_APIKEY");
47-
var userName = Environment.GetEnvironmentVariable("CAKEMAIL_USERNAME");
48-
var password = Environment.GetEnvironmentVariable("CAKEMAIL_PASSWORD");
49-
var overrideClientId = Environment.GetEnvironmentVariable("CAKEMAIL_OVERRIDECLIENTID");
50-
51-
var api = new CakeMailRestClient(apiKey, proxy);
52-
var loginInfo = api.Users.LoginAsync(userName, password).Result;
53-
var clientId = string.IsNullOrEmpty(overrideClientId) ? loginInfo.ClientId : long.Parse(overrideClientId);
54-
var userKey = loginInfo.UserKey;
55-
56-
TimezonesTests.ExecuteAllMethods(api).Wait();
57-
CountriesTests.ExecuteAllMethods(api).Wait();
58-
ClientsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
59-
UsersTests.ExecuteAllMethods(api, userKey, clientId).Wait();
60-
PermissionsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
61-
CampaignsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
62-
ListsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
63-
TemplatesTests.ExecuteAllMethods(api, userKey, clientId).Wait();
64-
SuppressionListsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
65-
RelaysTests.ExecuteAllMethods(api, userKey, clientId).Wait();
66-
TriggersTests.ExecuteAllMethods(api, userKey, clientId).Wait();
67-
MailingsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
68-
}
6973
}
7074
}

Source/CakeMail.RestClient/CakeMailRestClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public CakeMailRestClient(string apiKey, string host = DEFAULT_HOST, HttpClient
161161
_fluentClient.BaseClient.DefaultRequestHeaders.Add("apikey", this.ApiKey);
162162

163163
_fluentClient.Filters.Remove<DefaultErrorFilter>();
164+
_fluentClient.Filters.Add(new DiagnosticHandler());
164165
_fluentClient.Filters.Add(new CakeMailErrorHandler());
165166

166167
Campaigns = new Campaigns(_fluentClient);

0 commit comments

Comments
 (0)