I am trying to send a transactional email using Sendgrid upon client booking on a Rails application.
I did create a dynamic template as required. When I make a POST request to https://api.sendgrid.com/v3/mail/send with POSTMAN using the right body and my Sendgrid API key, it works, I do receive the confirmation email.
However, I am a Rails newbie and I really don't know how to proceed with the piece of code provided in the docs:
require 'sendgrid-ruby'
include SendGrid
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'], impersonate_subuser: The subuser's username. This header generates the API call as if the subuser account was making the call.)
data = JSON.parse('{
"name": "example_name",
"generation": "dynamic"
}')
response = sg.client.templates.post(request_body: data)
puts response.status_code
puts response.headers
puts response.body
Thanks in advance for your help!