diff --git a/examples/helpers/mail/example.rb b/examples/helpers/mail/example.rb index ee0c80dc..9ca18c73 100644 --- a/examples/helpers/mail/example.rb +++ b/examples/helpers/mail/example.rb @@ -11,7 +11,7 @@ def hello_world # puts JSON.pretty_generate(mail.to_json) puts mail.to_json - sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'], host: 'https://api.sendgrid.com') + sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) response = sg.client.mail._('send').post(request_body: mail.to_json) puts response.status_code puts response.body @@ -118,7 +118,7 @@ def kitchen_sink # puts JSON.pretty_generate(mail.to_json) puts mail.to_json - sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'], host: 'https://api.sendgrid.com') + sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) response = sg.client.mail._('send').post(request_body: mail.to_json) puts response.status_code puts response.body @@ -129,8 +129,6 @@ def dynamic_template_data_hello_world mail = Mail.new mail.template_id = '' # a non-legacy template id mail.from = Email.new(email: 'test@example.com') - subject = 'Dynamic Template Data Hello World from the Twilio SendGrid Ruby Library' - mail.subject = subject personalization = Personalization.new personalization.add_to(Email.new(email: 'test1@example.com', name: 'Example User')) personalization.add_dynamic_template_data({ @@ -139,6 +137,15 @@ def dynamic_template_data_hello_world ] }) mail.add_personalization(personalization) + + # puts JSON.pretty_generate(mail.to_json) + puts mail.to_json + + sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) + response = sg.client.mail._('send').post(request_body: mail.to_json) + puts response.status_code + puts response.body + puts response.headers end hello_world