Skip to content

Commit eb41ba5

Browse files
committed
Merge branch 'master' of https://github.com/sendgrid/sendgrid-python into issue_417
2 parents b8fd029 + a403813 commit eb41ba5

25 files changed

Lines changed: 189 additions & 226 deletions

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ Please see [our helper](https://github.com/sendgrid/sendgrid-python/tree/master/
180180
<a name="announcements"></a>
181181
# Announcements
182182

183+
Join an experienced and passionate team that focuses on making an impact. Opportunities abound to grow the product - and grow your career! Check out our [Data Platform Engineer role](http://grnh.se/wbx1701)
184+
183185
Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-python/issues/217). Your support is appreciated!
184186

185187
All updates to this library are documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-python/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/java) for releases and breaking changes.

examples/user/user.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# PUT /user/password #
5050

5151
data = {
52-
"new_password": "new_password",
52+
"new_password": "new_password",
5353
"old_password": "old_password"
5454
}
5555
response = sg.client.user.password.put(request_body=data)
@@ -62,8 +62,8 @@
6262
# PATCH /user/profile #
6363

6464
data = {
65-
"city": "Orange",
66-
"first_name": "Example",
65+
"city": "Orange",
66+
"first_name": "Example",
6767
"last_name": "User"
6868
}
6969
response = sg.client.user.profile.patch(request_body=data)
@@ -85,7 +85,7 @@
8585
# POST /user/scheduled_sends #
8686

8787
data = {
88-
"batch_id": "YOUR_BATCH_ID",
88+
"batch_id": "YOUR_BATCH_ID",
8989
"status": "pause"
9090
}
9191
response = sg.client.user.scheduled_sends.post(request_body=data)
@@ -140,7 +140,7 @@
140140
# PATCH /user/settings/enforced_tls #
141141

142142
data = {
143-
"require_tls": True,
143+
"require_tls": True,
144144
"require_valid_cert": False
145145
}
146146
response = sg.client.user.settings.enforced_tls.patch(request_body=data)
@@ -183,18 +183,18 @@
183183
# PATCH /user/webhooks/event/settings #
184184

185185
data = {
186-
"bounce": True,
187-
"click": True,
188-
"deferred": True,
189-
"delivered": True,
190-
"dropped": True,
191-
"enabled": True,
192-
"group_resubscribe": True,
193-
"group_unsubscribe": True,
194-
"open": True,
195-
"processed": True,
196-
"spam_report": True,
197-
"unsubscribe": True,
186+
"bounce": True,
187+
"click": True,
188+
"deferred": True,
189+
"delivered": True,
190+
"dropped": True,
191+
"enabled": True,
192+
"group_resubscribe": True,
193+
"group_unsubscribe": True,
194+
"open": True,
195+
"processed": True,
196+
"spam_report": True,
197+
"unsubscribe": True,
198198
"url": "url"
199199
}
200200
response = sg.client.user.webhooks.event.settings.patch(request_body=data)
@@ -228,9 +228,9 @@
228228
# POST /user/webhooks/parse/settings #
229229

230230
data = {
231-
"hostname": "myhostname.com",
232-
"send_raw": False,
233-
"spam_check": True,
231+
"hostname": "myhostname.com",
232+
"send_raw": False,
233+
"spam_check": True,
234234
"url": "http://email.myhosthame.com"
235235
}
236236
response = sg.client.user.webhooks.parse.settings.post(request_body=data)
@@ -252,7 +252,7 @@
252252
# PATCH /user/webhooks/parse/settings/{hostname} #
253253

254254
data = {
255-
"send_raw": True,
255+
"send_raw": True,
256256
"spam_check": False,
257257
"url": "http://newdomain.com/parse"
258258
}

