Skip to content

Commit

Permalink
Version Bump v4.0.0: BREAKING CHANGE #244
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious committed Apr 5, 2017
1 parent 8b11b6e commit 65943e4
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 39 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Change Log
All notable changes to this project will be documented in this file.

## [4.0.0] - 2017-04-05 ##
### BREAKING CHANGE
- Pull #244 [refactor helpers using property getter/setter](https://github.com/sendgrid/sendgrid-python/pull/244/files)
- Big thanks to [Denis Vlasov](https://github.com/denis90) for the pull request!
- The changes break the impelmentation of the [Mail Helper](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail) `Mail()` class
- `set_from()` is now the property `from_email`
- `set_subject()` is now the property `subject`
- `set_template_id()` is now the property `template_id`
- `set_send_at()` is now the property `send_at`
- `set_batch_id()` is now the property `batch_id`
- `set_asm()` is now the property `asm`
- `set_ip_pool_name()` is now the property `ip_pool_name`
- `set_mail_settings()` is now the property `mail_settings`
- `set_tracking_settings()` is now the property `tracking_settings`
- `set_reply_to()` is now the property `reply_to`
- `personalization.set_send_at()` is now the property `personalization.send_at`
- `personalization.set_subject()` is now the property `personalization.subject`
- `attachment.set_content()` is now the property `attachment.content`
- `attachment.set_type()` is now the property `attachment.type`
- `attachment.set_filename()` is now the property `attachment.filename`
- `attachment.set_disposition()` is now the property `attachment.disposition`
- `attachment.set_content_id()` is now the property `attachment.content_id`
- `mail_settings.set_bcc_settings()` is now the property `mail_settings.bcc_settings`
- `mail_settings.set_bypass_list_management()` is now the property `mail_settings.bypass_list_management`
- `mail_settings.set_footer_settings()` is now the property `mail_settings.footer_settings`
- `mail_settings.set_sandbox_mode()` is now the property `mail_settings.sandbox_mode`
- `mail_settings.set_spam_check()` is now the property `mail_settings.spam_check`
- `tracking_settings.set_click_tracking()` is now the property `click_tracking`
- `tracking_settings.set_open_tracking()` is now the property `open_tracking`
- `tracking_settings.set_subscription_tracking()` is now the property `subscription_tracking`
- `tracking_settings.set_ganalytics()` is now the property `ganalytics`

## [3.6.5] - 2017-03-30 ##
### Updated
- Pull #300 [Exclude test package](https://github.com/sendgrid/sendgrid-python/pull/250)
Expand Down
12 changes: 6 additions & 6 deletions USE_CASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ content = Content("text/html", "I'm replacing the <strong>body tag</strong>")
mail = Mail(from_email, subject, to_email, content)
mail.personalizations[0].add_substitution(Substitution("-name-", "Example User"))
mail.personalizations[0].add_substitution(Substitution("-city-", "Denver"))
mail.set_template_id("13b8f94f-bcae-4ec6-b752-70d6cb59f932")
mail.template_id = "13b8f94f-bcae-4ec6-b752-70d6cb59f932"
try:
response = sg.client.mail.send.post(request_body=mail.get())
except urllib.HTTPError as e:
Expand Down Expand Up @@ -151,11 +151,11 @@ with open(file_path,'rb') as f:
encoded = base64.b64encode(data).decode()

attachment = Attachment()
attachment.set_content(encoded)
attachment.set_type("application/pdf")
attachment.set_filename("test.pdf")
attachment.set_disposition("attachment")
attachment.set_content_id("Example Content ID")
attachment.content = encoded
attachment.type = "application/pdf"
attachment.filename = "test.pdf"
attachment.disposition = "attachment"
attachment.content_id = "Example Content ID"

mail = Mail(from_email, subject, to_email, content)
mail.add_attachment(attachment)
Expand Down
64 changes: 32 additions & 32 deletions examples/helpers/mail/mail_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def build_kitchen_sink():
"""All settings set"""
mail = Mail()

mail.set_from(Email("[email protected]", "Example User"))
mail.from_email = Email("[email protected]", "Example User")

mail.set_subject("Hello World from the SendGrid Python Library")
mail.subject = "Hello World from the SendGrid Python Library"

personalization = Personalization()
personalization.add_to(Email("[email protected]", "Example User"))
Expand All @@ -32,14 +32,14 @@ def build_kitchen_sink():
personalization.add_cc(Email("[email protected]", "Example User"))
personalization.add_bcc(Email("[email protected]"))
personalization.add_bcc(Email("[email protected]"))
personalization.set_subject("Hello World from the Personalized SendGrid Python Library")
personalization.subject = "Hello World from the Personalized SendGrid Python Library"
personalization.add_header(Header("X-Test", "test"))
personalization.add_header(Header("X-Mock", "true"))
personalization.add_substitution(Substitution("%name%", "Example User"))
personalization.add_substitution(Substitution("%city%", "Denver"))
personalization.add_custom_arg(CustomArg("user_id", "343"))
personalization.add_custom_arg(CustomArg("type", "marketing"))
personalization.set_send_at(1443636843)
personalization.send_at = 1443636843
mail.add_personalization(personalization)

personalization2 = Personalization()
Expand All @@ -49,36 +49,36 @@ def build_kitchen_sink():
personalization2.add_cc(Email("[email protected]", "Eric Shallock"))
personalization2.add_bcc(Email("[email protected]"))
personalization2.add_bcc(Email("[email protected]"))
personalization2.set_subject("Hello World from the Personalized SendGrid Python Library")
personalization2.subject = "Hello World from the Personalized SendGrid Python Library"
personalization2.add_header(Header("X-Test", "test"))
personalization2.add_header(Header("X-Mock", "true"))
personalization2.add_substitution(Substitution("%name%", "Example User"))
personalization2.add_substitution(Substitution("%city%", "Denver"))
personalization2.add_custom_arg(CustomArg("user_id", "343"))
personalization2.add_custom_arg(CustomArg("type", "marketing"))
personalization2.set_send_at(1443636843)
personalization2.send_at = 1443636843
mail.add_personalization(personalization2)

mail.add_content(Content("text/plain", "some text here"))
mail.add_content(Content("text/html", "<html><body>some text here</body></html>"))

attachment = Attachment()
attachment.set_content("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12")
attachment.set_type("application/pdf")
attachment.set_filename("balance_001.pdf")
attachment.set_disposition("attachment")
attachment.set_content_id("Balance Sheet")
attachment.content = "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12"
attachment.type = "application/pdf"
attachment.filename = "balance_001.pdf"
attachment.disposition = "attachment"
attachment.content_id = "Balance Sheet"
mail.add_attachment(attachment)

attachment2 = Attachment()
attachment2.set_content("BwdW")
attachment2.set_type("image/png")
attachment2.set_filename("banner.png")
attachment2.set_disposition("inline")
attachment2.set_content_id("Banner")
attachment2.content = "BwdW"
attachment2.type = "image/png"
attachment2.filename = "banner.png"
attachment2.disposition = "inline"
attachment2.content_id = "Banner"
mail.add_attachment(attachment2)

mail.set_template_id("13b8f94f-bcae-4ec6-b752-70d6cb59f932")
mail.template_id = "13b8f94f-bcae-4ec6-b752-70d6cb59f932"

mail.add_section(Section("%section1%", "Substitution Text for Section 1"))
mail.add_section(Section("%section2%", "Substitution Text for Section 2"))
Expand All @@ -92,31 +92,31 @@ def build_kitchen_sink():
mail.add_custom_arg(CustomArg("campaign", "welcome"))
mail.add_custom_arg(CustomArg("weekday", "morning"))

mail.set_send_at(1443636842)
mail.send_at = 1443636842

# This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) to work
# mail.set_batch_id("N2VkYjBjYWItMGU4OC0xMWU2LWJhMzYtZjQ1Yzg5OTBkNzkxLWM5ZTUyZjNhOA")

mail.set_asm(ASM(99, [4, 5, 6, 7, 8]))
mail.asm = ASM(99, [4, 5, 6, 7, 8])

mail.set_ip_pool_name("24")
mail.ip_pool_name = "24"

mail_settings = MailSettings()
mail_settings.set_bcc_settings(BCCSettings(True, Email("[email protected]")))
mail_settings.set_bypass_list_management(BypassListManagement(True))
mail_settings.set_footer_settings(FooterSettings(True, "Footer Text", "<html><body>Footer Text</body></html>"))
mail_settings.set_sandbox_mode(SandBoxMode(True))
mail_settings.set_spam_check(SpamCheck(True, 1, "https://spamcatcher.sendgrid.com"))
mail.set_mail_settings(mail_settings)
mail_settings.bcc_settings = BCCSettings(True, Email("[email protected]"))
mail_settings.bypass_list_management = BypassListManagement(True)
mail_settings.footer_settings = FooterSettings(True, "Footer Text", "<html><body>Footer Text</body></html>")
mail_settings.sandbox_mode = SandBoxMode(True)
mail_settings.spam_check = SpamCheck(True, 1, "https://spamcatcher.sendgrid.com")
mail.mail_settings = mail_settings

tracking_settings = TrackingSettings()
tracking_settings.set_click_tracking(ClickTracking(True, True))
tracking_settings.set_open_tracking(OpenTracking(True, "Optional tag to replace with the open image in the body of the message"))
tracking_settings.set_subscription_tracking(SubscriptionTracking(True, "text to insert into the text/plain portion of the message", "<html><body>html to insert into the text/html portion of the message</body></html>", "Optional tag to replace with the open image in the body of the message"))
tracking_settings.set_ganalytics(Ganalytics(True, "some source", "some medium", "some term", "some_content", "some_campaign"))
mail.set_tracking_settings(tracking_settings)
tracking_settings.click_tracking = ClickTracking(True, True)
tracking_settings.open_tracking = OpenTracking(True, "Optional tag to replace with the open image in the body of the message")
tracking_settings.subscription_tracking = SubscriptionTracking(True, "text to insert into the text/plain portion of the message", "<html><body>html to insert into the text/html portion of the message</body></html>", "Optional tag to replace with the open image in the body of the message")
tracking_settings.ganalytics = Ganalytics(True, "some source", "some medium", "some term", "some_content", "some_campaign")
mail.tracking_settings = tracking_settings

mail.set_reply_to(Email("[email protected]"))
mail.reply_to = Email("[email protected]")

return mail.get()

Expand Down
2 changes: 1 addition & 1 deletion sendgrid/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (3, 6, 5)
version_info = (4, 0, 0)
__version__ = '.'.join(str(v) for v in version_info)

0 comments on commit 65943e4

Please sign in to comment.