sendgrid / sendgrid-ruby

The Official Twilio SendGrid Led, Community Driven Ruby API Library
https://sendgrid.com
MIT License
621 stars 324 forks source link

The Required Unsubscribe block is borked #419

Closed fogonthedowns closed 4 years ago

fogonthedowns commented 4 years ago

Issue Summary

The required unsubscribe block is totally broken and does not work. I am completely unable to substitute Sender_Name, Sender_City, Sender_Zip etc etc. It appears as unprofessional broken text.

Steps to Reproduce

  1. Follow terrible Sendgrid docs
  2. Notice Other substitutions are working
  3. Notice the required unsubscribe block substitutions are not working

Code Snippet

      @token = token
      token_url = ENV['ENV_URI'] + "/users/confirmation?confirmation_token=" + record.confirmation_token
      data = JSON.parse('{
      "personalizations": [
        {
          "to": [
            {
              "email": "'+record.email+'"
            }
          ],
          "subject": "Welcome to Foo! Confirm Your Email",
          "dynamic_template_data": {
              "token": "'+token_url+'",
              "Sender_Name": "support@foo.baz",
              "Sender_Address": "181 Foo St",
              "Sender_City" : "Batz Francisco",
              "Sender_State" : "CA",
              "Sender_Zip": "91115"
            }
          }
        ],
        "from": {
          "email": "suport@foo.baz"
        },
        "content": [
          {
            "type": "text/plain",
            "value": "'+record.confirmation_token+'"
          }
        ],
        "substitutions": {
              "Sender_Name": "Foo@Batz.io",
              "Sender_Address": "181 FOO St",
              "Sender_City" : "San Batz",
              "Sender_State" : "CA",
              "Sender_Zip": "91111"
         },
        "template_id": "'+ENV['SENDGRID_TRANS_EMAIL_CONFIRM_TEMPLATE_ID']+'"
      }')

Exception/Log

Technical details:

fogonthedowns commented 4 years ago

I guess the above works - but you must include duplicate data in substitutions and dynamic_template_data.