示例#1
0
        public async Task TestUpdateTemplateVersionByIdWithAllParametersAsync()
        {
            // Make the API call
            Trace.WriteLine(String.Format("PUT /templates/{0}/versions/{1}", DEFAULT_TEMPLATE_ID, DEFAULT_VERSION_ID));
            var templateVersionName    = "New Template Version";
            var templateSubject        = "New Version!";
            var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);

            updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>";
            updatedTemplateVersion.text = "some text";
            try
            {
                var templateVersion = await Template.UpdateTemplateVersionAsync(DEFAULT_TEMPLATE_ID, DEFAULT_VERSION_ID, updatedTemplateVersion);

                // Validate the response
                SendwithusClientTest.ValidateResponse(templateVersion);
            }
            catch (AggregateException exception)
            {
                Assert.Fail(exception.ToString());
            }
        }
        public async Task TestCreateTemplateVersionWithLocaleWithAllParametersAsync()
        {
            // Make the API call
            Trace.WriteLine(String.Format("POST /templates/{0}/locales/{1}/versions", DEFAULT_TEMPLATE_ID, DEFAULT_LOCALE));
            var templateVersionName    = "New Template Version" + SendwithusClientTest.TimeStampAndRandomNumber();
            var templateSubject        = "New Version!";
            var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);

            updatedTemplateVersion.html      = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>";
            updatedTemplateVersion.text      = "some text";
            updatedTemplateVersion.preheader = "A Test Preheader";
            try
            {
                var templateVersion = await Template.CreateTemplateVersion(DEFAULT_TEMPLATE_ID, DEFAULT_LOCALE, updatedTemplateVersion);

                // Validate the response
                SendwithusClientTest.ValidateResponse(templateVersion);
            }
            catch (AggregateException exception)
            {
                Assert.Fail(exception.ToString());
            }
        }
示例#3
0
        public async Task TestGetCustomerEmailLogsWithAllParametersAsync()
        {
            Trace.WriteLine(String.Format("GET /customers/{0}/logs", DEFAULT_CUSTOMER_EMAIL_ADDRESS));

            // Build the query parameters
            var queryParameters = new Dictionary <string, object>();

            queryParameters.Add("count", 2);
            queryParameters.Add("created_lt", LOG_CREATED_BEFORE_TIME);
            queryParameters.Add("created_gt", LOG_CREATED_AFTER_TIME);

            // Make the API call
            try
            {
                var customerEmailLogsResponse = await Customer.GetCustomerEmailLogsAsync(DEFAULT_CUSTOMER_EMAIL_ADDRESS, queryParameters);

                // Validate the response
                SendwithusClientTest.ValidateResponse(customerEmailLogsResponse);
            }
            catch (AggregateException exception)
            {
                Assert.Fail(exception.ToString());
            }
        }
        /// <summary>
        /// Validates an individual batch API call response from the list that was received in the batch API call
        /// </summary>
        /// <typeparam name="T">The type to convert the BatchApiResponse's body to (the type that the individual API call returns)</typeparam>
        /// <param name="response">The individual batch API call</param>
        private void ValidateIndividualBatchedApiCallResponse <T>(BatchApiResponse response)
        {
            var responseBody = response.GetBody <T>();

            SendwithusClientTest.ValidateResponse(responseBody);
        }