{"action":"created","issue":{"url":"https://api.github.com/repos/sendgrid/sendgrid-python/issues/224","repository_url":"https://api.github.com/repos/sendgrid/sendgrid-python","labels_url":"https://api.github.com/repos/sendgrid/sendgrid-python/issues/224/labels{/name}","comments_url":"https://api.github.com/repos/sendgrid/sendgrid-python/issues/224/comments","events_url":"https://api.github.com/repos/sendgrid/sendgrid-python/issues/224/events","html_url":"https://github.com/sendgrid/sendgrid-python/issues/224","id":178788283,"number":224,"title":"Send a Single Email to a Single Recipient","user":{"login":"thinkingserious","id":146695,"avatar_url":"https://avatars3.githubusercontent.com/u/146695?v=3","gravatar_id":"","url":"https://api.github.com/users/thinkingserious","html_url":"https://github.com/thinkingserious","followers_url":"https://api.github.com/users/thinkingserious/followers","following_url":"https://api.github.com/users/thinkingserious/following{/other_user}","gists_url":"https://api.github.com/users/thinkingserious/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkingserious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkingserious/subscriptions","organizations_url":"https://api.github.com/users/thinkingserious/orgs","repos_url":"https://api.github.com/users/thinkingserious/repos","events_url":"https://api.github.com/users/thinkingserious/events{/privacy}","received_events_url":"https://api.github.com/users/thinkingserious/received_events","type":"User","site_admin":false},"labels":[{"id":455063952,"url":"https://api.github.com/repos/sendgrid/sendgrid-python/labels/hacktoberfest","name":"hacktoberfest","color":"c2e0c6","default":false},{"id":378654181,"url":"https://api.github.com/repos/sendgrid/sendgrid-python/labels/status:%20help%20wanted","name":"status: help wanted","color":"e99695","default":false},{"id":290033,"url":"https://api.github.com/repos/sendgrid/sendgrid-python/labels/type:%20enhancement","name":"type: enhancement","color":"84b6eb","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-23T05:29:49Z","updated_at":"2017-05-17T17:01:46Z","closed_at":null,"body":"Acceptance Criteria:\n- A email object that represents the response body payload\n- A mail object that handles sending email objects, data validation and error handling\n\nReference:\n- https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail\n- https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md\n- https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html\n"},"comment":{"url":"https://api.github.com/repos/sendgrid/sendgrid-python/issues/comments/302154735","html_url":"https://github.com/sendgrid/sendgrid-python/issues/224#issuecomment-302154735","issue_url":"https://api.github.com/repos/sendgrid/sendgrid-python/issues/224","id":302154735,"user":{"login":"thinkingserious","id":146695,"avatar_url":"https://avatars3.githubusercontent.com/u/146695?v=3","gravatar_id":"","url":"https://api.github.com/users/thinkingserious","html_url":"https://github.com/thinkingserious","followers_url":"https://api.github.com/users/thinkingserious/followers","following_url":"https://api.github.com/users/thinkingserious/following{/other_user}","gists_url":"https://api.github.com/users/thinkingserious/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkingserious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkingserious/subscriptions","organizations_url":"https://api.github.com/users/thinkingserious/orgs","repos_url":"https://api.github.com/users/thinkingserious/repos","events_url":"https://api.github.com/users/thinkingserious/events{/privacy}","received_events_url":"https://api.github.com/users/thinkingserious/received_events","type":"User","site_admin":false},"created_at":"2017-05-17T17:01:46Z","updated_at":"2017-05-17T17:01:46Z","body":"Hi @dibyadas,\r\n\r\nThank you for the follow up!\r\n\r\n1. For the Response object, I'm referring to something [like this](https://github.com/sendgrid/sendgrid-csharp/blob/master/src/SendGrid/Response.cs). It's a wrapper around [HTTPResponse](https://docs.python.org/3/library/http.client.html#http.client.HTTPResponse). The idea is that we can then customize the return object for specific SendGrid functionality. For now, it should have a status_code, body and headers. Right now, we return [the original object directly](https://github.com/sendgrid/sendgrid-python/blob/0942f9de2d5ba5fedb65a23940ebe1005a21a6c7/sendgrid/client.py#L81).\r\n\r\n2. The data validation portion does not have to be included in this iteration. But we should plan for it. The idea is that the helper should surface API errors where possible before the message is sent. \r\n\r\n3. For error handling please see: https://github.com/sendgrid/sendgrid-python/issues/193\r\n\r\nAt a high level, we want a request object builder that we can pass to a function that will send the email.\r\n\r\nFor the use case described in the example, I'm thinking of something along the lines of this (both cases should be possible):\r\n\r\n```python\r\nimport sendgrid\r\n\r\nsg = sendgrid.SendGridClient('SENDGRID_API_KEY')\r\n\r\nfrom_email = Email('Test User', 'test@example.com')\r\nto_email = Email('Test User', 'test@example.com')\r\nsubject = 'Hello World from the SendGrid Python Library!'\r\nplain_text_content = 'Hello, Email!'\r\nhtml_content = '<strong>Hello, Email!</strong>'\r\nmsg = create_single_email(from_email, to_email, subject, plain_text_content, html_content)\r\n\r\nresponse = sg.send(msg)\r\n```\r\n\r\nor\r\n\r\n```python\r\nimport sendgrid\r\nfrom sendgrid import SendGridMessage\r\n\r\nsg = sendgrid.SendGridClient('SENDGRID_API_KEY')\r\n\r\nmsg = SendGridMessage()\r\nmsg.from_email = Email('Test User', 'test@example.com')\r\nmsg.to_email = Email('Test User', 'test@example.com')\r\nmsg.subject = 'Hello World from the SendGrid Python Library!'\r\nmsg.plain_text_content = 'Hello, Email!'\r\nmsg.html_content = '<strong>Hello, Email!</strong>'\r\n\r\nresponse = sg.send(msg)\r\n```\r\nThe first case demonstrates the use of the SendGridMessage builder create_single_email which this issue addresses. \r\n\r\nThe second case demonstrates the custom building of the SendGridMessage builder to allow for more advanced usage."}}
{"actor":{"display_login":"thinkingserious"}}