Skip to content

Commit 65943e4

Browse files
Version Bump v4.0.0: BREAKING CHANGE #244
1 parent 8b11b6e commit 65943e4

File tree

4 files changed

+71
-39
lines changed

4 files changed

+71
-39
lines changed

CHANGELOG.md

+32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [4.0.0] - 2017-04-05 ##
5+
### BREAKING CHANGE
6+
- Pull #244 [refactor helpers using property getter/setter](https://github.com/sendgrid/sendgrid-python/pull/244/files)
7+
- Big thanks to [Denis Vlasov](https://github.com/denis90) for the pull request!
8+
- The changes break the impelmentation of the [Mail Helper](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail) `Mail()` class
9+
- `set_from()` is now the property `from_email`
10+
- `set_subject()` is now the property `subject`
11+
- `set_template_id()` is now the property `template_id`
12+
- `set_send_at()` is now the property `send_at`
13+
- `set_batch_id()` is now the property `batch_id`
14+
- `set_asm()` is now the property `asm`
15+
- `set_ip_pool_name()` is now the property `ip_pool_name`
16+
- `set_mail_settings()` is now the property `mail_settings`
17+
- `set_tracking_settings()` is now the property `tracking_settings`
18+
- `set_reply_to()` is now the property `reply_to`
19+
- `personalization.set_send_at()` is now the property `personalization.send_at`
20+
- `personalization.set_subject()` is now the property `personalization.subject`
21+
- `attachment.set_content()` is now the property `attachment.content`
22+
- `attachment.set_type()` is now the property `attachment.type`
23+
- `attachment.set_filename()` is now the property `attachment.filename`
24+
- `attachment.set_disposition()` is now the property `attachment.disposition`
25+
- `attachment.set_content_id()` is now the property `attachment.content_id`
26+
- `mail_settings.set_bcc_settings()` is now the property `mail_settings.bcc_settings`
27+
- `mail_settings.set_bypass_list_management()` is now the property `mail_settings.bypass_list_management`
28+
- `mail_settings.set_footer_settings()` is now the property `mail_settings.footer_settings`
29+
- `mail_settings.set_sandbox_mode()` is now the property `mail_settings.sandbox_mode`
30+
- `mail_settings.set_spam_check()` is now the property `mail_settings.spam_check`
31+
- `tracking_settings.set_click_tracking()` is now the property `click_tracking`
32+
- `tracking_settings.set_open_tracking()` is now the property `open_tracking`
33+
- `tracking_settings.set_subscription_tracking()` is now the property `subscription_tracking`
34+
- `tracking_settings.set_ganalytics()` is now the property `ganalytics`
35+
436
## [3.6.5] - 2017-03-30 ##
537
### Updated
638
- Pull #300 [Exclude test package](https://github.com/sendgrid/sendgrid-python/pull/250)

USE_CASES.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ content = Content("text/html", "I'm replacing the <strong>body tag</strong>")
6363
mail = Mail(from_email, subject, to_email, content)
6464
mail.personalizations[0].add_substitution(Substitution("-name-", "Example User"))
6565
mail.personalizations[0].add_substitution(Substitution("-city-", "Denver"))
66-
mail.set_template_id("13b8f94f-bcae-4ec6-b752-70d6cb59f932")
66+
mail.template_id = "13b8f94f-bcae-4ec6-b752-70d6cb59f932"
6767
try:
6868
response = sg.client.mail.send.post(request_body=mail.get())
6969
except urllib.HTTPError as e:
@@ -151,11 +151,11 @@ with open(file_path,'rb') as f:
151151
encoded = base64.b64encode(data).decode()
152152

153153
attachment = Attachment()
154-
attachment.set_content(encoded)
155-
attachment.set_type("application/pdf")
156-
attachment.set_filename("test.pdf")
157-
attachment.set_disposition("attachment")
158-
attachment.set_content_id("Example Content ID")
154+
attachment.content = encoded
155+
attachment.type = "application/pdf"
156+
attachment.filename = "test.pdf"
157+
attachment.disposition = "attachment"
158+
attachment.content_id = "Example Content ID"
159159

160160
mail = Mail(from_email, subject, to_email, content)
161161
mail.add_attachment(attachment)

examples/helpers/mail/mail_example.py

+32-32
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def build_kitchen_sink():
2121
"""All settings set"""
2222
mail = Mail()
2323

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

26-
mail.set_subject("Hello World from the SendGrid Python Library")
26+
mail.subject = "Hello World from the SendGrid Python Library"
2727

2828
personalization = Personalization()
2929
personalization.add_to(Email("[email protected]", "Example User"))
@@ -32,14 +32,14 @@ def build_kitchen_sink():
3232
personalization.add_cc(Email("[email protected]", "Example User"))
3333
personalization.add_bcc(Email("[email protected]"))
3434
personalization.add_bcc(Email("[email protected]"))
35-
personalization.set_subject("Hello World from the Personalized SendGrid Python Library")
35+
personalization.subject = "Hello World from the Personalized SendGrid Python Library"
3636
personalization.add_header(Header("X-Test", "test"))
3737
personalization.add_header(Header("X-Mock", "true"))
3838
personalization.add_substitution(Substitution("%name%", "Example User"))
3939
personalization.add_substitution(Substitution("%city%", "Denver"))
4040
personalization.add_custom_arg(CustomArg("user_id", "343"))
4141
personalization.add_custom_arg(CustomArg("type", "marketing"))
42-
personalization.set_send_at(1443636843)
42+
personalization.send_at = 1443636843
4343
mail.add_personalization(personalization)
4444

4545
personalization2 = Personalization()
@@ -49,36 +49,36 @@ def build_kitchen_sink():
4949
personalization2.add_cc(Email("[email protected]", "Eric Shallock"))
5050
personalization2.add_bcc(Email("[email protected]"))
5151
personalization2.add_bcc(Email("[email protected]"))
52-
personalization2.set_subject("Hello World from the Personalized SendGrid Python Library")
52+
personalization2.subject = "Hello World from the Personalized SendGrid Python Library"
5353
personalization2.add_header(Header("X-Test", "test"))
5454
personalization2.add_header(Header("X-Mock", "true"))
5555
personalization2.add_substitution(Substitution("%name%", "Example User"))
5656
personalization2.add_substitution(Substitution("%city%", "Denver"))
5757
personalization2.add_custom_arg(CustomArg("user_id", "343"))
5858
personalization2.add_custom_arg(CustomArg("type", "marketing"))
59-
personalization2.set_send_at(1443636843)
59+
personalization2.send_at = 1443636843
6060
mail.add_personalization(personalization2)
6161

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

6565
attachment = Attachment()
66-
attachment.set_content("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12")
67-
attachment.set_type("application/pdf")
68-
attachment.set_filename("balance_001.pdf")
69-
attachment.set_disposition("attachment")
70-
attachment.set_content_id("Balance Sheet")
66+
attachment.content = "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12"
67+
attachment.type = "application/pdf"
68+
attachment.filename = "balance_001.pdf"
69+
attachment.disposition = "attachment"
70+
attachment.content_id = "Balance Sheet"
7171
mail.add_attachment(attachment)
7272

7373
attachment2 = Attachment()
74-
attachment2.set_content("BwdW")
75-
attachment2.set_type("image/png")
76-
attachment2.set_filename("banner.png")
77-
attachment2.set_disposition("inline")
78-
attachment2.set_content_id("Banner")
74+
attachment2.content = "BwdW"
75+
attachment2.type = "image/png"
76+
attachment2.filename = "banner.png"
77+
attachment2.disposition = "inline"
78+
attachment2.content_id = "Banner"
7979
mail.add_attachment(attachment2)
8080

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

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

95-
mail.set_send_at(1443636842)
95+
mail.send_at = 1443636842
9696

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

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

102-
mail.set_ip_pool_name("24")
102+
mail.ip_pool_name = "24"
103103

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

112112
tracking_settings = TrackingSettings()
113-
tracking_settings.set_click_tracking(ClickTracking(True, True))
114-
tracking_settings.set_open_tracking(OpenTracking(True, "Optional tag to replace with the open image in the body of the message"))
115-
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"))
116-
tracking_settings.set_ganalytics(Ganalytics(True, "some source", "some medium", "some term", "some_content", "some_campaign"))
117-
mail.set_tracking_settings(tracking_settings)
113+
tracking_settings.click_tracking = ClickTracking(True, True)
114+
tracking_settings.open_tracking = OpenTracking(True, "Optional tag to replace with the open image in the body of the message")
115+
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")
116+
tracking_settings.ganalytics = Ganalytics(True, "some source", "some medium", "some term", "some_content", "some_campaign")
117+
mail.tracking_settings = tracking_settings
118118

119-
mail.set_reply_to(Email("[email protected]"))
119+
mail.reply_to = Email("[email protected]")
120120

121121
return mail.get()
122122

sendgrid/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (3, 6, 5)
1+
version_info = (4, 0, 0)
22
__version__ = '.'.join(str(v) for v in version_info)

0 commit comments

Comments
 (0)