Skip to content

Commit be18bd8

Browse files
author
Guillaume Badi
committed
send
1 parent 7d3c5e2 commit be18bd8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
First, make sure you have an API key, and an API secret.
66
Once you got them, save them in your environment:
77

8+
### API documentation
9+
10+
Find out more about the Mailjet API: http://dev.mailjet.com/
11+
12+
813
```
914
export MJ_APIKEY_PUBLIC='your api key'
1015
export MJ_APIKEY_PRIVATE='your api secret'
@@ -60,3 +65,13 @@ email = {
6065
mailjet.send.post(email)
6166

6267
```
68+
69+
## Create a new Contact
70+
``` python
71+
72+
# wrapping the call inside a function
73+
def new_contact(email):
74+
return mailjet.contact.new(data={'Email': email})
75+
76+
new_contact('[email protected]')
77+
```

mailjet/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Config(object):
1515

1616
def __getitem__(self, key):
1717
url = self.API_URL[0:]
18-
if key != 'Send':
18+
if key.lower() != 'send':
1919
url = urljoin(url, 'REST/')
2020
elif key == 'Contactslist_csvdata':
2121
url = urljoin(url, 'DATA/')
@@ -46,6 +46,7 @@ def create(self, data, filters=None, action_id=None, **kwargs):
4646
return api_call(self._auth, 'post', self._url, data=data, action=self.action, action_id=action_id, filters=filters, **kwargs)
4747

4848
new = create
49+
post = create
4950

5051
def update(self, id, data, filters=None, action_id=None, **kwargs):
5152
return api_call(self._auth, 'put', self._url, resource_id=id, data=data, action=self.action, action_id=action_id, filters=filters, **kwargs)
@@ -75,7 +76,7 @@ def api_call(auth, method, url, data=None, filters=None, resource_id=None, extra
7576
headers = build_headers(extra_headers)
7677
req_method = getattr(requests, method)
7778

78-
# url = 'http://requestb.in/1emzll91'
79+
# url = 'http://requestb.in/1fuplcz1'
7980

8081
try:
8182
response = req_method(url, data=json.dumps(data), params=filters, headers=headers, auth=auth,

0 commit comments

Comments
 (0)