From b680abc2d6727b4459d91344f2cc73074fb92dce Mon Sep 17 00:00:00 2001 From: Marc Riera Date: Mon, 14 Jun 2021 14:24:45 +0200 Subject: [PATCH 1/3] Improve format of SendgridHelper docs --- lib/bamboo/adapters/send_grid_helper.ex | 58 ++++++++++++++----------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/lib/bamboo/adapters/send_grid_helper.ex b/lib/bamboo/adapters/send_grid_helper.ex index 9402adc9..f7688101 100644 --- a/lib/bamboo/adapters/send_grid_helper.ex +++ b/lib/bamboo/adapters/send_grid_helper.ex @@ -87,6 +87,7 @@ defmodule Bamboo.SendGridHelper do @doc """ Add a property to the list of dynamic template data in the SendGrid template. + This will be added to the request as: ``` @@ -104,7 +105,6 @@ defmodule Bamboo.SendGridHelper do ], ``` - The tag can be of any type since SendGrid allows you to use Handlebars in its templates ## Example @@ -126,7 +126,8 @@ defmodule Bamboo.SendGridHelper do do: raise("expected the name parameter to be of type binary or atom, got #{field}") @doc """ - An integer id for an ASM (Advanced Suppression Manager) group that this email should belong to. + Set the ASM (Advanced Suppression Manager) group that this email should belong to. + This can be used to let recipients unsubscribe from only a certain type of communication. ## Example @@ -144,8 +145,9 @@ defmodule Bamboo.SendGridHelper do end @doc """ - A boolean setting to instruct SendGrid to bypass list management for this - email. If enabled, SendGrid will ignore any email supression (such as + Instruct SendGrid to bypass list management for this email. + + If enabled, SendGrid will ignore any email supression (such as unsubscriptions, bounces, spam filters) for this email. This is useful for emails that all users must receive, such as Terms of Service updates, or password resets. @@ -166,8 +168,10 @@ defmodule Bamboo.SendGridHelper do @doc """ Instruct SendGrid to enable or disable Google Analytics tracking, and - optionally set the UTM parameters for it. This is useful if you need to - control UTM tracking parameters on an individual email basis. + optionally set the UTM parameters for it. + + This is useful if you need to control UTM tracking parameters on an individual email + basis. ## Example @@ -225,7 +229,7 @@ defmodule Bamboo.SendGridHelper do end @doc """ - Add SendGrid personalizations + Add SendGrid personalizations. Each personalization can have the following fields: `to`, `cc`, `bcc`, `subject`, `headers`, `substitutions`, `custom_args`, or `send_at`. @@ -238,24 +242,24 @@ defmodule Bamboo.SendGridHelper do ## Example: - base_personalization = %{ - bcc: [%{"email" => "bcc@bar.com", "name" => "BCC"}], - subject: "Here is your email" - } - - personalizations = - Enum.map( - [ - %{to: "one@test.com"}, - %{to: "two@test.com", send_at: 1_580_485_560} - ], - &Map.merge(base_personalization, &1) - ) - - email = - new_email() - |> Email.put_header("Reply-To", "reply@foo.com") - |> Bamboo.SendGridHelper.add_personalizations(personalizations) + base_personalization = %{ + bcc: [%{"email" => "bcc@bar.com", "name" => "BCC"}], + subject: "Here is your email" + } + + personalizations = + Enum.map( + [ + %{to: "one@test.com"}, + %{to: "two@test.com", send_at: 1_580_485_560} + ], + &Map.merge(base_personalization, &1) + ) + + email = + new_email() + |> Email.put_header("Reply-To", "reply@foo.com") + |> Bamboo.SendGridHelper.add_personalizations(personalizations) """ @spec add_personalizations(Bamboo.Email.t(), [map]) :: Bamboo.Email.t() @@ -297,7 +301,9 @@ defmodule Bamboo.SendGridHelper do end @doc """ - A map of unique arguments for this email. This will override any existing unique arguments. + Set a map of unique arguments for this email. + + This will override any existing unique arguments. ## Example From e4075d59708ebb65f1e00279f89609a6e5b03d90 Mon Sep 17 00:00:00 2001 From: Marc Riera Date: Mon, 14 Jun 2021 14:32:14 +0200 Subject: [PATCH 2/3] Improve docs --- lib/bamboo/adapters/send_grid_helper.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bamboo/adapters/send_grid_helper.ex b/lib/bamboo/adapters/send_grid_helper.ex index f7688101..761dd10c 100644 --- a/lib/bamboo/adapters/send_grid_helper.ex +++ b/lib/bamboo/adapters/send_grid_helper.ex @@ -63,8 +63,10 @@ defmodule Bamboo.SendGridHelper do end @doc """ - An array of category names for this email. A maximum of 10 categories can be assigned to an email. - Duplicate categories will be ignored and only unique entries will be sent. + Sets a list of categories for this email. + + A maximum of 10 categories can be assigned to an email. Duplicate categories will + be ignored and only unique entries will be sent. ## Example From 44d21108bdf81bc18fdd6de5301c6f031ac9b5a5 Mon Sep 17 00:00:00 2001 From: Marc Riera Casals Date: Mon, 14 Jun 2021 14:34:36 +0200 Subject: [PATCH 3/3] Fix format --- lib/bamboo/adapters/send_grid_helper.ex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/bamboo/adapters/send_grid_helper.ex b/lib/bamboo/adapters/send_grid_helper.ex index 761dd10c..f3db5084 100644 --- a/lib/bamboo/adapters/send_grid_helper.ex +++ b/lib/bamboo/adapters/send_grid_helper.ex @@ -64,7 +64,7 @@ defmodule Bamboo.SendGridHelper do @doc """ Sets a list of categories for this email. - + A maximum of 10 categories can be assigned to an email. Duplicate categories will be ignored and only unique entries will be sent. @@ -89,7 +89,7 @@ defmodule Bamboo.SendGridHelper do @doc """ Add a property to the list of dynamic template data in the SendGrid template. - + This will be added to the request as: ``` @@ -129,7 +129,7 @@ defmodule Bamboo.SendGridHelper do @doc """ Set the ASM (Advanced Suppression Manager) group that this email should belong to. - + This can be used to let recipients unsubscribe from only a certain type of communication. ## Example @@ -148,7 +148,7 @@ defmodule Bamboo.SendGridHelper do @doc """ Instruct SendGrid to bypass list management for this email. - + If enabled, SendGrid will ignore any email supression (such as unsubscriptions, bounces, spam filters) for this email. This is useful for emails that all users must receive, such as Terms of Service updates, or @@ -171,7 +171,7 @@ defmodule Bamboo.SendGridHelper do @doc """ Instruct SendGrid to enable or disable Google Analytics tracking, and optionally set the UTM parameters for it. - + This is useful if you need to control UTM tracking parameters on an individual email basis. @@ -304,7 +304,7 @@ defmodule Bamboo.SendGridHelper do @doc """ Set a map of unique arguments for this email. - + This will override any existing unique arguments. ## Example