public async Task GenerateEmailPreviewWithPersonalisation()
        {
            Dictionary <String, dynamic> personalisation = new Dictionary <String, dynamic>
            {
                { "name", "someone" }
            };

            TemplatePreviewResponse response =
                await this.client.GenerateTemplatePreviewAsync(EMAIL_TEMPLATE_ID, personalisation);

            Assert.IsNotNull(response);
            Assert.AreEqual(response.body, TEST_EMAIL_BODY);
            Assert.AreEqual(response.subject, TEST_EMAIL_SUBJECT);
        }
        public void GenerateSMSPreviewWithPersonalisation()
        {
            Dictionary <String, dynamic> personalisation = new Dictionary <String, dynamic>
            {
                { "name", "someone" }
            };

            TemplatePreviewResponse response =
                this.client.GenerateTemplatePreview(SMS_TEMPLATE_ID, personalisation);

            Assert.IsNotNull(response);
            Assert.AreEqual(response.body, TEST_SMS_BODY);
            Assert.AreEqual(response.subject, null);
        }
        public void GenerateTemplatePreviewGeneratesExpectedRequest()
        {
            Dictionary <String, dynamic> personalisation = new Dictionary <String, dynamic> {
                { "name", "someone" }
            };

            JObject o = new JObject
            {
                { "personalisation", JObject.FromObject(personalisation) }
            };

            mockRequest(Constants.fakeTemplatePreviewResponseJson,
                        client.GET_TEMPLATE_URL + Constants.fakeTemplateId + "/preview", AssertValidRequest, HttpMethod.Post);

            TemplatePreviewResponse response = client.GenerateTemplatePreview(Constants.fakeTemplateId, personalisation);
        }
        public TemplatePreviewResponse GenerateTemplatePreview(String templateId, Dictionary <String, dynamic> personalisation = null)
        {
            String url = string.Format("{0}{1}/preview", GET_TEMPLATE_URL, templateId);

            JObject o = new JObject
            {
                { "personalisation", JObject.FromObject(personalisation) }
            };

            String response = this.POST(url, o.ToString(Formatting.None));

            try
            {
                TemplatePreviewResponse template = JsonConvert.DeserializeObject <TemplatePreviewResponse>(response);
                return(template);
            }
            catch (JsonReaderException)
            {
                throw new NotifyClientException("Could not create Template object from response: {0}", response);
            }
        }