diff --git a/examples/accesssettings/accesssettings.py b/examples/accesssettings/accesssettings.py index aac0e4a54..5cbf1c35b 100644 --- a/examples/accesssettings/accesssettings.py +++ b/examples/accesssettings/accesssettings.py @@ -20,17 +20,17 @@ # POST /access_settings/whitelist # data = { - "ips": [ - { - "ip": "192.168.1.1" - }, - { - "ip": "192.*.*.*" - }, - { - "ip": "192.168.1.3/32" - } - ] + "ips": [ + { + "ip": "192.168.1.1" + }, + { + "ip": "192.*.*.*" + }, + { + "ip": "192.168.1.3/32" + } + ] } response = sg.client.access_settings.whitelist.post(request_body=data) print(response.status_code) @@ -51,11 +51,11 @@ # DELETE /access_settings/whitelist # data = { - "ids": [ - 1, - 2, - 3 - ] + "ids": [ + 1, + 2, + 3 + ] } response = sg.client.access_settings.whitelist.delete(request_body=data) print(response.status_code) @@ -81,4 +81,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/alerts/alerts.py b/examples/alerts/alerts.py index e30d48748..df2aef700 100644 --- a/examples/alerts/alerts.py +++ b/examples/alerts/alerts.py @@ -10,9 +10,9 @@ # POST /alerts # data = { - "email_to": "example@example.com", - "frequency": "daily", - "type": "stats_notification" + "email_to": "example@example.com", + "frequency": "daily", + "type": "stats_notification" } response = sg.client.alerts.post(request_body=data) print(response.status_code) @@ -33,7 +33,7 @@ # PATCH /alerts/{alert_id} # data = { - "email_to": "example@example.com" + "email_to": "example@example.com" } alert_id = "test_url_param" response = sg.client.alerts._(alert_id).patch(request_body=data) @@ -60,4 +60,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/apikeys/apikeys.py b/examples/apikeys/apikeys.py index 42c3afa10..0699d385b 100644 --- a/examples/apikeys/apikeys.py +++ b/examples/apikeys/apikeys.py @@ -10,13 +10,13 @@ # POST /api_keys # data = { - "name": "My API Key", - "sample": "data", - "scopes": [ - "mail.send", - "alerts.create", - "alerts.read" - ] + "name": "My API Key", + "sample": "data", + "scopes": [ + "mail.send", + "alerts.create", + "alerts.read" + ] } response = sg.client.api_keys.post(request_body=data) print(response.status_code) @@ -38,11 +38,11 @@ # PUT /api_keys/{api_key_id} # data = { - "name": "A New Hope", - "scopes": [ - "user.profile.read", - "user.profile.update" - ] + "name": "A New Hope", + "scopes": [ + "user.profile.read", + "user.profile.update" + ] } api_key_id = "test_url_param" response = sg.client.api_keys._(api_key_id).put(request_body=data) @@ -55,7 +55,7 @@ # PATCH /api_keys/{api_key_id} # data = { - "name": "A New Hope" + "name": "A New Hope" } api_key_id = "test_url_param" response = sg.client.api_keys._(api_key_id).patch(request_body=data) @@ -82,4 +82,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/asm/asm.py b/examples/asm/asm.py index 43130cf06..40f35576a 100644 --- a/examples/asm/asm.py +++ b/examples/asm/asm.py @@ -10,9 +10,9 @@ # POST /asm/groups # data = { - "description": "Suggestions for products our users might like.", - "is_default": True, - "name": "Product Suggestions" + "description": "Suggestions for products our users might like.", + "is_default": True, + "name": "Product Suggestions" } response = sg.client.asm.groups.post(request_body=data) print(response.status_code) @@ -34,9 +34,9 @@ # PATCH /asm/groups/{group_id} # data = { - "description": "Suggestions for items our users might like.", - "id": 103, - "name": "Item Suggestions" + "description": "Suggestions for items our users might like.", + "id": 103, + "name": "Item Suggestions" } group_id = "test_url_param" response = sg.client.asm.groups._(group_id).patch(request_body=data) @@ -69,13 +69,14 @@ # POST /asm/groups/{group_id}/suppressions # data = { - "recipient_emails": [ - "test1@example.com", - "test2@example.com" - ] + "recipient_emails": [ + "test1@example.com", + "test2@example.com" + ] } group_id = "test_url_param" -response = sg.client.asm.groups._(group_id).suppressions.post(request_body=data) +response = sg.client.asm.groups._( + group_id).suppressions.post(request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -95,14 +96,15 @@ # POST /asm/groups/{group_id}/suppressions/search # data = { - "recipient_emails": [ - "exists1@example.com", - "exists2@example.com", - "doesnotexists@example.com" - ] + "recipient_emails": [ + "exists1@example.com", + "exists2@example.com", + "doesnotexists@example.com" + ] } group_id = "test_url_param" -response = sg.client.asm.groups._(group_id).suppressions.search.post(request_body=data) +response = sg.client.asm.groups._( + group_id).suppressions.search.post(request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -132,10 +134,10 @@ # POST /asm/suppressions/global # data = { - "recipient_emails": [ - "test1@example.com", - "test2@example.com" - ] + "recipient_emails": [ + "test1@example.com", + "test2@example.com" + ] } response = sg.client.asm.suppressions._("global").post(request_body=data) print(response.status_code) @@ -171,4 +173,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/browsers/browsers.py b/examples/browsers/browsers.py index c123c12e5..eb0b9b8ad 100644 --- a/examples/browsers/browsers.py +++ b/examples/browsers/browsers.py @@ -9,9 +9,13 @@ # Retrieve email statistics by browser. # # GET /browsers/stats # -params = {'end_date': '2016-04-01', 'aggregated_by': 'day', 'browsers': 'test_string', 'limit': 'test_string', 'offset': 'test_string', 'start_date': '2016-01-01'} +params = {'end_date': '2016-04-01', + 'aggregated_by': 'day', + 'browsers': 'test_string', + 'limit': 'test_string', + 'offset': 'test_string', + 'start_date': '2016-01-01'} response = sg.client.browsers.stats.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/campaigns/campaigns.py b/examples/campaigns/campaigns.py index c77fc878b..76bdaeb9e 100644 --- a/examples/campaigns/campaigns.py +++ b/examples/campaigns/campaigns.py @@ -10,24 +10,24 @@ # POST /campaigns # data = { - "categories": [ - "spring line" - ], - "custom_unsubscribe_url": "", - "html_content": "
Check out our spring line!
", - "ip_pool": "marketing", - "list_ids": [ - 110, - 124 - ], - "plain_content": "Check out our spring line!", - "segment_ids": [ - 110 - ], - "sender_id": 124451, - "subject": "New Products for Spring!", - "suppression_group_id": 42, - "title": "March Newsletter" + "categories": [ + "spring line" + ], + "custom_unsubscribe_url": "", + "html_content": "Check out our spring line!
", + "ip_pool": "marketing", + "list_ids": [ + 110, + 124 + ], + "plain_content": "Check out our spring line!", + "segment_ids": [ + 110 + ], + "sender_id": 124451, + "subject": "New Products for Spring!", + "suppression_group_id": 42, + "title": "March Newsletter" } response = sg.client.campaigns.post(request_body=data) print(response.status_code) @@ -49,13 +49,13 @@ # PATCH /campaigns/{campaign_id} # data = { - "categories": [ - "summer line" - ], - "html_content": "Check out our summer line!
", - "plain_content": "Check out our summer line!", - "subject": "New Products for Summer!", - "title": "May Newsletter" + "categories": [ + "summer line" + ], + "html_content": "Check out our summer line!
", + "plain_content": "Check out our summer line!", + "subject": "New Products for Summer!", + "title": "May Newsletter" } campaign_id = "test_url_param" response = sg.client.campaigns._(campaign_id).patch(request_body=data) @@ -88,10 +88,11 @@ # PATCH /campaigns/{campaign_id}/schedules # data = { - "send_at": 1489451436 + "send_at": 1489451436 } campaign_id = "test_url_param" -response = sg.client.campaigns._(campaign_id).schedules.patch(request_body=data) +response = sg.client.campaigns._( + campaign_id).schedules.patch(request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -101,7 +102,7 @@ # POST /campaigns/{campaign_id}/schedules # data = { - "send_at": 1489771528 + "send_at": 1489771528 } campaign_id = "test_url_param" response = sg.client.campaigns._(campaign_id).schedules.post(request_body=data) @@ -144,11 +145,11 @@ # POST /campaigns/{campaign_id}/schedules/test # data = { - "to": "your.email@example.com" + "to": "your.email@example.com" } campaign_id = "test_url_param" -response = sg.client.campaigns._(campaign_id).schedules.test.post(request_body=data) +response = sg.client.campaigns._( + campaign_id).schedules.test.post(request_body=data) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/categories/categories.py b/examples/categories/categories.py index 7984f0fe0..774284ee8 100644 --- a/examples/categories/categories.py +++ b/examples/categories/categories.py @@ -19,7 +19,8 @@ # Retrieve Email Statistics for Categories # # GET /categories/stats # -params = {'end_date': '2016-04-01', 'aggregated_by': 'day', 'limit': 1, 'offset': 1, 'start_date': '2016-01-01', 'categories': 'test_string'} +params = {'end_date': '2016-04-01', 'aggregated_by': 'day', 'limit': 1, + 'offset': 1, 'start_date': '2016-01-01', 'categories': 'test_string'} response = sg.client.categories.stats.get(query_params=params) print(response.status_code) print(response.body) @@ -29,9 +30,14 @@ # Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?] # # GET /categories/stats/sums # -params = {'end_date': '2016-04-01', 'aggregated_by': 'day', 'limit': 1, 'sort_by_metric': 'test_string', 'offset': 1, 'start_date': '2016-01-01', 'sort_by_direction': 'asc'} +params = {'end_date': '2016-04-01', + 'aggregated_by': 'day', + 'limit': 1, + 'sort_by_metric': 'test_string', + 'offset': 1, + 'start_date': '2016-01-01', + 'sort_by_direction': 'asc'} response = sg.client.categories.stats.sums.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/clients/clients.py b/examples/clients/clients.py index 7831ef78f..1a36fdd0d 100644 --- a/examples/clients/clients.py +++ b/examples/clients/clients.py @@ -9,7 +9,9 @@ # Retrieve email statistics by client type. # # GET /clients/stats # -params = {'aggregated_by': 'day', 'start_date': '2016-01-01', 'end_date': '2016-04-01'} +params = {'aggregated_by': 'day', + 'start_date': '2016-01-01', + 'end_date': '2016-04-01'} response = sg.client.clients.stats.get(query_params=params) print(response.status_code) print(response.body) @@ -19,10 +21,11 @@ # Retrieve stats by a specific client type. # # GET /clients/{client_type}/stats # -params = {'aggregated_by': 'day', 'start_date': '2016-01-01', 'end_date': '2016-04-01'} +params = {'aggregated_by': 'day', + 'start_date': '2016-01-01', + 'end_date': '2016-04-01'} client_type = "test_url_param" response = sg.client.clients._(client_type).stats.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/contactdb/contactdb.py b/examples/contactdb/contactdb.py index c234d7724..f07336c1d 100644 --- a/examples/contactdb/contactdb.py +++ b/examples/contactdb/contactdb.py @@ -10,8 +10,8 @@ # POST /contactdb/custom_fields # data = { - "name": "pet", - "type": "text" + "name": "pet", + "type": "text" } response = sg.client.contactdb.custom_fields.post(request_body=data) print(response.status_code) @@ -52,7 +52,7 @@ # POST /contactdb/lists # data = { - "name": "your list name" + "name": "your list name" } response = sg.client.contactdb.lists.post(request_body=data) print(response.status_code) @@ -73,10 +73,10 @@ # DELETE /contactdb/lists # data = [ - 1, - 2, - 3, - 4 + 1, + 2, + 3, + 4 ] response = sg.client.contactdb.lists.delete(request_body=data) print(response.status_code) @@ -88,11 +88,13 @@ # PATCH /contactdb/lists/{list_id} # data = { - "name": "newlistname" + "name": "newlistname" } params = {'list_id': 1} list_id = "test_url_param" -response = sg.client.contactdb.lists._(list_id).patch(request_body=data, query_params=params) +response = sg.client.contactdb.lists._(list_id).patch( + request_body=data, + query_params=params) print(response.status_code) print(response.body) print(response.headers) @@ -124,11 +126,12 @@ # POST /contactdb/lists/{list_id}/recipients # data = [ - "recipient_id1", - "recipient_id2" + "recipient_id1", + "recipient_id2" ] list_id = "test_url_param" -response = sg.client.contactdb.lists._(list_id).recipients.post(request_body=data) +response = sg.client.contactdb.lists._( + list_id).recipients.post(request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -139,7 +142,8 @@ params = {'page': 1, 'page_size': 1} list_id = "test_url_param" -response = sg.client.contactdb.lists._(list_id).recipients.get(query_params=params) +response = sg.client.contactdb.lists._( + list_id).recipients.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) @@ -150,7 +154,8 @@ list_id = "test_url_param" recipient_id = "test_url_param" -response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).post() +response = sg.client.contactdb.lists._( + list_id).recipients._(recipient_id).post() print(response.status_code) print(response.body) print(response.headers) @@ -162,7 +167,8 @@ params = {'recipient_id': 1, 'list_id': 1} list_id = "test_url_param" recipient_id = "test_url_param" -response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).delete(query_params=params) +response = sg.client.contactdb.lists._(list_id).recipients._( + recipient_id).delete(query_params=params) print(response.status_code) print(response.body) print(response.headers) @@ -172,11 +178,11 @@ # PATCH /contactdb/recipients # data = [ - { - "email": "jones@example.com", - "first_name": "Guy", - "last_name": "Jones" - } + { + "email": "jones@example.com", + "first_name": "Guy", + "last_name": "Jones" + } ] response = sg.client.contactdb.recipients.patch(request_body=data) print(response.status_code) @@ -188,18 +194,18 @@ # POST /contactdb/recipients # data = [ - { - "age": 25, - "email": "example@example.com", - "first_name": "", - "last_name": "User" - }, - { - "age": 25, - "email": "example2@example.com", - "first_name": "Example", - "last_name": "User" - } + { + "age": 25, + "email": "example@example.com", + "first_name": "", + "last_name": "User" + }, + { + "age": 25, + "email": "example2@example.com", + "first_name": "Example", + "last_name": "User" + } ] response = sg.client.contactdb.recipients.post(request_body=data) print(response.status_code) @@ -221,8 +227,8 @@ # DELETE /contactdb/recipients # data = [ - "recipient_id1", - "recipient_id2" + "recipient_id1", + "recipient_id2" ] response = sg.client.contactdb.recipients.delete(request_body=data) print(response.status_code) @@ -301,28 +307,28 @@ # POST /contactdb/segments # data = { - "conditions": [ - { - "and_or": "", - "field": "last_name", - "operator": "eq", - "value": "Miller" - }, - { - "and_or": "and", - "field": "last_clicked", - "operator": "gt", - "value": "01/02/2015" - }, - { - "and_or": "or", - "field": "clicks.campaign_identifier", - "operator": "eq", - "value": "513" - } - ], - "list_id": 4, - "name": "Last Name Miller" + "conditions": [ + { + "and_or": "", + "field": "last_name", + "operator": "eq", + "value": "Miller" + }, + { + "and_or": "and", + "field": "last_clicked", + "operator": "gt", + "value": "01/02/2015" + }, + { + "and_or": "or", + "field": "clicks.campaign_identifier", + "operator": "eq", + "value": "513" + } + ], + "list_id": 4, + "name": "Last Name Miller" } response = sg.client.contactdb.segments.post(request_body=data) print(response.status_code) @@ -343,20 +349,22 @@ # PATCH /contactdb/segments/{segment_id} # data = { - "conditions": [ - { - "and_or": "", - "field": "last_name", - "operator": "eq", - "value": "Miller" - } - ], - "list_id": 5, - "name": "The Millers" + "conditions": [ + { + "and_or": "", + "field": "last_name", + "operator": "eq", + "value": "Miller" + } + ], + "list_id": 5, + "name": "The Millers" } params = {'segment_id': 'test_string'} segment_id = "test_url_param" -response = sg.client.contactdb.segments._(segment_id).patch(request_body=data, query_params=params) +response = sg.client.contactdb.segments._(segment_id).patch( + request_body=data, + query_params=params) print(response.status_code) print(response.body) print(response.headers) @@ -378,7 +386,8 @@ params = {'delete_contacts': 'true'} segment_id = "test_url_param" -response = sg.client.contactdb.segments._(segment_id).delete(query_params=params) +response = sg.client.contactdb.segments._( + segment_id).delete(query_params=params) print(response.status_code) print(response.body) print(response.headers) @@ -389,8 +398,8 @@ params = {'page': 1, 'page_size': 1} segment_id = "test_url_param" -response = sg.client.contactdb.segments._(segment_id).recipients.get(query_params=params) +response = sg.client.contactdb.segments._( + segment_id).recipients.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/devices/devices.py b/examples/devices/devices.py index 108e98452..8fab92921 100644 --- a/examples/devices/devices.py +++ b/examples/devices/devices.py @@ -9,9 +9,11 @@ # Retrieve email statistics by device type. # # GET /devices/stats # -params = {'aggregated_by': 'day', 'limit': 1, 'start_date': '2016-01-01', 'end_date': '2016-04-01', 'offset': 1} +params = {'aggregated_by': 'day', 'limit': 1, + 'start_date': '2016-01-01', + 'end_date': '2016-04-01', + 'offset': 1} response = sg.client.devices.stats.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/geo/geo.py b/examples/geo/geo.py index 7d58ec085..78bf1552f 100644 --- a/examples/geo/geo.py +++ b/examples/geo/geo.py @@ -9,9 +9,13 @@ # Retrieve email statistics by country and state/province. # # GET /geo/stats # -params = {'end_date': '2016-04-01', 'country': 'US', 'aggregated_by': 'day', 'limit': 1, 'offset': 1, 'start_date': '2016-01-01'} +params = {'end_date': '2016-04-01', + 'country': 'US', + 'aggregated_by': 'day', + 'limit': 1, + 'offset': 1, + 'start_date': '2016-01-01'} response = sg.client.geo.stats.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/helpers/mail/mail_example.py b/examples/helpers/mail/mail_example.py index a36cefbf6..5ea39d334 100644 --- a/examples/helpers/mail/mail_example.py +++ b/examples/helpers/mail/mail_example.py @@ -216,4 +216,4 @@ def send_kitchen_sink(): send_hello_email() # this will only send an email if you set SandBox Mode to False -send_kitchen_sink() +send_kitchen_sink() \ No newline at end of file diff --git a/examples/ips/ips.py b/examples/ips/ips.py index 6c48ae306..5d3e4e0bd 100644 --- a/examples/ips/ips.py +++ b/examples/ips/ips.py @@ -9,7 +9,8 @@ # Retrieve all IP addresses # # GET /ips # -params = {'subuser': 'test_string', 'ip': 'test_string', 'limit': 1, 'exclude_whitelabels': 'true', 'offset': 1} +params = {'subuser': 'test_string', 'ip': 'test_string', + 'limit': 1, 'exclude_whitelabels': 'true', 'offset': 1} response = sg.client.ips.get(query_params=params) print(response.status_code) print(response.body) @@ -29,7 +30,7 @@ # POST /ips/pools # data = { - "name": "marketing" + "name": "marketing" } response = sg.client.ips.pools.post(request_body=data) print(response.status_code) @@ -50,7 +51,7 @@ # PUT /ips/pools/{pool_name} # data = { - "name": "new_pool_name" + "name": "new_pool_name" } pool_name = "test_url_param" response = sg.client.ips.pools._(pool_name).put(request_body=data) @@ -83,7 +84,7 @@ # POST /ips/pools/{pool_name}/ips # data = { - "ip": "0.0.0.0" + "ip": "0.0.0.0" } pool_name = "test_url_param" response = sg.client.ips.pools._(pool_name).ips.post(request_body=data) @@ -107,7 +108,7 @@ # POST /ips/warmup # data = { - "ip": "0.0.0.0" + "ip": "0.0.0.0" } response = sg.client.ips.warmup.post(request_body=data) print(response.status_code) @@ -152,4 +153,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/mail/mail.py b/examples/mail/mail.py index fef420e87..253c2558a 100644 --- a/examples/mail/mail.py +++ b/examples/mail/mail.py @@ -27,148 +27,148 @@ ################################################## # v3 Mail Send # # POST /mail/send # -# This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-python/blob/master/sendgrid/helpers/mail/README.md). +# This endpoint has a helper, check it out +# [here](https://github.com/sendgrid/sendgrid-python/blob/master/sendgrid/helpers/mail/README.md). data = { - "asm": { - "group_id": 1, - "groups_to_display": [ - 1, - 2, - 3 - ] - }, - "attachments": [ - { - "content": "[BASE64 encoded content block here]", - "content_id": "ii_139db99fdb5c3704", - "disposition": "inline", - "filename": "file1.jpg", - "name": "file1", - "type": "jpg" - } - ], - "batch_id": "[YOUR BATCH ID GOES HERE]", - "categories": [ - "category1", - "category2" - ], - "content": [ - { - "type": "text/html", - "value": "Hello, world!
ThanksThe SendGrid Team
", - "text": "Thanks,/n The SendGrid Team" - }, - "sandbox_mode": { - "enable": False - }, - "spam_check": { - "enable": True, - "post_to_url": "http://example.com/compliance", - "threshold": 3 - } - }, - "personalizations": [ - { - "bcc": [ + "asm": { + "group_id": 1, + "groups_to_display": [ + 1, + 2, + 3 + ] + }, + "attachments": [ { - "email": "sam.doe@example.com", - "name": "Sam Doe" + "content": "[BASE64 encoded content block here]", + "content_id": "ii_139db99fdb5c3704", + "disposition": "inline", + "filename": "file1.jpg", + "name": "file1", + "type": "jpg" } - ], - "cc": [ + ], + "batch_id": "[YOUR BATCH ID GOES HERE]", + "categories": [ + "category1", + "category2" + ], + "content": [ { - "email": "jane.doe@example.com", - "name": "Jane Doe" + "type": "text/html", + "value": "Hello, world!
ThanksThe SendGrid Team
", + "text": "Thanks,/n The SendGrid Team" + }, + "sandbox_mode": { + "enable": False + }, + "spam_check": { + "enable": True, + "post_to_url": "http://example.com/compliance", + "threshold": 3 + } + }, + "personalizations": [ { - "email": "john.doe@example.com", - "name": "John Doe" + "bcc": [ + { + "email": "sam.doe@example.com", + "name": "Sam Doe" + } + ], + "cc": [ + { + "email": "jane.doe@example.com", + "name": "Jane Doe" + } + ], + "custom_args": { + "New Argument 1": "New Value 1", + "activationAttempt": "1", + "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" + }, + "headers": { + "X-Accept-Language": "en", + "X-Mailer": "MyApp" + }, + "send_at": 1409348513, + "subject": "Hello, World!", + "substitutions": { + "id": "substitutions", + "type": "object" + }, + "to": [ + { + "email": "john.doe@example.com", + "name": "John Doe" + } + ] + } + ], + "reply_to": { + "email": "sam.smith@example.com", + "name": "Sam Smith" + }, + "sections": { + "section": { + ":sectionName1": "section 1 text", + ":sectionName2": "section 2 text" + } + }, + "send_at": 1409348513, + "subject": "Hello, World!", + "template_id": "[YOUR TEMPLATE ID GOES HERE]", + "tracking_settings": { + "click_tracking": { + "enable": True, + "enable_text": True + }, + "ganalytics": { + "enable": True, + "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]", + "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]", + "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]", + "utm_name": "[NAME OF YOUR CAMPAIGN]", + "utm_term": "[IDENTIFY PAID KEYWORDS HERE]" + }, + "open_tracking": { + "enable": True, + "substitution_tag": "%opentrack" + }, + "subscription_tracking": { + "enable": True, + "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.", + "substitution_tag": "<%click here%>", + "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>." } - ] - } - ], - "reply_to": { - "email": "sam.smith@example.com", - "name": "Sam Smith" - }, - "sections": { - "section": { - ":sectionName1": "section 1 text", - ":sectionName2": "section 2 text" - } - }, - "send_at": 1409348513, - "subject": "Hello, World!", - "template_id": "[YOUR TEMPLATE ID GOES HERE]", - "tracking_settings": { - "click_tracking": { - "enable": True, - "enable_text": True - }, - "ganalytics": { - "enable": True, - "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]", - "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]", - "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]", - "utm_name": "[NAME OF YOUR CAMPAIGN]", - "utm_term": "[IDENTIFY PAID KEYWORDS HERE]" - }, - "open_tracking": { - "enable": True, - "substitution_tag": "%opentrack" - }, - "subscription_tracking": { - "enable": True, - "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.", - "substitution_tag": "<%click here%>", - "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>." } - } } response = sg.client.mail.send.post(request_body=data) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/mailboxproviders/mailboxproviders.py b/examples/mailboxproviders/mailboxproviders.py index 1b75ecac5..a95b388b4 100644 --- a/examples/mailboxproviders/mailboxproviders.py +++ b/examples/mailboxproviders/mailboxproviders.py @@ -9,9 +9,13 @@ # Retrieve email statistics by mailbox provider. # # GET /mailbox_providers/stats # -params = {'end_date': '2016-04-01', 'mailbox_providers': 'test_string', 'aggregated_by': 'day', 'limit': 1, 'offset': 1, 'start_date': '2016-01-01'} +params = {'end_date': '2016-04-01', + 'mailbox_providers': 'test_string', + 'aggregated_by': 'day', + 'limit': 1, + 'offset': 1, + 'start_date': '2016-01-01'} response = sg.client.mailbox_providers.stats.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/mailsettings/mailsettings.py b/examples/mailsettings/mailsettings.py index 18c57b960..e0d89b5fa 100644 --- a/examples/mailsettings/mailsettings.py +++ b/examples/mailsettings/mailsettings.py @@ -20,11 +20,11 @@ # PATCH /mail_settings/address_whitelist # data = { - "enabled": True, - "list": [ - "email1@example.com", - "example.com" - ] + "enabled": True, + "list": [ + "email1@example.com", + "example.com" + ] } response = sg.client.mail_settings.address_whitelist.patch(request_body=data) print(response.status_code) @@ -45,8 +45,8 @@ # PATCH /mail_settings/bcc # data = { - "email": "email@example.com", - "enabled": False + "email": "email@example.com", + "enabled": False } response = sg.client.mail_settings.bcc.patch(request_body=data) print(response.status_code) @@ -67,9 +67,9 @@ # PATCH /mail_settings/bounce_purge # data = { - "enabled": True, - "hard_bounces": 5, - "soft_bounces": 5 + "enabled": True, + "hard_bounces": 5, + "soft_bounces": 5 } response = sg.client.mail_settings.bounce_purge.patch(request_body=data) print(response.status_code) @@ -90,9 +90,9 @@ # PATCH /mail_settings/footer # data = { - "enabled": True, - "html_content": "...", - "plain_content": "..." + "enabled": True, + "html_content": "...", + "plain_content": "..." } response = sg.client.mail_settings.footer.patch(request_body=data) print(response.status_code) @@ -113,8 +113,8 @@ # PATCH /mail_settings/forward_bounce # data = { - "email": "example@example.com", - "enabled": True + "email": "example@example.com", + "enabled": True } response = sg.client.mail_settings.forward_bounce.patch(request_body=data) print(response.status_code) @@ -135,8 +135,8 @@ # PATCH /mail_settings/forward_spam # data = { - "email": "", - "enabled": False + "email": "", + "enabled": False } response = sg.client.mail_settings.forward_spam.patch(request_body=data) print(response.status_code) @@ -157,7 +157,7 @@ # PATCH /mail_settings/plain_content # data = { - "enabled": False + "enabled": False } response = sg.client.mail_settings.plain_content.patch(request_body=data) print(response.status_code) @@ -178,9 +178,9 @@ # PATCH /mail_settings/spam_check # data = { - "enabled": True, - "max_score": 5, - "url": "url" + "enabled": True, + "max_score": 5, + "url": "url" } response = sg.client.mail_settings.spam_check.patch(request_body=data) print(response.status_code) @@ -201,8 +201,8 @@ # PATCH /mail_settings/template # data = { - "enabled": True, - "html_content": "<% body %>" + "enabled": True, + "html_content": "<% body %>" } response = sg.client.mail_settings.template.patch(request_body=data) print(response.status_code) @@ -217,4 +217,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/partnersettings/partnersettings.py b/examples/partnersettings/partnersettings.py index 37f77f4e6..fa2589b55 100644 --- a/examples/partnersettings/partnersettings.py +++ b/examples/partnersettings/partnersettings.py @@ -20,9 +20,9 @@ # PATCH /partner_settings/new_relic # data = { - "enable_subuser_statistics": True, - "enabled": True, - "license_key": "" + "enable_subuser_statistics": True, + "enabled": True, + "license_key": "" } response = sg.client.partner_settings.new_relic.patch(request_body=data) print(response.status_code) @@ -37,4 +37,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/scopes/scopes.py b/examples/scopes/scopes.py index 124f77d39..c9d4f1209 100644 --- a/examples/scopes/scopes.py +++ b/examples/scopes/scopes.py @@ -13,4 +13,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/senders/senders.py b/examples/senders/senders.py index f21459b71..f198a8f91 100644 --- a/examples/senders/senders.py +++ b/examples/senders/senders.py @@ -10,21 +10,21 @@ # POST /senders # data = { - "address": "123 Elm St.", - "address_2": "Apt. 456", - "city": "Denver", - "country": "United States", - "from": { - "email": "from@example.com", - "name": "Example INC" - }, - "nickname": "My Sender ID", - "reply_to": { - "email": "replyto@example.com", - "name": "Example INC" - }, - "state": "Colorado", - "zip": "80202" + "address": "123 Elm St.", + "address_2": "Apt. 456", + "city": "Denver", + "country": "United States", + "from": { + "email": "from@example.com", + "name": "Example INC" + }, + "nickname": "My Sender ID", + "reply_to": { + "email": "replyto@example.com", + "name": "Example INC" + }, + "state": "Colorado", + "zip": "80202" } response = sg.client.senders.post(request_body=data) print(response.status_code) @@ -45,21 +45,21 @@ # PATCH /senders/{sender_id} # data = { - "address": "123 Elm St.", - "address_2": "Apt. 456", - "city": "Denver", - "country": "United States", - "from": { - "email": "from@example.com", - "name": "Example INC" - }, - "nickname": "My Sender ID", - "reply_to": { - "email": "replyto@example.com", - "name": "Example INC" - }, - "state": "Colorado", - "zip": "80202" + "address": "123 Elm St.", + "address_2": "Apt. 456", + "city": "Denver", + "country": "United States", + "from": { + "email": "from@example.com", + "name": "Example INC" + }, + "nickname": "My Sender ID", + "reply_to": { + "email": "replyto@example.com", + "name": "Example INC" + }, + "state": "Colorado", + "zip": "80202" } sender_id = "test_url_param" response = sg.client.senders._(sender_id).patch(request_body=data) @@ -96,4 +96,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/stats/stats.py b/examples/stats/stats.py index a7bf3362e..4ddce6b75 100644 --- a/examples/stats/stats.py +++ b/examples/stats/stats.py @@ -9,9 +9,9 @@ # Retrieve global email statistics # # GET /stats # -params = {'aggregated_by': 'day', 'limit': 1, 'start_date': '2016-01-01', 'end_date': '2016-04-01', 'offset': 1} +params = {'aggregated_by': 'day', 'limit': 1, + 'start_date': '2016-01-01', 'end_date': '2016-04-01', 'offset': 1} response = sg.client.stats.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/subusers/subusers.py b/examples/subusers/subusers.py index 6aa91e535..3d79bfb11 100644 --- a/examples/subusers/subusers.py +++ b/examples/subusers/subusers.py @@ -10,13 +10,13 @@ # POST /subusers # data = { - "email": "John@example.com", - "ips": [ - "1.1.1.1", - "2.2.2.2" - ], - "password": "johns_password", - "username": "John@example.com" + "email": "John@example.com", + "ips": [ + "1.1.1.1", + "2.2.2.2" + ], + "password": "johns_password", + "username": "John@example.com" } response = sg.client.subusers.post(request_body=data) print(response.status_code) @@ -47,7 +47,12 @@ # Retrieve email statistics for your subusers. # # GET /subusers/stats # -params = {'end_date': '2016-04-01', 'aggregated_by': 'day', 'limit': 1, 'offset': 1, 'start_date': '2016-01-01', 'subusers': 'test_string'} +params = {'end_date': '2016-04-01', + 'aggregated_by': 'day', + 'limit': 1, + 'offset': 1, + 'start_date': '2016-01-01', + 'subusers': 'test_string'} response = sg.client.subusers.stats.get(query_params=params) print(response.status_code) print(response.body) @@ -57,7 +62,12 @@ # Retrieve monthly stats for all subusers # # GET /subusers/stats/monthly # -params = {'subuser': 'test_string', 'limit': 1, 'sort_by_metric': 'test_string', 'offset': 1, 'date': 'test_string', 'sort_by_direction': 'asc'} +params = {'subuser': 'test_string', + 'limit': 1, + 'sort_by_metric': 'test_string', + 'offset': 1, + 'date': 'test_string', + 'sort_by_direction': 'asc'} response = sg.client.subusers.stats.monthly.get(query_params=params) print(response.status_code) print(response.body) @@ -67,7 +77,13 @@ # Retrieve the totals for each email statistic metric for all subusers. # # GET /subusers/stats/sums # -params = {'end_date': '2016-04-01', 'aggregated_by': 'day', 'limit': 1, 'sort_by_metric': 'test_string', 'offset': 1, 'start_date': '2016-01-01', 'sort_by_direction': 'asc'} +params = {'end_date': '2016-04-01', + 'aggregated_by': 'day', + 'limit': 1, + 'sort_by_metric': 'test_string', + 'offset': 1, + 'start_date': '2016-01-01', + 'sort_by_direction': 'asc'} response = sg.client.subusers.stats.sums.get(query_params=params) print(response.status_code) print(response.body) @@ -78,7 +94,7 @@ # PATCH /subusers/{subuser_name} # data = { - "disabled": False + "disabled": False } subuser_name = "test_url_param" response = sg.client.subusers._(subuser_name).patch(request_body=data) @@ -101,7 +117,7 @@ # PUT /subusers/{subuser_name}/ips # data = [ - "127.0.0.1" + "127.0.0.1" ] subuser_name = "test_url_param" response = sg.client.subusers._(subuser_name).ips.put(request_body=data) @@ -114,8 +130,8 @@ # PUT /subusers/{subuser_name}/monitor # data = { - "email": "example@example.com", - "frequency": 500 + "email": "example@example.com", + "frequency": 500 } subuser_name = "test_url_param" response = sg.client.subusers._(subuser_name).monitor.put(request_body=data) @@ -128,8 +144,8 @@ # POST /subusers/{subuser_name}/monitor # data = { - "email": "example@example.com", - "frequency": 50000 + "email": "example@example.com", + "frequency": 50000 } subuser_name = "test_url_param" response = sg.client.subusers._(subuser_name).monitor.post(request_body=data) @@ -161,10 +177,14 @@ # Retrieve the monthly email statistics for a single subuser # # GET /subusers/{subuser_name}/stats/monthly # -params = {'date': 'test_string', 'sort_by_direction': 'asc', 'limit': 1, 'sort_by_metric': 'test_string', 'offset': 1} +params = {'date': 'test_string', + 'sort_by_direction': 'asc', + 'limit': 1, + 'sort_by_metric': 'test_string', + 'offset': 1} subuser_name = "test_url_param" -response = sg.client.subusers._(subuser_name).stats.monthly.get(query_params=params) +response = sg.client.subusers._( + subuser_name).stats.monthly.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/suppression/suppression.py b/examples/suppression/suppression.py index abdaef76d..391dbe299 100644 --- a/examples/suppression/suppression.py +++ b/examples/suppression/suppression.py @@ -20,11 +20,11 @@ # DELETE /suppression/blocks # data = { - "delete_all": False, - "emails": [ - "example1@example.com", - "example2@example.com" - ] + "delete_all": False, + "emails": [ + "example1@example.com", + "example2@example.com" + ] } response = sg.client.suppression.blocks.delete(request_body=data) print(response.status_code) @@ -66,11 +66,11 @@ # DELETE /suppression/bounces # data = { - "delete_all": True, - "emails": [ - "example@example.com", - "example2@example.com" - ] + "delete_all": True, + "emails": [ + "example@example.com", + "example2@example.com" + ] } response = sg.client.suppression.bounces.delete(request_body=data) print(response.status_code) @@ -113,11 +113,11 @@ # DELETE /suppression/invalid_emails # data = { - "delete_all": False, - "emails": [ - "example1@example.com", - "example2@example.com" - ] + "delete_all": False, + "emails": [ + "example1@example.com", + "example2@example.com" + ] } response = sg.client.suppression.invalid_emails.delete(request_body=data) print(response.status_code) @@ -179,11 +179,11 @@ # DELETE /suppression/spam_reports # data = { - "delete_all": False, - "emails": [ - "example1@example.com", - "example2@example.com" - ] + "delete_all": False, + "emails": [ + "example1@example.com", + "example2@example.com" + ] } response = sg.client.suppression.spam_reports.delete(request_body=data) print(response.status_code) @@ -199,4 +199,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/templates/templates.py b/examples/templates/templates.py index 9d3d5dd4b..a370006b2 100644 --- a/examples/templates/templates.py +++ b/examples/templates/templates.py @@ -10,7 +10,7 @@ # POST /templates # data = { - "name": "example_name" + "name": "example_name" } response = sg.client.templates.post(request_body=data) print(response.status_code) @@ -31,7 +31,7 @@ # PATCH /templates/{template_id} # data = { - "name": "new_example_name" + "name": "new_example_name" } template_id = "test_url_param" response = sg.client.templates._(template_id).patch(request_body=data) @@ -64,12 +64,12 @@ # POST /templates/{template_id}/versions # data = { - "active": 1, - "html_content": "<%body%>", - "name": "example_version_name", - "plain_content": "<%body%>", - "subject": "<%subject%>", - "template_id": "ddb96bbc-9b92-425e-8979-99464621b543" + "active": 1, + "html_content": "<%body%>", + "name": "example_version_name", + "plain_content": "<%body%>", + "subject": "<%subject%>", + "template_id": "ddb96bbc-9b92-425e-8979-99464621b543" } template_id = "test_url_param" response = sg.client.templates._(template_id).versions.post(request_body=data) @@ -82,15 +82,16 @@ # PATCH /templates/{template_id}/versions/{version_id} # data = { - "active": 1, - "html_content": "<%body%>", - "name": "updated_example_name", - "plain_content": "<%body%>", - "subject": "<%subject%>" + "active": 1, + "html_content": "<%body%>", + "name": "updated_example_name", + "plain_content": "<%body%>", + "subject": "<%subject%>" } template_id = "test_url_param" version_id = "test_url_param" -response = sg.client.templates._(template_id).versions._(version_id).patch(request_body=data) +response = sg.client.templates._(template_id).versions._( + version_id).patch(request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -123,8 +124,8 @@ template_id = "test_url_param" version_id = "test_url_param" -response = sg.client.templates._(template_id).versions._(version_id).activate.post() +response = sg.client.templates._( + template_id).versions._(version_id).activate.post() print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/trackingsettings/trackingsettings.py b/examples/trackingsettings/trackingsettings.py index 80dbe243a..0c45e10d9 100644 --- a/examples/trackingsettings/trackingsettings.py +++ b/examples/trackingsettings/trackingsettings.py @@ -20,7 +20,7 @@ # PATCH /tracking_settings/click # data = { - "enabled": True + "enabled": True } response = sg.client.tracking_settings.click.patch(request_body=data) print(response.status_code) @@ -41,14 +41,15 @@ # PATCH /tracking_settings/google_analytics # data = { - "enabled": True, - "utm_campaign": "website", - "utm_content": "", - "utm_medium": "email", - "utm_source": "sendgrid.com", - "utm_term": "" + "enabled": True, + "utm_campaign": "website", + "utm_content": "", + "utm_medium": "email", + "utm_source": "sendgrid.com", + "utm_term": "" } -response = sg.client.tracking_settings.google_analytics.patch(request_body=data) +response = sg.client.tracking_settings.google_analytics.patch( + request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -67,7 +68,7 @@ # PATCH /tracking_settings/open # data = { - "enabled": True + "enabled": True } response = sg.client.tracking_settings.open.patch(request_body=data) print(response.status_code) @@ -88,12 +89,12 @@ # PATCH /tracking_settings/subscription # data = { - "enabled": True, - "html_content": "html content", - "landing": "landing page html", - "plain_content": "text content", - "replace": "replacement tag", - "url": "url" + "enabled": True, + "html_content": "html content", + "landing": "landing page html", + "plain_content": "text content", + "replace": "replacement tag", + "url": "url" } response = sg.client.tracking_settings.subscription.patch(request_body=data) print(response.status_code) @@ -108,4 +109,3 @@ print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/user/user.py b/examples/user/user.py index e71a8d11e..c7aabd4ac 100644 --- a/examples/user/user.py +++ b/examples/user/user.py @@ -28,7 +28,7 @@ # PUT /user/email # data = { - "email": "example@example.com" + "email": "example@example.com" } response = sg.client.user.email.put(request_body=data) print(response.status_code) @@ -49,8 +49,8 @@ # PUT /user/password # data = { - "new_password": "new_password", - "old_password": "old_password" + "new_password": "new_password", + "old_password": "old_password" } response = sg.client.user.password.put(request_body=data) print(response.status_code) @@ -62,9 +62,9 @@ # PATCH /user/profile # data = { - "city": "Orange", - "first_name": "Example", - "last_name": "User" + "city": "Orange", + "first_name": "Example", + "last_name": "User" } response = sg.client.user.profile.patch(request_body=data) print(response.status_code) @@ -85,8 +85,8 @@ # POST /user/scheduled_sends # data = { - "batch_id": "YOUR_BATCH_ID", - "status": "pause" + "batch_id": "YOUR_BATCH_ID", + "status": "pause" } response = sg.client.user.scheduled_sends.post(request_body=data) print(response.status_code) @@ -107,7 +107,7 @@ # PATCH /user/scheduled_sends/{batch_id} # data = { - "status": "pause" + "status": "pause" } batch_id = "test_url_param" response = sg.client.user.scheduled_sends._(batch_id).patch(request_body=data) @@ -140,8 +140,8 @@ # PATCH /user/settings/enforced_tls # data = { - "require_tls": True, - "require_valid_cert": False + "require_tls": True, + "require_valid_cert": False } response = sg.client.user.settings.enforced_tls.patch(request_body=data) print(response.status_code) @@ -162,7 +162,7 @@ # PUT /user/username # data = { - "username": "test_username" + "username": "test_username" } response = sg.client.user.username.put(request_body=data) print(response.status_code) @@ -183,19 +183,19 @@ # PATCH /user/webhooks/event/settings # data = { - "bounce": True, - "click": True, - "deferred": True, - "delivered": True, - "dropped": True, - "enabled": True, - "group_resubscribe": True, - "group_unsubscribe": True, - "open": True, - "processed": True, - "spam_report": True, - "unsubscribe": True, - "url": "url" + "bounce": True, + "click": True, + "deferred": True, + "delivered": True, + "dropped": True, + "enabled": True, + "group_resubscribe": True, + "group_unsubscribe": True, + "open": True, + "processed": True, + "spam_report": True, + "unsubscribe": True, + "url": "url" } response = sg.client.user.webhooks.event.settings.patch(request_body=data) print(response.status_code) @@ -216,7 +216,7 @@ # POST /user/webhooks/event/test # data = { - "url": "url" + "url": "url" } response = sg.client.user.webhooks.event.test.post(request_body=data) print(response.status_code) @@ -228,10 +228,10 @@ # POST /user/webhooks/parse/settings # data = { - "hostname": "myhostname.com", - "send_raw": False, - "spam_check": True, - "url": "http://email.myhosthame.com" + "hostname": "myhostname.com", + "send_raw": False, + "spam_check": True, + "url": "http://email.myhosthame.com" } response = sg.client.user.webhooks.parse.settings.post(request_body=data) print(response.status_code) @@ -252,12 +252,13 @@ # PATCH /user/webhooks/parse/settings/{hostname} # data = { - "send_raw": True, - "spam_check": False, - "url": "http://newdomain.com/parse" + "send_raw": True, + "spam_check": False, + "url": "http://newdomain.com/parse" } hostname = "test_url_param" -response = sg.client.user.webhooks.parse.settings._(hostname).patch(request_body=data) +response = sg.client.user.webhooks.parse.settings._( + hostname).patch(request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -286,9 +287,12 @@ # Retrieves Inbound Parse Webhook statistics. # # GET /user/webhooks/parse/stats # -params = {'aggregated_by': 'day', 'limit': 'test_string', 'start_date': '2016-01-01', 'end_date': '2016-04-01', 'offset': 'test_string'} +params = {'aggregated_by': 'day', + 'limit': 'test_string', + 'start_date': '2016-01-01', + 'end_date': '2016-04-01', + 'offset': 'test_string'} response = sg.client.user.webhooks.parse.stats.get(query_params=params) print(response.status_code) print(response.body) print(response.headers) - diff --git a/examples/whitelabel/whitelabel.py b/examples/whitelabel/whitelabel.py index f529d3ed2..d528e8767 100644 --- a/examples/whitelabel/whitelabel.py +++ b/examples/whitelabel/whitelabel.py @@ -10,16 +10,16 @@ # POST /whitelabel/domains # data = { - "automatic_security": False, - "custom_spf": True, - "default": True, - "domain": "example.com", - "ips": [ - "192.168.1.1", - "192.168.1.2" - ], - "subdomain": "news", - "username": "john@example.com" + "automatic_security": False, + "custom_spf": True, + "default": True, + "domain": "example.com", + "ips": [ + "192.168.1.1", + "192.168.1.2" + ], + "subdomain": "news", + "username": "john@example.com" } response = sg.client.whitelabel.domains.post(request_body=data) print(response.status_code) @@ -30,7 +30,8 @@ # List all domain whitelabels. # # GET /whitelabel/domains # -params = {'username': 'test_string', 'domain': 'test_string', 'exclude_subusers': 'true', 'limit': 1, 'offset': 1} +params = {'username': 'test_string', 'domain': 'test_string', + 'exclude_subusers': 'true', 'limit': 1, 'offset': 1} response = sg.client.whitelabel.domains.get(query_params=params) print(response.status_code) print(response.body) @@ -68,8 +69,8 @@ # PATCH /whitelabel/domains/{domain_id} # data = { - "custom_spf": True, - "default": False + "custom_spf": True, + "default": False } domain_id = "test_url_param" response = sg.client.whitelabel.domains._(domain_id).patch(request_body=data) @@ -102,10 +103,11 @@ # POST /whitelabel/domains/{domain_id}/subuser # data = { - "username": "jane@example.com" + "username": "jane@example.com" } domain_id = "test_url_param" -response = sg.client.whitelabel.domains._(domain_id).subuser.post(request_body=data) +response = sg.client.whitelabel.domains._( + domain_id).subuser.post(request_body=data) print(response.status_code) print(response.body) print(response.headers) @@ -115,7 +117,7 @@ # POST /whitelabel/domains/{id}/ips # data = { - "ip": "192.168.0.1" + "ip": "192.168.0.1" } id = "test_url_param" response = sg.client.whitelabel.domains._(id).ips.post(request_body=data) @@ -149,9 +151,9 @@ # POST /whitelabel/ips # data = { - "domain": "example.com", - "ip": "192.168.1.1", - "subdomain": "email" + "domain": "example.com", + "ip": "192.168.1.1", + "subdomain": "email" } response = sg.client.whitelabel.ips.post(request_body=data) print(response.status_code) @@ -203,12 +205,13 @@ # POST /whitelabel/links # data = { - "default": True, - "domain": "example.com", - "subdomain": "mail" + "default": True, + "domain": "example.com", + "subdomain": "mail" } params = {'limit': 1, 'offset': 1} -response = sg.client.whitelabel.links.post(request_body=data, query_params=params) +response = sg.client.whitelabel.links.post( + request_body=data, query_params=params) print(response.status_code) print(response.body) print(response.headers) @@ -258,7 +261,7 @@ # PATCH /whitelabel/links/{id} # data = { - "default": True + "default": True } id = "test_url_param" response = sg.client.whitelabel.links._(id).patch(request_body=data) @@ -301,11 +304,11 @@ # POST /whitelabel/links/{link_id}/subuser # data = { - "username": "jane@example.com" + "username": "jane@example.com" } link_id = "test_url_param" -response = sg.client.whitelabel.links._(link_id).subuser.post(request_body=data) +response = sg.client.whitelabel.links._( + link_id).subuser.post(request_body=data) print(response.status_code) print(response.body) print(response.headers) - diff --git a/sendgrid/helpers/inbound/config.py b/sendgrid/helpers/inbound/config.py index 32c389e38..d0c6517bc 100644 --- a/sendgrid/helpers/inbound/config.py +++ b/sendgrid/helpers/inbound/config.py @@ -5,6 +5,7 @@ class Config(object): """All configuration for this app is loaded here""" + def __init__(self, **opts): if os.environ.get('ENV') != 'prod': # We are not in Heroku self.init_environment() @@ -35,8 +36,6 @@ def init_environment(): if len(var) == 2: os.environ[var[0]] = var[1] - - @property def debug_mode(self): """Flask debug mode - set to False in production.""" diff --git a/sendgrid/helpers/inbound/parse.py b/sendgrid/helpers/inbound/parse.py index 77b6683ad..49627a121 100644 --- a/sendgrid/helpers/inbound/parse.py +++ b/sendgrid/helpers/inbound/parse.py @@ -7,6 +7,7 @@ class Parse(object): + def __init__(self, config, request): self._keys = config.keys self._request = request diff --git a/sendgrid/helpers/inbound/send.py b/sendgrid/helpers/inbound/send.py index fe67aca46..6de575aab 100644 --- a/sendgrid/helpers/inbound/send.py +++ b/sendgrid/helpers/inbound/send.py @@ -12,6 +12,7 @@ class Send(object): + def __init__(self, url): """Create a Send object with target `url`.""" self._url = url diff --git a/sendgrid/helpers/mail/mail.py b/sendgrid/helpers/mail/mail.py index 7d131f4b7..d5e82db75 100644 --- a/sendgrid/helpers/mail/mail.py +++ b/sendgrid/helpers/mail/mail.py @@ -381,8 +381,6 @@ def custom_args(self): return self._custom_args def add_custom_arg(self, custom_arg): - """Add a CustomArg to this Mail. - - :type custom_arg: CustomArg - """ + if self._custom_args is None: + self._custom_args = [] self._custom_args.append(custom_arg) diff --git a/test/test_email.py b/test/test_email.py index 92ae10aaa..902c59d4e 100644 --- a/test/test_email.py +++ b/test/test_email.py @@ -10,18 +10,19 @@ class TestEmailObject(unittest.TestCase): + def test_add_email_address(self): address = "test@example.com" email = Email(address) self.assertEqual(email.email, "test@example.com") - + def test_add_name(self): name = "SomeName" email = Email(name=name) self.assertEqual(email.name, name) - + def test_add_name_email(self): name = "SomeName" address = "test@example.com" @@ -43,7 +44,7 @@ def test_add_rfc_email(self): email = Email(name_address) self.assertEqual(email.name, name) self.assertEqual(email.email, "test@example.com") - + def test_empty_obj_add_name(self): email = Email() name = "SomeName" @@ -56,4 +57,4 @@ def test_empty_obj_add_email(self): address = "test@example.com" email.email = address - self.assertEqual(email.email, address) \ No newline at end of file + self.assertEqual(email.email, address) diff --git a/test/test_mail.py b/test/test_mail.py index 0941fa78a..1b474a5cb 100644 --- a/test/test_mail.py +++ b/test/test_mail.py @@ -444,7 +444,6 @@ def test_kitchenSink(self): ) def test_unicode_values_in_substitutions_helper(self): - """ Test that the Substitutions helper accepts unicode values """ self.maxDiff = None diff --git a/test/test_sendgrid.py b/test/test_sendgrid.py index 3b3e8e743..09b094a8d 100644 --- a/test/test_sendgrid.py +++ b/test/test_sendgrid.py @@ -27,6 +27,7 @@ def setUpClass(cls): api_key=os.environ.get('SENDGRID_API_KEY')) cls.devnull = open(os.devnull, 'w') prism_cmd = None + # try: # # check for prism in the PATH # if subprocess.call('prism version'.split(), stdout=cls.devnull) == 0: @@ -136,16 +137,18 @@ def test_reset_request_headers(self): self.assertNotIn('blah', self.sg.client.request_headers) self.assertNotIn('blah2x', self.sg.client.request_headers) - for k,v in self.sg._get_default_headers().items(): + for k, v in self.sg._get_default_headers().items(): self.assertEqual(v, self.sg.client.request_headers[k]) def test_hello_world(self): from_email = Email("test@example.com") to_email = Email("test@example.com") subject = "Sending with SendGrid is Fun" - content = Content("text/plain", "and easy to do anywhere, even with Python") + content = Content( + "text/plain", "and easy to do anywhere, even with Python") mail = Mail(from_email, subject, to_email, content) - self.assertTrue(mail.get() == {'content': [{'type': 'text/plain', 'value': 'and easy to do anywhere, even with Python'}], 'personalizations': [{'to': [{'email': 'test@example.com'}]}], 'from': {'email': 'test@example.com'}, 'subject': 'Sending with SendGrid is Fun'}) + self.assertTrue(mail.get() == {'content': [{'type': 'text/plain', 'value': 'and easy to do anywhere, even with Python'}], 'personalizations': [ + {'to': [{'email': 'test@example.com'}]}], 'from': {'email': 'test@example.com'}, 'subject': 'Sending with SendGrid is Fun'}) def test_access_settings_activity_get(self): params = {'limit': 1}