Exemple #1
0
        static void Main()
        {
            // Do you want to proxy requests through fiddler (useful for debugging)?
            var useFiddler = false;

            if (useFiddler)
            {
                // This is necessary to ensure HTTPS traffic can be proxied through Fiddler without any certificate validation error.
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); });
            }
            var httpClient = new HttpClient(
                new HttpClientHandler
            {
                Proxy    = new WebProxy("http://localhost:8888"),
                UseProxy = useFiddler
            }
                );
            var apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
            var client = new StrongGrid.Client(apiKey: apiKey, httpClient: httpClient);

            //ApiKeys(client);
            //Campaigns(client);
            //ContactsAndCustomFields(client);
            //GlobalSuppressions(client);
            //ListsAndSegments(client);
            //Mail(client);
            //UnsubscribeGroups(client);
            //User(client);
            //Statistics(client);
            //Templates(client);
            //Settings(client);
            //Alerts(client);
            Blocks(client);
        }
Exemple #2
0
        public static void Main()
        {
            // -----------------------------------------------------------------------------

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

            // Set this variable to true if you want to pause after each test
            // which gives you an opportunity to review the output in the console.
            var pauseAfterTests = false;

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


            var proxy  = useFiddler ? new WebProxy("http://localhost:8888") : null;
            var apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
            var client = new StrongGrid.Client(apiKey, proxy);

            try
            {
                ApiKeys(client, pauseAfterTests);
                Campaigns(client, pauseAfterTests);
                Categories(client, pauseAfterTests);
                ContactsAndCustomFields(client, pauseAfterTests);
                GlobalSuppressions(client, pauseAfterTests);
                ListsAndSegments(client, pauseAfterTests);
                Mail(client, pauseAfterTests);
                UnsubscribeGroups(client, pauseAfterTests);
                User(client, pauseAfterTests);
                Statistics(client, pauseAfterTests);
                Templates(client, pauseAfterTests);
                Settings(client, pauseAfterTests);
                Alerts(client, pauseAfterTests);
                Blocks(client, pauseAfterTests);
                SpamReports(client, pauseAfterTests);
                InvalidEmails(client, pauseAfterTests);
                Batches(client, pauseAfterTests);
                Whitelabel(client, pauseAfterTests);
            }
            catch (Exception e)
            {
                Console.WriteLine("\n\n**************************************************");
                Console.WriteLine("**************************************************");
                Console.WriteLine($"AN EXCEPTION OCCURED: {e.Message}");
                Console.WriteLine("**************************************************");
                Console.WriteLine("**************************************************");
            }
            finally
            {
                while (Console.KeyAvailable)
                {
                    Console.ReadKey(false);
                }
                Console.WriteLine("\n\n*************************");
                Console.WriteLine("All tests completed");
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
        }