From 75569aa5f73f38ac88f6dbc6f4ddf0c67d495db5 Mon Sep 17 00:00:00 2001 From: Marc Riera Date: Fri, 25 Jun 2021 12:36:19 +0200 Subject: [PATCH] Improve format of SendGridHelper docs (#611) Improves format of SendgridHelper docs, including an incorrect indentation in code sample that caused to be formatted incorrectly. --- lib/bamboo/adapters/send_grid_helper.ex | 64 ++++++++++++++----------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/lib/bamboo/adapters/send_grid_helper.ex b/lib/bamboo/adapters/send_grid_helper.ex index 9402adc9..f3db5084 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 @@ -87,6 +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: ``` @@ -104,7 +107,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 +128,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 +147,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 +170,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 +231,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 +244,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 +303,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