summaryrefslogtreecommitdiffstats
path: root/SendGrid/SendGridMail/Transport
diff options
context:
space:
mode:
authorBrandon West <brawest@gmail.com>2013-01-14 12:11:52 -0700
committerBrandon West <brawest@gmail.com>2013-01-14 12:11:52 -0700
commit030dbc8e420e3942dac8d36db1d69432c0cea092 (patch)
tree7add6add3973e8b1ca6b6876a6081c765ee3da48 /SendGrid/SendGridMail/Transport
parentff4c6524b6c29c9f4243225f651bfe44c3c51268 (diff)
downloadsendgrid-csharp-030dbc8e420e3942dac8d36db1d69432c0cea092.zip
sendgrid-csharp-030dbc8e420e3942dac8d36db1d69432c0cea092.tar.gz
sendgrid-csharp-030dbc8e420e3942dac8d36db1d69432c0cea092.tar.bz2
make https configurable
Diffstat (limited to 'SendGrid/SendGridMail/Transport')
-rw-r--r--SendGrid/SendGridMail/Transport/Web.cs20
1 files changed, 11 insertions, 9 deletions
diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs
index ebb2982..6ff89d5 100644
--- a/SendGrid/SendGridMail/Transport/Web.cs
+++ b/SendGrid/SendGridMail/Transport/Web.cs
@@ -13,32 +13,34 @@ namespace SendGridMail.Transport
{
#region Properties
//TODO: Make this configurable
- public const String BaseURl = "https://sendgrid.com/api/";
+ public const String BaseURl = "sendgrid.com/api/";
public const String Endpoint = "mail.send";
public const String JsonFormat = "json";
public const String XmlFormat = "xml";
private readonly NetworkCredential _credentials;
+ private readonly bool Https;
#endregion
/// <summary>
/// Factory method for Web transport of sendgrid messages
/// </summary>
/// <param name="credentials">SendGrid credentials for sending mail messages</param>
- /// <param name="url">The uri of the Web endpoint</param>
+ /// <param name="https">Use https?</param>
/// <returns>New instance of the transport mechanism</returns>
- public static Web GetInstance(NetworkCredential credentials, String url = Endpoint)
+ public static Web GetInstance(NetworkCredential credentials, bool https = true)
{
- return new Web(credentials, url);
+ return new Web(credentials, https);
}
- /// <summary>
- /// Creates a new Web interface for sending mail. Preference is using the Factory method.
+ /// <summary>
+ /// Creates a new Web interface for sending mail. Preference is using the Factory method.
/// </summary>
/// <param name="credentials">SendGrid user parameters</param>
- /// <param name="url">The uri of the Web endpoint</param>
- internal Web(NetworkCredential credentials, String url = Endpoint)
+ /// <param name="https">Use https?</param>
+ internal Web(NetworkCredential credentials, bool https = true)
{
+ Https = https;
_credentials = credentials;
}
@@ -48,7 +50,7 @@ namespace SendGridMail.Transport
/// <param name="message"></param>
public void Deliver(ISendGrid message)
{
- var client = new RestClient(BaseURl);
+ var client = Https ? new RestClient("https://" + BaseURl) : new RestClient("http://" + BaseURl);
var request = new RestRequest(Endpoint + ".xml", Method.POST);
AttachFormParams(message, request);
AttachFiles(message, request);