Skip to content

Commit 1e5097d

Browse files
authored
Merge pull request #27 from sendwithus/add-preheader-and-amp-fields
Add optional preheader and AMP fields
2 parents d09d20d + 8e9cdab commit 1e5097d

5 files changed

Lines changed: 27 additions & 2 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ var templateSubject = "edited!";
170170
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
171171
updatedTemplateVersion.html = "<html><head></head><body><h1>UPDATE</h1></body></html>"; // optional
172172
updatedTemplateVersion.text = "sometext"; // optional
173+
updatedTemplateVersion.preheader = "some preheader"; // optional
173174
try
174175
{
175176
var templateVersion = await Template.UpdateTemplateVersionAsync(templateId, versionId, updatedTemplateVersion);
@@ -190,6 +191,7 @@ var templateSubject = "edited!";
190191
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
191192
updatedTemplateVersion.html = "<html><head></head><body><h1>UPDATE</h1></body></html>"; // optional
192193
updatedTemplateVersion.text = "sometext"; // optional
194+
updatedTemplateVersion.preheader = "some preheader"; // optional
193195
try
194196
{
195197
var templateVersion = await Template.UpdateTemplateVersionAsync(templateId, versionId, updatedTemplateVersion);
@@ -207,6 +209,7 @@ var templateSubject = "New Version!";
207209
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
208210
updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>"; // optional
209211
updatedTemplateVersion.text = "some text"; // optional
212+
updatedTemplateVersion.preheader = "some preheader"; // optional
210213
updatedTemplateVersion.locale = "en-US"; // optional
211214
try
212215
{
@@ -227,6 +230,7 @@ var templateSubject = "Ce est un nouveau modèle!";
227230
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
228231
updatedTemplateVersion.html = "<html><head></head><body><h1>Nouveau modèle!</h1></body></html>"; // optional
229232
updatedTemplateVersion.text = "un texte"; // optional
233+
updatedTemplateVersion.preheader = "some preheader"; // optional
230234
try
231235
{
232236
var template = await Template.AddLocaleToTemplate(templateId, locale, updatedTemplateVersion);
@@ -246,6 +250,7 @@ var templateSubject = "New Version!";
246250
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
247251
updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>"; // optional
248252
updatedTemplateVersion.text = "some text"; // optional
253+
updatedTemplateVersion.preheader = "some preheader"; // optional
249254
try
250255
{
251256
var templateVersion = await Template.CreateTemplateVersion(templateId, updatedTemplateVersion);
@@ -265,6 +270,7 @@ var templateSubject = "New Version!";
265270
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
266271
updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>"; // optional
267272
updatedTemplateVersion.text = "some text"; // optional
273+
updatedTemplateVersion.preheader = "some preheader"; // optional
268274
try
269275
{
270276
var templateVersion = await Template.CreateTemplateVersion(templateId, locale, updatedTemplateVersion);

Sendwithus/SendwithusClient/API/Helpers/RenderTemplateResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class RenderTemplateResponse
1111
public string status { get; set; }
1212
public RenderTemplateResponseTemplate template { get; set; }
1313
public string subject { get; set; }
14+
public string preheader { get; set; }
15+
public string amp_html { get; set; }
1416
public string html { get; set; }
1517
public string text { get; set; }
1618

@@ -23,6 +25,8 @@ public RenderTemplateResponse()
2325
status = String.Empty;
2426
template = new RenderTemplateResponseTemplate();
2527
subject = String.Empty;
28+
preheader = String.Empty;
29+
amp_html = String.Empty;
2630
html = String.Empty;
2731
text = String.Empty;
2832
}

Sendwithus/SendwithusClient/API/Helpers/TemplateVersion.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ public class TemplateVersion
1212
public string id { get; set; }
1313
public string created { get; set; }
1414
public string modified { get; set; }
15+
public string amp_html { get; set; }
1516
public string html { get; set; }
1617
public string text { get; set; }
1718
public string subject { get; set; }
19+
public string preheader { get; set; }
1820
public string locale { get; set; }
1921
public bool published { get; set; }
2022

@@ -31,9 +33,10 @@ public TemplateVersion(string name, string subject)
3133
id = String.Empty;
3234
created = String.Empty;
3335
modified = String.Empty;
36+
amp_html = String.Empty;
3437
html = String.Empty;
3538
text = String.Empty;
36-
39+
preheader = String.Empty;
3740
locale = String.Empty;
3841
published = false;
3942
}

Sendwithus/SendwithusTest/Tests/TemplateTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ public async Task TestGetTemplateVersionByIdAsync()
229229

230230
// Validate the response
231231
SendwithusClientTest.ValidateResponse(templateVersion);
232+
233+
// Check for presence of expected fields
234+
Assert.AreEqual(templateVersion.preheader, "A preheader test");
232235
}
233236
catch (AggregateException exception)
234237
{
@@ -251,6 +254,9 @@ public async Task TestGetTemplateVersionByIdAndLocaleAsync()
251254

252255
// Validate the response
253256
SendwithusClientTest.ValidateResponse(templateVersion);
257+
258+
// Check for presence of expected fields
259+
Assert.AreEqual(templateVersion.preheader, "A preheader test");
254260
}
255261
catch (AggregateException exception)
256262
{
@@ -272,6 +278,7 @@ public async Task TestUpdateTemplateVersionByIdWithAllParametersAsync()
272278
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
273279
updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>";
274280
updatedTemplateVersion.text = "some text";
281+
updatedTemplateVersion.preheader = "A Test Preheader";
275282
try
276283
{
277284
var templateVersion = await Template.UpdateTemplateVersionAsync(DEFAULT_TEMPLATE_ID, DEFAULT_VERSION_ID, updatedTemplateVersion);
@@ -403,6 +410,7 @@ public async Task TestUpdateTemplateVersionByIdAndLocaleWithAllParametersAsync()
403410
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
404411
updatedTemplateVersion.html = "<html><head></head><body><h1>UPDATE</h1></body></html>";
405412
updatedTemplateVersion.text = "sometext";
413+
updatedTemplateVersion.preheader = "A Test Preheader";
406414
try
407415
{
408416
var templateVersion = await Template.UpdateTemplateVersionAsync(DEFAULT_TEMPLATE_ID, DEFAULT_LOCALE, DEFAULT_VERSION_ID, updatedTemplateVersion);
@@ -510,6 +518,7 @@ public async Task TestAddLocaleToTemplateWithAllParmetersAsync()
510518
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
511519
updatedTemplateVersion.html = "<html><head></head><body><h1>Nouveau modèle!</h1></body></html>";
512520
updatedTemplateVersion.text = "un texte";
521+
updatedTemplateVersion.preheader = "A French Preheader";
513522

514523
try
515524
{
@@ -590,6 +599,7 @@ public async Task TestCreateTemplateVersionWithAllParametersAsync()
590599
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
591600
updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>";
592601
updatedTemplateVersion.text = "some text";
602+
updatedTemplateVersion.preheader = "A Test Preheader";
593603
try
594604
{
595605
var templateVersion = await Template.CreateTemplateVersion(DEFAULT_TEMPLATE_ID, updatedTemplateVersion);
@@ -669,6 +679,7 @@ public async Task TestCreateTemplateVersionWithLocaleWithAllParametersAsync()
669679
var updatedTemplateVersion = new TemplateVersion(templateVersionName, templateSubject);
670680
updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>";
671681
updatedTemplateVersion.text = "some text";
682+
updatedTemplateVersion.preheader = "A Test Preheader";
672683
try
673684
{
674685
var templateVersion = await Template.CreateTemplateVersion(DEFAULT_TEMPLATE_ID, DEFAULT_LOCALE, updatedTemplateVersion);
@@ -747,6 +758,7 @@ public static async Task<Template> BuildAndSendCreateTemplateRequestWithAllParam
747758
updatedTemplateVersion.html = "<html><head></head><body><h1>NEW TEMPLATE VERSION</h1></body></html>";
748759
updatedTemplateVersion.text = "some text";
749760
updatedTemplateVersion.locale = DEFAULT_LOCALE;
761+
updatedTemplateVersion.preheader = "Test Preheader";
750762
return await Template.CreateTemplateAsync(updatedTemplateVersion);
751763
}
752764

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 2.2.{build}
1+
version: 2.3.{build}
22

33
#---------------------------------#
44
# environment configuration #

0 commit comments

Comments
 (0)