Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update example.rb #344

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions examples/helpers/mail/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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({
Expand All @@ -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
Expand Down