From 8ae2ce6995c726a666bd9f8d8b4ffb50772c7b2d Mon Sep 17 00:00:00 2001 From: Houssem Yahiaoui Date: Mon, 27 Aug 2018 18:56:16 +0100 Subject: [PATCH 1/7] Updating Advanced Usage Adding a new section for API v3 users and making a differentiation between legacy and the new Transactional Template with v3 API. --- use-cases/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/use-cases/README.md b/use-cases/README.md index 14552536c..4822c81a8 100644 --- a/use-cases/README.md +++ b/use-cases/README.md @@ -8,7 +8,8 @@ This documentation provides examples for specific SendGrid v3 API use cases. Ple * [Flexible Email Address Fields](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/flexible-address-fields.md) * [Handling Success/Failure/Errors](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/success-failure-errors.md) * [Advanced Usage](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/advanced.md) - * [Transactional Templates](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/transactional-templates.md) + * [Transactional Templates (Legacy)](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/transactional-legacy-templates.md) + * [Transactional Templates (API v3)](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/transactional-templates.md) * [Attachments](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/attachments.md) * [Customization Per Recipient](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/customization.md) * [Manually Providing Content](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/manual-content.md) From 27c5332d95122c20979fdfebc5281f4be21cfde4 Mon Sep 17 00:00:00 2001 From: Houssem Yahiaoui Date: Mon, 27 Aug 2018 19:00:17 +0100 Subject: [PATCH 2/7] Renaming old Transactional to Legacy --- ...ansactional-templates.md => transactional-legacy-templates.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename use-cases/{transactional-templates.md => transactional-legacy-templates.md} (100%) diff --git a/use-cases/transactional-templates.md b/use-cases/transactional-legacy-templates.md similarity index 100% rename from use-cases/transactional-templates.md rename to use-cases/transactional-legacy-templates.md From d8cfc956bda2ed006805b8cba6117b8d68e2a3e2 Mon Sep 17 00:00:00 2001 From: Houssem Yahiaoui Date: Mon, 27 Aug 2018 19:07:29 +0100 Subject: [PATCH 3/7] Adding v3 Transactional Template documentation --- use-cases/transactional-templates.md | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 use-cases/transactional-templates.md diff --git a/use-cases/transactional-templates.md b/use-cases/transactional-templates.md new file mode 100644 index 000000000..0fd6a0390 --- /dev/null +++ b/use-cases/transactional-templates.md @@ -0,0 +1,55 @@ +# Transactional Templates (For API v3 Users) + +For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing. + +Template ID (replace with your own): + +```text +d-f43daeeaef504760851f727007e0b5d0 +``` + +Email Subject: + +```text +<%subject%> +``` + +Template Body: + +```html + + + + + +Hello {{name}}, +

+I'm glad you are trying out the template feature! +

+<%body%> +

+I hope you are having a great day in {{city}} :) +

