-
Notifications
You must be signed in to change notification settings - Fork 322
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
Send a Single Email to a Single Recipient #100
Comments
Hi, I'm looking to help out, but I'm not sure what's required of this issue. From what I can tell, ruby-http-client manages the actual request, returning the status code, errors and body payload. |
Hi @ssonal, This issue is part of a bigger project: Mail Helper Enhancement (v3 mail/send). Specifically, we want to refactor the Mail Helper so that it is much easier to use. I would start by proposing a new method signature. For example, we currently have: require 'sendgrid-ruby'
include SendGrid
from = Email.new(email: '[email protected]')
subject = 'Hello World from the SendGrid Ruby Library!'
to = Email.new(email: '[email protected]')
content = Content.new(type: 'text/plain', value: 'Hello, Email!')
mail = Mail.new(from, subject, to, content)
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 Perhaps a new version would be: require 'sendgrid-ruby'
include SendGrid
from = Email.new(email: '[email protected]')
subject = 'Hello World from the SendGrid Ruby Library!'
to = Email.new(email: '[email protected]')
content = Content.new(type: 'text/plain', value: 'Hello, Email!')
mail = Mail.new(from, subject, to, content)
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
response = sg.client.send(mail)
puts response.status_code
puts response.body
puts response.headers |
@thinkingserious So in this case for new method signature, we can add new method in def send(mail)
data = mail.kind_of?(Mail) ? mail.to_json : mail
@client.mail._("send").post(request_body: data)
end And we can call it as sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
response = sg.send(mail) Am i correct? |
This has been moved here. |
Acceptance Criteria:
Reference:
The text was updated successfully, but these errors were encountered: