summaryrefslogtreecommitdiffstats
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
commit7b02b282e5df1d0dcfd4a910816e4832684eb0d0 (patch)
tree89103449b9fc00ccd408ad810ef47555394d8471
parent3a948747213aea2adeccacd0c6fa6e66c0437e73 (diff)
downloadsendgrid-csharp-7b02b282e5df1d0dcfd4a910816e4832684eb0d0.zip
sendgrid-csharp-7b02b282e5df1d0dcfd4a910816e4832684eb0d0.tar.gz
sendgrid-csharp-7b02b282e5df1d0dcfd4a910816e4832684eb0d0.tar.bz2
make https configurable
-rwxr-xr-xSendGrid/Example/WEBAPI.cs2
-rw-r--r--SendGrid/SendGridMail/Transport/Web.cs20
2 files changed, 12 insertions, 10 deletions
diff --git a/SendGrid/Example/WEBAPI.cs b/SendGrid/Example/WEBAPI.cs
index d3f8d4a..fd18605 100755
--- a/SendGrid/Example/WEBAPI.cs
+++ b/SendGrid/Example/WEBAPI.cs
@@ -255,7 +255,7 @@ namespace Example
message.Subject = "Hello World Unsubscribe Test";
//create an instance of the Web transport mechanism
- var transportInstance = Web.GetInstance(new NetworkCredential(_username, _password));
+ var transportInstance = Web.GetInstance(new NetworkCredential(_username, _password), true);
//enable spamcheck
//or optionally, you can specify 'replace' instead of the text and html in order to
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);