alexgaribay / sendgrid_elixir

Create and send composable emails with Elixir and SendGrid.
MIT License
86 stars 44 forks source link

Can't use dynamic templates #30

Closed a-kinder closed 5 years ago

a-kinder commented 5 years ago

Hello We are trying to upgrade our templates to the new SendGrid template creators, however if we add substitutions with add_custom_arg/3 they do not populate, however add_substitution/3 is disabled for dynamic templates and returns the error

 [
   %{
     "field" => "personalizations.0.substitutions",
     "help" => "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.substitutions",
     "message" => "Substitutions may not be used with dynamic templating"
   }
 ]}

It looks like we may need the add_dynamic_template_data/2 function that was recently added to master, is there a workaround to use this or am I missing something in my data?

thanks

alexgaribay commented 5 years ago

I haven't used that specific feature. You can try using the library at a specific commit hash until I push a new version to Hex.

{:sendgrid, github: "alexgaribay/sendgrid_elixir", ref: "43379d4"}
a-kinder commented 5 years ago

I'll try that, thank you!

aturkewi commented 5 years ago

It looks like this feature was added in this PR: https://github.com/alexgaribay/sendgrid_elixir/pull/29, but the version of this package has not been bumped since January 1st 2018 (before the new dynamic templates existed on SendGrid I believe). Given that the code is in, perhaps the package can be versioned so it's easier to use?

Thanks!

alexgaribay commented 5 years ago

@aturkewi @a-kinder You can try it out now in by upgrading your dependency to {:sendgrid, "~> 2.0.0-rc.0"}. Just be aware that there are some breaking changes (most notably SendGrid.Mailer is now SendGrid.Mail)

alexgaribay commented 5 years ago

This is now available in the 2.0.0 version.