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

Commit

Permalink
Merge branch 'release/7.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Jun 15, 2017
2 parents 62f0352 + 462721f commit d0c7a45
Show file tree
Hide file tree
Showing 13 changed files with 2,596 additions and 101 deletions.
2 changes: 1 addition & 1 deletion GitReleaseManager.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
create:
include-footer: true
include-footer: false
footer-heading: Where to get it
footer-content: You can download this release from [nuget.org](https://www.nuget.org/packages/CakeMail.RestClient/{milestone})
footer-includes-milestone: true
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Pre-release packages are available on my MyGet feed:
- `IF`, `ELSEIF`, `ELSE` and `ENDIF` must be upper case which means that ``[IF `myfield` = "myValue"]`` is valid but ``[if `myfield` = "myValue"]`` is not.
- square bracket is the delimeter which means that ``[IF `myfield` = "myValue"]`` is valid but ``{IF `myfield` = "myValue"}`` is not.
- 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.
- you can only compare a field to a constant value which means that ``[IF `firstname` = "Bob"]`` is valid but ``[IF `firstname` = `nickname`]`` is not.
- 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.
- 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.
- 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.
- the constant value must not be surrounded by any quotes when it's a numeric value which means that ``[IF `age` >= 18]`` is valid.
- 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.
- you can have multiple conditions seperated by `AND` or `OR` which means that ``IF `firstname` = "Bob" AND `lastname` = "Smith"]`` is valid.
- the acceptable operators when comparing a field to a string value: `<`, `<=`, `=`, `!=`, `>=`, `>`, `LIKE` and `NOT LIKE`
Expand Down
49 changes: 49 additions & 0 deletions Source/CakeMail.RestClient.IntegrationTests/ConsoleLogProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace CakeMail.RestClient.IntegrationTests
{
using Logging;
using System;
using System.Globalization;

// 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) =>
{
if (messageFunc == null)
{
return true; // All log levels are enabled
}

var message = string.Format(CultureInfo.InvariantCulture, messageFunc(), formatParameters);
if (exception != null)
{
message = message + "|" + exception;
}
Console.WriteLine("{0} | {1} | {2} | {3}", DateTime.UtcNow, logLevel, name, message);

return true;
};
}

public IDisposable OpenNestedContext(string message)
{
return NullDisposable.Instance;
}

public IDisposable OpenMappedContext(string key, string value)
{
return NullDisposable.Instance;
}

private class NullDisposable : IDisposable
{
internal static readonly IDisposable Instance = new NullDisposable();

public void Dispose()
{ }
}
}
}
92 changes: 48 additions & 44 deletions Source/CakeMail.RestClient.IntegrationTests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,61 @@
using System;
using CakeMail.RestClient.Logging;
using System;

namespace CakeMail.RestClient.IntegrationTests
{
public class Program
{
public static void Main()
{
Console.WriteLine("{0} Executing all CakeMail API methods ... {0}", new string('=', 10));
// -----------------------------------------------------------------------------

// Do you want to proxy requests through Fiddler (useful for debugging)?
var useFiddler = false;

// As an alternative to Fiddler, you can display debug information about
// every HTTP request/response in the console. This is useful for debugging
// purposes but the amount of information can be overwhelming.
var debugHttpMessagesToConsole = true;
// -----------------------------------------------------------------------------

var proxy = useFiddler ? new WebProxy("http://localhost:8888") : null;
var apiKey = Environment.GetEnvironmentVariable("CAKEMAIL_APIKEY");
var userName = Environment.GetEnvironmentVariable("CAKEMAIL_USERNAME");
var password = Environment.GetEnvironmentVariable("CAKEMAIL_PASSWORD");
var overrideClientId = Environment.GetEnvironmentVariable("CAKEMAIL_OVERRIDECLIENTID");

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

try
{
ExecuteAllMethods();
var client = new CakeMailRestClient(apiKey, proxy);
var loginInfo = client.Users.LoginAsync(userName, password).Result;
var clientId = string.IsNullOrEmpty(overrideClientId) ? loginInfo.ClientId : long.Parse(overrideClientId);
var userKey = loginInfo.UserKey;

TimezonesTests.ExecuteAllMethods(client).Wait();
CountriesTests.ExecuteAllMethods(client).Wait();
ClientsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
UsersTests.ExecuteAllMethods(client, userKey, clientId).Wait();
PermissionsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
CampaignsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
ListsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
TemplatesTests.ExecuteAllMethods(client, userKey, clientId).Wait();
SuppressionListsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
RelaysTests.ExecuteAllMethods(client, userKey, clientId).Wait();
TriggersTests.ExecuteAllMethods(client, userKey, clientId).Wait();
MailingsTests.ExecuteAllMethods(client, userKey, clientId).Wait();
}
catch (Exception e)
{
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("An error has occured: {0}", (e.InnerException ?? e).Message);
Console.WriteLine("\n\n**************************************************");
Console.WriteLine("**************************************************");
Console.WriteLine($"AN EXCEPTION OCCURED: {(e.InnerException ?? e).Message}");
Console.WriteLine("**************************************************");
Console.WriteLine("**************************************************");
}
finally
{
Expand All @@ -25,46 +64,11 @@ public static void Main()
{
Console.ReadKey();
}

Console.WriteLine("");
Console.WriteLine("Press any key...");
Console.WriteLine("\n\n*************************");
Console.WriteLine("All tests completed");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}

private static void ExecuteAllMethods()
{
// -----------------------------------------------------------------------------

// Do you want to proxy requests through Fiddler (useful for debugging)?
var useFiddler = false;

// -----------------------------------------------------------------------------


var proxy = useFiddler ? new WebProxy("http://localhost:8888") : null;
var apiKey = Environment.GetEnvironmentVariable("CAKEMAIL_APIKEY");
var userName = Environment.GetEnvironmentVariable("CAKEMAIL_USERNAME");
var password = Environment.GetEnvironmentVariable("CAKEMAIL_PASSWORD");
var overrideClientId = Environment.GetEnvironmentVariable("CAKEMAIL_OVERRIDECLIENTID");

var api = new CakeMailRestClient(apiKey, proxy);
var loginInfo = api.Users.LoginAsync(userName, password).Result;
var clientId = string.IsNullOrEmpty(overrideClientId) ? loginInfo.ClientId : long.Parse(overrideClientId);
var userKey = loginInfo.UserKey;

TimezonesTests.ExecuteAllMethods(api).Wait();
CountriesTests.ExecuteAllMethods(api).Wait();
ClientsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
UsersTests.ExecuteAllMethods(api, userKey, clientId).Wait();
PermissionsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
CampaignsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
ListsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
TemplatesTests.ExecuteAllMethods(api, userKey, clientId).Wait();
SuppressionListsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
RelaysTests.ExecuteAllMethods(api, userKey, clientId).Wait();
TriggersTests.ExecuteAllMethods(api, userKey, clientId).Wait();
MailingsTests.ExecuteAllMethods(api, userKey, clientId).Wait();
}
}
}
1 change: 1 addition & 0 deletions Source/CakeMail.RestClient/CakeMailRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public CakeMailRestClient(string apiKey, string host = DEFAULT_HOST, HttpClient
_fluentClient.BaseClient.DefaultRequestHeaders.Add("apikey", this.ApiKey);

_fluentClient.Filters.Remove<DefaultErrorFilter>();
_fluentClient.Filters.Add(new DiagnosticHandler());
_fluentClient.Filters.Add(new CakeMailErrorHandler());

Campaigns = new Campaigns(_fluentClient);
Expand Down
Loading

0 comments on commit d0c7a45

Please sign in to comment.