using System;
using NUnit.Framework;
using SendGrid.Helpers.Mail;
using System.Collections.Generic;
using System.Net;
using Newtonsoft.Json;
namespace UnitTest
{
// Test the building of the v3/mail/send request body
[TestFixture]
public class Mail
{
static string _apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
public dynamic sg = new SendGrid.SendGridAPIClient(_apiKey);
// Base case for sending an email
[Test]
public void TestHelloEmail()
{
SendGrid.Helpers.Mail.Mail mail = new SendGrid.Helpers.Mail.Mail();
Email email = new Email();
email.Address = "test@example.com";
mail.From = email;
Personalization personalization = new Personalization();
email = new Email();
email.Address = "test@example.com";
personalization.AddTo(email);
mail.AddPersonalization(personalization);
mail.Subject = "Hello World from the SendGrid CSharp Library";
Content content = new Content();
content.Type = "text/plain";
content.Value = "Textual content";
mail.AddContent(content);
content = new Content();
content.Type = "text/html";
content.Value = "
HTML content";
mail.AddContent(content);
String ret = mail.Get();
String final = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(ret),
Formatting.None,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore });
Assert.AreEqual(final, "{\"from\":{\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid CSharp Library\",\"personalizations\":[{\"to\":[{\"email\":\"test@example.com\"}]}],\"content\":[{\"type\":\"text/plain\",\"value\":\"Textual content\"},{\"type\":\"text/html\",\"value\":\"HTML content\"}]}");
}
// All paramaters available for sending an email
[Test]
public void TestKitchenSink()
{
SendGrid.Helpers.Mail.Mail mail = new SendGrid.Helpers.Mail.Mail();
Email email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
mail.From = email;
mail.Subject = "Hello World from the SendGrid CSharp Library";
Personalization personalization = new Personalization();
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddTo(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddCc(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddCc(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddBcc(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddBcc(email);
personalization.Subject = "Thank you for signing up, %name%";
personalization.AddHeader("X-Test", "True");
personalization.AddHeader("X-Mock", "True");
personalization.AddSubstitution("%name%", "Example User");
personalization.AddSubstitution("%city%", "Denver");
personalization.AddCustomArgs("marketing", "false");
personalization.AddCustomArgs("transactional", "true");
personalization.SendAt = 1461775051;
mail.AddPersonalization(personalization);
personalization = new Personalization();
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddTo(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddCc(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddCc(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddBcc(email);
email = new Email();
email.Name = "Example User";
email.Address = "test@example.com";
personalization.AddBcc(email);
personalization.Subject = "Thank you for signing up, %name%";
personalization.AddHeader("X-Test", "True");
personalization.AddHeader("X-Mock", "True");
personalization.AddSubstitution("%name%", "Example User");
personalization.AddSubstitution("%city%", "Denver");
personalization.AddCustomArgs("marketing", "false");
personalization.AddCustomArgs("transactional", "true");
personalization.SendAt = 1461775051;
mail.AddPersonalization(personalization);
Content content = new Content();
content.Type = "text/plain";
content.Value = "Textual content";
mail.AddContent(content);
content = new Content();
content.Type = "text/html";
content.Value = "HTML content";
mail.AddContent(content);
content = new Content();
content.Type = "text/calendar";
content.Value = "Party Time!!";
mail.AddContent(content);
Attachment attachment = new Attachment();
attachment.Content = "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12";
attachment.Type = "application/pdf";
attachment.Filename = "balance_001.pdf";
attachment.Disposition = "attachment";
attachment.ContentId = "Balance Sheet";
mail.AddAttachment(attachment);
attachment = new Attachment();
attachment.Content = "BwdW";
attachment.Type = "image/png";
attachment.Filename = "banner.png";
attachment.Disposition = "inline";
attachment.ContentId = "Banner";
mail.AddAttachment(attachment);
mail.TemplateId = "13b8f94f-bcae-4ec6-b752-70d6cb59f932";
mail.AddHeader("X-Day", "Monday");
mail.AddHeader("X-Month", "January");
mail.AddSection("%section1", "Substitution for Section 1 Tag");
mail.AddSection("%section2", "Substitution for Section 2 Tag");
mail.AddCategory("customer");
mail.AddCategory("vip");
mail.AddCustomArgs("campaign", "welcome");
mail.AddCustomArgs("sequence", "2");
ASM asm = new ASM();
asm.GroupId = 3;
List groups_to_display = new List()
{
1, 4, 5
};
asm.GroupsToDisplay = groups_to_display;
mail.Asm = asm;
mail.SendAt = 1461775051;
mail.SetIpPoolId = "23";
// This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
// mail.BatchId = "some_batch_id";
MailSettings mailSettings = new MailSettings();
BCCSettings bccSettings = new BCCSettings();
bccSettings.Enable = true;
bccSettings.Email = "test@example.com";
mailSettings.BccSettings = bccSettings;
BypassListManagement bypassListManagement = new BypassListManagement();
bypassListManagement.Enable = true;
mailSettings.BypassListManagement = bypassListManagement;
FooterSettings footerSettings = new FooterSettings();
footerSettings.Enable = true;
footerSettings.Text = "Some Footer Text";
footerSettings.Html = "Some HTML Here";
mailSettings.FooterSettings = footerSettings;
SandboxMode sandboxMode = new SandboxMode();
sandboxMode.Enable = true;
mailSettings.SandboxMode = sandboxMode;
SpamCheck spamCheck = new SpamCheck();
spamCheck.Enable = true;
spamCheck.Threshold = 1;
spamCheck.PostToUrl = "https://gotchya.example.com";
mailSettings.SpamCheck = spamCheck;
mail.MailSettings = mailSettings;
TrackingSettings trackingSettings = new TrackingSettings();
ClickTracking clickTracking = new ClickTracking();
clickTracking.Enable = true;
clickTracking.EnableText = false;
trackingSettings.ClickTracking = clickTracking;
OpenTracking openTracking = new OpenTracking();
openTracking.Enable = true;
openTracking.SubstitutionTag = "Optional tag to replace with the open image in the body of the message";
trackingSettings.OpenTracking = openTracking;
SubscriptionTracking subscriptionTracking = new SubscriptionTracking();
subscriptionTracking.Enable = true;
subscriptionTracking.Text = "text to insert into the text/plain portion of the message";
subscriptionTracking.Html = "HTML to insert into the text/html portion of the message";
subscriptionTracking.SubstitutionTag = "text to insert into the text/plain portion of the message";
trackingSettings.SubscriptionTracking = subscriptionTracking;
Ganalytics ganalytics = new Ganalytics();
ganalytics.Enable = true;
ganalytics.UtmCampaign = "some campaign";
ganalytics.UtmContent = "some content";
ganalytics.UtmMedium = "some medium";
ganalytics.UtmSource = "some source";
ganalytics.UtmTerm = "some term";
trackingSettings.Ganalytics = ganalytics;
mail.TrackingSettings = trackingSettings;
email = new Email();
email.Address = "test@example.com";
mail.ReplyTo = email;
String ret = mail.Get();
String final = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(ret),
Formatting.None,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore });
Assert.AreEqual(final, "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid CSharp Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Thank you for signing up, %name%\",\"headers\":{\"X-Test\":\"True\",\"X-Mock\":\"True\"},\"substitutions\":{\"%name%\":\"Example User\",\"%city%\":\"Denver\"},\"custom_args\":{\"marketing\":\"false\",\"transactional\":\"true\"},\"send_at\":1461775051},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Thank you for signing up, %name%\",\"headers\":{\"X-Test\":\"True\",\"X-Mock\":\"True\"},\"substitutions\":{\"%name%\":\"Example User\",\"%city%\":\"Denver\"},\"custom_args\":{\"marketing\":\"false\",\"transactional\":\"true\"},\"send_at\":1461775051}],\"content\":[{\"type\":\"text/plain\",\"value\":\"Textual content\"},{\"type\":\"text/html\",\"value\":\"HTML content\"},{\"type\":\"text/calendar\",\"value\":\"Party Time!!\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"headers\":{\"X-Day\":\"Monday\",\"X-Month\":\"January\"},\"sections\":{\"%section1\":\"Substitution for Section 1 Tag\",\"%section2\":\"Substitution for Section 2 Tag\"},\"categories\":[\"customer\",\"vip\"],\"custom_args\":{\"campaign\":\"welcome\",\"sequence\":\"2\"},\"send_at\":1461775051,\"asm\":{\"group_id\":3,\"groups_to_display\":[1,4,5]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Some Footer Text\",\"html\":\"Some HTML Here\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://gotchya.example.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"HTML to insert into the text/html portion of the message\",\"substitution_tag\":\"text to insert into the text/plain portion of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_medium\":\"some medium\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some campaign\"}},\"reply_to\":{\"email\":\"test@example.com\"}}");
}
}
[TestFixture]
public class v3WebAPI
{
[Test]
public void test_access_settings_activity_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'limit': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.access_settings.activity.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_access_settings_whitelist_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'ips': [
{
'ip': '192.168.1.1'
},
{
'ip': '192.*.*.*'
},
{
'ip': '192.168.1.3/32'
}
]
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.access_settings.whitelist.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_access_settings_whitelist_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.access_settings.whitelist.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_access_settings_whitelist_delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'ids': [
1,
2,
3
]
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.access_settings.whitelist.delete(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_access_settings_whitelist__rule_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var rule_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.access_settings.whitelist._(rule_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_access_settings_whitelist__rule_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var rule_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.access_settings.whitelist._(rule_id).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_alerts_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'email_to': 'example@example.com',
'frequency': 'daily',
'type': 'stats_notification'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.alerts.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_alerts_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.alerts.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_alerts__alert_id__patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'email_to': 'example@example.com'
}";
var alert_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.alerts._(alert_id).patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_alerts__alert_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var alert_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.alerts._(alert_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_alerts__alert_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var alert_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.alerts._(alert_id).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_api_keys_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'My API Key',
'sample': 'data',
'scopes': [
'mail.send',
'alerts.create',
'alerts.read'
]
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.api_keys.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_api_keys_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'limit': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.api_keys.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_api_keys__api_key_id__put()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'A New Hope',
'scopes': [
'user.profile.read',
'user.profile.update'
]
}";
var api_key_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.api_keys._(api_key_id).put(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_api_keys__api_key_id__patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'A New Hope'
}";
var api_key_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.api_keys._(api_key_id).patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_api_keys__api_key_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var api_key_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.api_keys._(api_key_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_api_keys__api_key_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var api_key_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.api_keys._(api_key_id).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_asm_groups_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'description': 'Suggestions for products our users might like.',
'is_default': true,
'name': 'Product Suggestions'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.asm.groups.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_asm_groups_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'id': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.asm.groups.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_asm_groups__group_id__patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'description': 'Suggestions for items our users might like.',
'id': 103,
'name': 'Item Suggestions'
}";
var group_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.asm.groups._(group_id).patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_asm_groups__group_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var group_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.asm.groups._(group_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_asm_groups__group_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var group_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.asm.groups._(group_id).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_asm_groups__group_id__suppressions_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'recipient_emails': [
'test1@example.com',
'test2@example.com'
]
}";
var group_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.asm.groups._(group_id).suppressions.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_asm_groups__group_id__suppressions_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var group_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.asm.groups._(group_id).suppressions.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_asm_groups__group_id__suppressions_search_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'recipient_emails': [
'exists1@example.com',
'exists2@example.com',
'doesnotexists@example.com'
]
}";
var group_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.asm.groups._(group_id).suppressions.search.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_asm_groups__group_id__suppressions__email__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var group_id = "test_url_param";
var email = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.asm.groups._(group_id).suppressions._(email).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_asm_suppressions_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.asm.suppressions.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_asm_suppressions_global_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'recipient_emails': [
'test1@example.com',
'test2@example.com'
]
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.asm.suppressions.global.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_asm_suppressions_global__email__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var email = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.asm.suppressions.global._(email).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_asm_suppressions_global__email__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var email = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.asm.suppressions.global._(email).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_asm_suppressions__email__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var email = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.asm.suppressions._(email).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_browsers_stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'browsers': 'test_string',
'end_date': '2016-04-01',
'limit': 'test_string',
'offset': 'test_string',
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.browsers.stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_campaigns_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'categories': [
'spring line'
],
'custom_unsubscribe_url': '',
'html_content': 'Check out our spring line!
',
'ip_pool': 'marketing',
'list_ids': [
110,
124
],
'plain_content': 'Check out our spring line!',
'segment_ids': [
110
],
'sender_id': 124451,
'subject': 'New Products for Spring!',
'suppression_group_id': 42,
'title': 'March Newsletter'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.campaigns.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_campaigns_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'limit': 1,
'offset': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.campaigns.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_campaigns__campaign_id__patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'categories': [
'summer line'
],
'html_content': 'Check out our summer line!
',
'plain_content': 'Check out our summer line!',
'subject': 'New Products for Summer!',
'title': 'May Newsletter'
}";
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.campaigns._(campaign_id).patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_campaigns__campaign_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.campaigns._(campaign_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_campaigns__campaign_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.campaigns._(campaign_id).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_campaigns__campaign_id__schedules_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'send_at': 1489451436
}";
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.campaigns._(campaign_id).schedules.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_campaigns__campaign_id__schedules_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'send_at': 1489771528
}";
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.campaigns._(campaign_id).schedules.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_campaigns__campaign_id__schedules_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.campaigns._(campaign_id).schedules.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_campaigns__campaign_id__schedules_delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.campaigns._(campaign_id).schedules.delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_campaigns__campaign_id__schedules_now_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.campaigns._(campaign_id).schedules.now.post(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_campaigns__campaign_id__schedules_test_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'to': 'your.email@example.com'
}";
var campaign_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.campaigns._(campaign_id).schedules.test.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_categories_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'category': 'test_string',
'limit': 1,
'offset': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.categories.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_categories_stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'categories': 'test_string',
'end_date': '2016-04-01',
'limit': 1,
'offset': 1,
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.categories.stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_categories_stats_sums_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
'limit': 1,
'offset': 1,
'sort_by_direction': 'asc',
'sort_by_metric': 'test_string',
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.categories.stats.sums.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_clients_stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.clients.stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_clients__client_type__stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
'start_date': '2016-01-01'
}";
var client_type = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.clients._(client_type).stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_custom_fields_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'pet',
'type': 'text'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.contactdb.custom_fields.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_contactdb_custom_fields_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.custom_fields.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_custom_fields__custom_field_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var custom_field_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.custom_fields._(custom_field_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_custom_fields__custom_field_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var custom_field_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "202");
dynamic response = sg.client.contactdb.custom_fields._(custom_field_id).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Accepted);
}
[Test]
public void test_contactdb_lists_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'your list name'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.contactdb.lists.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_contactdb_lists_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.lists.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_lists_delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"[
1,
2,
3,
4
]";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.contactdb.lists.delete(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_contactdb_lists__list_id__patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'newlistname'
}";
string queryParams = @"{
'list_id': 1
}";
var list_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.lists._(list_id).patch(requestBody: data, queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_lists__list_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'list_id': 1
}";
var list_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.lists._(list_id).get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_lists__list_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'delete_contacts': 'true'
}";
var list_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "202");
dynamic response = sg.client.contactdb.lists._(list_id).delete(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Accepted);
}
[Test]
public void test_contactdb_lists__list_id__recipients_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"[
'recipient_id1',
'recipient_id2'
]";
var list_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.contactdb.lists._(list_id).recipients.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_contactdb_lists__list_id__recipients_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'list_id': 1,
'page': 1,
'page_size': 1
}";
var list_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.lists._(list_id).recipients.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_lists__list_id__recipients__recipient_id__post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var list_id = "test_url_param";
var recipient_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).post(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_contactdb_lists__list_id__recipients__recipient_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'list_id': 1,
'recipient_id': 1
}";
var list_id = "test_url_param";
var recipient_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).delete(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_contactdb_recipients_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"[
{
'email': 'jones@example.com',
'first_name': 'Guy',
'last_name': 'Jones'
}
]";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.contactdb.recipients.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_contactdb_recipients_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"[
{
'age': 25,
'email': 'example@example.com',
'first_name': '',
'last_name': 'User'
},
{
'age': 25,
'email': 'example2@example.com',
'first_name': 'Example',
'last_name': 'User'
}
]";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.contactdb.recipients.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_contactdb_recipients_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'page': 1,
'page_size': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.recipients.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_recipients_delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"[
'recipient_id1',
'recipient_id2'
]";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.recipients.delete(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_recipients_billable_count_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.recipients.billable_count.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_recipients_count_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.recipients.count.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_recipients_search_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'%7Bfield_name%7D': 'test_string',
'{field_name}': 'test_string'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.recipients.search.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_recipients__recipient_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var recipient_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.recipients._(recipient_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_recipients__recipient_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var recipient_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.contactdb.recipients._(recipient_id).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_contactdb_recipients__recipient_id__lists_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var recipient_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.recipients._(recipient_id).lists.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_reserved_fields_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.reserved_fields.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_segments_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'conditions': [
{
'and_or': '',
'field': 'last_name',
'operator': 'eq',
'value': 'Miller'
},
{
'and_or': 'and',
'field': 'last_clicked',
'operator': 'gt',
'value': '01/02/2015'
},
{
'and_or': 'or',
'field': 'clicks.campaign_identifier',
'operator': 'eq',
'value': '513'
}
],
'list_id': 4,
'name': 'Last Name Miller'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.segments.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_segments_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.segments.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_segments__segment_id__patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'conditions': [
{
'and_or': '',
'field': 'last_name',
'operator': 'eq',
'value': 'Miller'
}
],
'list_id': 5,
'name': 'The Millers'
}";
string queryParams = @"{
'segment_id': 'test_string'
}";
var segment_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.segments._(segment_id).patch(requestBody: data, queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_segments__segment_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'segment_id': 1
}";
var segment_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.segments._(segment_id).get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_contactdb_segments__segment_id__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'delete_contacts': 'true'
}";
var segment_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.contactdb.segments._(segment_id).delete(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_contactdb_segments__segment_id__recipients_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'page': 1,
'page_size': 1
}";
var segment_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.contactdb.segments._(segment_id).recipients.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_devices_stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
'limit': 1,
'offset': 1,
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.devices.stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_geo_stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'country': 'US',
'end_date': '2016-04-01',
'limit': 1,
'offset': 1,
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.geo.stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'exclude_whitelabels': 'true',
'ip': 'test_string',
'limit': 1,
'offset': 1,
'subuser': 'test_string'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_assigned_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.assigned.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_pools_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'marketing'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.pools.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_pools_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.pools.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_pools__pool_name__put()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'name': 'new_pool_name'
}";
var pool_name = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.pools._(pool_name).put(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_pools__pool_name__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var pool_name = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.pools._(pool_name).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_pools__pool_name__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var pool_name = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.ips.pools._(pool_name).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_ips_pools__pool_name__ips_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'ip': '0.0.0.0'
}";
var pool_name = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.ips.pools._(pool_name).ips.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_ips_pools__pool_name__ips__ip__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var pool_name = "test_url_param";
var ip = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.ips.pools._(pool_name).ips._(ip).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_ips_warmup_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'ip': '0.0.0.0'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.warmup.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_warmup_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.warmup.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_warmup__ip_address__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var ip_address = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips.warmup._(ip_address).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_ips_warmup__ip_address__delete()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var ip_address = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "204");
dynamic response = sg.client.ips.warmup._(ip_address).delete(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.NoContent);
}
[Test]
public void test_ips__ip_address__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var ip_address = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.ips._(ip_address).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_batch_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "201");
dynamic response = sg.client.mail.batch.post(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
}
[Test]
public void test_mail_batch__batch_id__get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
var batch_id = "test_url_param";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail.batch._(batch_id).get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_send_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'asm': {
'group_id': 1,
'groups_to_display': [
1,
2,
3
]
},
'attachments': [
{
'content': '[BASE64 encoded content block here]',
'content_id': 'ii_139db99fdb5c3704',
'disposition': 'inline',
'filename': 'file1.jpg',
'name': 'file1',
'type': 'jpg'
}
],
'batch_id': '[YOUR BATCH ID GOES HERE]',
'categories': [
'category1',
'category2'
],
'content': [
{
'type': 'text/html',
'value': 'Hello, world!
'
}
],
'custom_args': {
'New Argument 1': 'New Value 1',
'activationAttempt': '1',
'customerAccountNumber': '[CUSTOMER ACCOUNT NUMBER GOES HERE]'
},
'from': {
'email': 'sam.smith@example.com',
'name': 'Sam Smith'
},
'headers': {},
'ip_pool_name': '[YOUR POOL NAME GOES HERE]',
'mail_settings': {
'bcc': {
'email': 'ben.doe@example.com',
'enable': true
},
'bypass_list_management': {
'enable': true
},
'footer': {
'enable': true,
'html': 'ThanksThe SendGrid Team
',
'text': 'Thanks,/n The SendGrid Team'
},
'sandbox_mode': {
'enable': false
},
'spam_check': {
'enable': true,
'post_to_url': 'http://example.com/compliance',
'threshold': 3
}
},
'personalizations': [
{
'bcc': [
{
'email': 'sam.doe@example.com',
'name': 'Sam Doe'
}
],
'cc': [
{
'email': 'jane.doe@example.com',
'name': 'Jane Doe'
}
],
'custom_args': {
'New Argument 1': 'New Value 1',
'activationAttempt': '1',
'customerAccountNumber': '[CUSTOMER ACCOUNT NUMBER GOES HERE]'
},
'headers': {
'X-Accept-Language': 'en',
'X-Mailer': 'MyApp'
},
'send_at': 1409348513,
'subject': 'Hello, World!',
'substitutions': {
'id': 'substitutions',
'type': 'object'
},
'to': [
{
'email': 'john.doe@example.com',
'name': 'John Doe'
}
]
}
],
'reply_to': {
'email': 'sam.smith@example.com',
'name': 'Sam Smith'
},
'sections': {
'section': {
':sectionName1': 'section 1 text',
':sectionName2': 'section 2 text'
}
},
'send_at': 1409348513,
'subject': 'Hello, World!',
'template_id': '[YOUR TEMPLATE ID GOES HERE]',
'tracking_settings': {
'click_tracking': {
'enable': true,
'enable_text': true
},
'ganalytics': {
'enable': true,
'utm_campaign': '[NAME OF YOUR REFERRER SOURCE]',
'utm_content': '[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]',
'utm_medium': '[NAME OF YOUR MARKETING MEDIUM e.g. email]',
'utm_name': '[NAME OF YOUR CAMPAIGN]',
'utm_term': '[IDENTIFY PAID KEYWORDS HERE]'
},
'open_tracking': {
'enable': true,
'substitution_tag': '%opentrack'
},
'subscription_tracking': {
'enable': true,
'html': 'If you would like to unsubscribe and stop receiving these emails <% clickhere %>.',
'substitution_tag': '<%click here%>',
'text': 'If you would like to unsubscribe and stop receiveing these emails <% click here %>.'
}
}
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "202");
dynamic response = sg.client.mail.send.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.Accepted);
}
[Test]
public void test_mail_settings_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'limit': 1,
'offset': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_address_whitelist_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'enabled': true,
'list': [
'email1@example.com',
'example.com'
]
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.address_whitelist.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_address_whitelist_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.address_whitelist.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_bcc_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'email': 'email@example.com',
'enabled': false
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.bcc.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_bcc_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.bcc.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_bounce_purge_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'enabled': true,
'hard_bounces': 5,
'soft_bounces': 5
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.bounce_purge.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_bounce_purge_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.bounce_purge.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_footer_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'enabled': true,
'html_content': '...',
'plain_content': '...'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.footer.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_footer_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.footer.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_forward_bounce_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'email': 'example@example.com',
'enabled': true
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.forward_bounce.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_forward_bounce_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.forward_bounce.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_forward_spam_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'email': '',
'enabled': false
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.forward_spam.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_forward_spam_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.forward_spam.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_plain_content_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'enabled': false
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.plain_content.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_plain_content_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.plain_content.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_spam_check_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'enabled': true,
'max_score': 5,
'url': 'url'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.spam_check.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_spam_check_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.spam_check.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_template_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'enabled': true,
'html_content': '<% body %>'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.template.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mail_settings_template_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mail_settings.template.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_mailbox_providers_stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
'limit': 1,
'mailbox_providers': 'test_string',
'offset': 1,
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.mailbox_providers.stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_partner_settings_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'limit': 1,
'offset': 1
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.partner_settings.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_partner_settings_new_relic_patch()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'enable_subuser_statistics': true,
'enabled': true,
'license_key': ''
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.partner_settings.new_relic.patch(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_partner_settings_new_relic_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.partner_settings.new_relic.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_scopes_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.scopes.get(requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_stats_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'aggregated_by': 'day',
'end_date': '2016-04-01',
'limit': 1,
'offset': 1,
'start_date': '2016-01-01'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.stats.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_subusers_post()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string data = @"{
'email': 'John@example.com',
'ips': [
'1.1.1.1',
'2.2.2.2'
],
'password': 'johns_password',
'username': 'John@example.com'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.subusers.post(requestBody: data, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_subusers_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'limit': 1,
'offset': 1,
'username': 'test_string'
}";
Dictionary headers = new Dictionary();
headers.Clear();
headers.Add("X-Mock", "200");
dynamic response = sg.client.subusers.get(queryParams: queryParams, requestHeaders: headers);
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
}
[Test]
public void test_subusers_reputations_get()
{
string _apiKey = "SendGrid API Key";
string host = "";
if( Environment.GetEnvironmentVariable("TRAVIS") == "true" ) {
host = Environment.GetEnvironmentVariable("MOCK_HOST");
} else {
host = "http://localhost:4010";
}
dynamic sg = new SendGrid.SendGridAPIClient(_apiKey, host);
string queryParams = @"{
'usernames': 'test_string'
}";
Dictionary headers = new Dictionary