sendgrid/helpers/mail/asm.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ def __init__(self, group_id=None, groups_to_display=None):
99
:param groups_to_display: Unsubscribe groups to display
1010
:type groups_to_display: list(int), optional
1111
"""
12-
self._group_id = None
13-
self._groups_to_display = None
14-
15-
if group_id is not None:
16-
self._group_id = group_id
17-
18-
if groups_to_display is not None:
19-
self._groups_to_display = groups_to_display
12+
self.group_id = group_id
13+
self.groups_to_display = groups_to_display
2014

2115
@property
2216
def group_id(self):
@@ -41,6 +35,8 @@ def groups_to_display(self):
4135

4236
@groups_to_display.setter
4337
def groups_to_display(self, value):
38+
if value is not None and len(value) > 25:
39+
raise ValueError("New groups_to_display exceeds max length of 25.")
4440
self._groups_to_display = value
4541

4642
def get(self):

sendgrid/helpers/mail/bcc_settings.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@ def __init__(self, enable=None, email=None):
1313
:param email: Who should be BCCed.
1414
:type email: Email, optional
1515
"""
16-
self._enable = None
17-
self._email = None
18-
19-
if enable is not None:
20-
self.enable = enable
21-
22-
if email is not None:
23-
self.email = email
16+
self.enable = enable
17+
self.email = email
2418

2519
@property
2620
def enable(self):

sendgrid/helpers/mail/bypass_list_management.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ def __init__(self, enable=None):
1313
:param enable: Whether emails should bypass list management.
1414
:type enable: boolean, optional
1515
"""
16-
self._enable = None
17-
18-
if enable is not None:
19-
self.enable = enable
16+
self.enable = enable
2017

2118
@property
2219
def enable(self):

sendgrid/helpers/mail/category.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ def __init__(self, name=None):
77
:param name: The name of this category
88
:type name: string, optional
99
"""
10-
self._name = None
11-
if name is not None:
12-
self._name = name
10+
self.name = name
1311

1412
@property
1513
def name(self):

sendgrid/helpers/mail/click_tracking.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ def __init__(self, enable=None, enable_text=None):
99
:param enable_text: If click tracking is on in your email's text/plain.
1010
:type enable_text: boolean, optional
1111
"""
12-
self._enable = None
13-
self._enable_text = None
14-
15-
if enable is not None:
16-
self.enable = enable
17-
18-
if enable_text is not None:
19-
self.enable_text = enable_text
12+
self.enable = enable
13+
self.enable_text = enable_text
2014

2115
@property
2216
def enable(self):

sendgrid/helpers/mail/content.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@ def __init__(self, type_=None, value=None):
1212
:param value: The actual content.
1313
:type value: string, optional
1414
"""
15-
self._type = None
16-
self._value = None
17-
18-
if type_ is not None:
19-
self.type = type_
20-
21-
if value is not None:
22-
self.value = value
15+
self.type = type_
16+
self.value = value
2317

2418
@property
2519
def type(self):

sendgrid/helpers/mail/custom_arg.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ class CustomArg(object):
99

1010
def __init__(self, key=None, value=None):
1111
"""Create a CustomArg with the given key and value."""
12-
self._key = None
13-
self._value = None
14-
15-
if key is not None:
16-
self.key = key
17-
18-
if value is not None:
19-
self.value = value
12+
self.key = key
13+
self.value = value
2014

2115
@property
2216
def key(self):

sendgrid/helpers/mail/email.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
try:
2+
import rfc822
3+
except ImportError:
4+
import email.utils as rfc822
5+
6+
17
class Email(object):
28
"""An email address with an optional name."""
39

@@ -11,17 +17,13 @@ def __init__(self, email=None, name=None):
1117
:param name: Name for this sender or recipient.
1218
:type name: string
1319
"""
14-
self._name = None
15-
self._email = None
16-
if name or email:
17-
if not name:
18-
# allows passing emails as "dude Fella <example@example.com>"
19-
self.parse_email(email)
20-
else:
21-
# allows backwards compatibility for Email(email, name)
22-
if email is not None:
23-
self.email = email
24-
self.name = name
20+
if email and not name:
21+
# allows passing emails as "dude Fella <example@example.com>"
22+
self.parse_email(email)
23+
else:
24+
# allows backwards compatibility for Email(email, name)
25+
self.email = email
26+
self.name = name
2527

2628
@property
2729
def name(self):
@@ -65,11 +67,6 @@ def get(self):
6567
return email
6668

6769
def parse_email(self, email_info):
68-
try:
69-
import rfc822
70-
except ImportError:
71-
import email.utils as rfc822
72-
7370
name, email = rfc822.parseaddr(email_info)
7471

7572
# more than likely a string was passed here instead of an email address

0 commit comments

Comments
 (0)