+ + +``` + +```js +const sgMail = require('@sendgrid/mail'); +sgMail.setApiKey(process.env.SENDGRID_API_KEY); +const msg = { + to: 'recipient@example.org', + from: 'sender@example.org', + subject: 'Hello world', + text: 'Hello plain world!', + html: '

Hello HTML world!

', + templateId: 'd-f43daeeaef504760851f727007e0b5d0', + dynamic_template_data: { + name: 'Some One', + city: 'Denver', + }, +}; +sgMail.send(msg); +``` + +With SendGrid API v3, there's no need to specify the substitution wrappers as it will assume that you're using [Handlebars](https://handlebarsjs.com/) templting by default. From 17b1b7c55f928a2370eb3ee425bd6685486269aa Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 28 Aug 2018 16:04:46 -0700 Subject: [PATCH 4/7] Update README.md --- use-cases/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/use-cases/README.md b/use-cases/README.md index 4822c81a8..f11dbe798 100644 --- a/use-cases/README.md +++ b/use-cases/README.md @@ -8,8 +8,8 @@ This documentation provides examples for specific SendGrid v3 API use cases. Ple * [Flexible Email Address Fields](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/flexible-address-fields.md) * [Handling Success/Failure/Errors](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/success-failure-errors.md) * [Advanced Usage](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/advanced.md) - * [Transactional Templates (Legacy)](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/transactional-legacy-templates.md) - * [Transactional Templates (API v3)](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/transactional-templates.md) + * [Transactional Templates](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/transactional-templates.md) + * [Legacy Transactional Templates](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/transactional-legacy-templates.md) * [Attachments](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/attachments.md) * [Customization Per Recipient](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/customization.md) * [Manually Providing Content](https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/manual-content.md) From c1b099ffafc6543b73c00ec1e39cbab7f095f875 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 28 Aug 2018 16:05:06 -0700 Subject: [PATCH 5/7] Update transactional-legacy-templates.md --- use-cases/transactional-legacy-templates.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/use-cases/transactional-legacy-templates.md b/use-cases/transactional-legacy-templates.md index aae92a8d0..40a1dda50 100644 --- a/use-cases/transactional-legacy-templates.md +++ b/use-cases/transactional-legacy-templates.md @@ -1,7 +1,5 @@ # (LEGACY) Transactional Templates -IF YOU ARE USING OUR NEW TEMPLATES, PLEASE SEE [THIS ISSUE](https://github.com/sendgrid/sendgrid-nodejs/issues/703). - For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing. Template ID (replace with your own): From b807532b5d2efa16fb874504137c210fe3015ddd Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 28 Aug 2018 16:06:47 -0700 Subject: [PATCH 6/7] Update transactional-templates.md --- use-cases/transactional-templates.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/use-cases/transactional-templates.md b/use-cases/transactional-templates.md index 0fd6a0390..26e3b0d55 100644 --- a/use-cases/transactional-templates.md +++ b/use-cases/transactional-templates.md @@ -1,17 +1,11 @@ -# Transactional Templates (For API v3 Users) +# Transactional Templates For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing. -Template ID (replace with your own): - -```text -d-f43daeeaef504760851f727007e0b5d0 -``` - Email Subject: ```text -<%subject%> +{{ subject }} ``` Template Body: @@ -22,13 +16,13 @@ Template Body: -Hello {{name}}, +Hello {{ name }},

I'm glad you are trying out the template feature!

<%body%>

-I hope you are having a great day in {{city}} :) +I hope you are having a great day in {{ city }} :)

@@ -45,6 +39,7 @@ const msg = { html: '

Hello HTML world!

', templateId: 'd-f43daeeaef504760851f727007e0b5d0', dynamic_template_data: { + subject: 'Testing Templates', name: 'Some One', city: 'Denver', }, @@ -52,4 +47,4 @@ const msg = { sgMail.send(msg); ``` -With SendGrid API v3, there's no need to specify the substitution wrappers as it will assume that you're using [Handlebars](https://handlebarsjs.com/) templting by default. +There's no need to specify the substitution wrappers as it will assume that you're using [Handlebars](https://handlebarsjs.com/) templting by default. From 8c275f0c8c0ec5a5e3a77fda4c6a93dae3bce368 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 28 Aug 2018 16:07:13 -0700 Subject: [PATCH 7/7] Update transactional-templates.md --- use-cases/transactional-templates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/use-cases/transactional-templates.md b/use-cases/transactional-templates.md index 26e3b0d55..0e8c40077 100644 --- a/use-cases/transactional-templates.md +++ b/use-cases/transactional-templates.md @@ -47,4 +47,4 @@ const msg = { sgMail.send(msg); ``` -There's no need to specify the substitution wrappers as it will assume that you're using [Handlebars](https://handlebarsjs.com/) templting by default. +There's no need to specify the substitution wrappers as it will assume that you're using [Handlebars](https://handlebarsjs.com/) templating by default.