Skip to content

Commit e942cb0

Browse files
Version Bump 2.0.0: Naming conventions
1 parent 2046d9a commit e942cb0

File tree

10 files changed

+33
-94
lines changed

10 files changed

+33
-94
lines changed

.env_sample

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ All notable changes to this project will be documented in this file.
33

44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6-
## [1.2.4] - 2016-3-02
6+
## [2.0.0] - 2016-06-03
7+
### Changed
8+
- Made the Response variables non-redundant. e.g. response.response_body becomes response.body
9+
10+
## [1.2.4] - 2016-03-02
711
### Fixed
812
- Getting README to display in PyPi
913

10-
## [1.2.3] - 2016-3-01
14+
## [1.2.3] - 2016-03-01
1115
### Added
1216
- Can now reuse part of the chaining construction for multiple urls/requests
1317
- Thanks to [Kevin Gillette](https://github.com/extemporalgenome)!

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ global_headers = {"Authorization": "Basic XXXXXXX"}
3030
client = Client(host='base_url', request_headers=global_headers)
3131
client.your.api._(param).call.get()
3232
print response.status_code
33-
print response.response_headers
34-
print response.response_body
33+
print response.headers
34+
print response.body
3535
```
3636

3737
`POST /your/api/{param}/call` with headers, query parameters and a request body with versioning.
@@ -47,8 +47,8 @@ response = client.your.api._(param).call.post(request_body=data,
4747
query_params=query_params,
4848
request_headers=request_headers)
4949
print response.status_code
50-
print response.response_headers
51-
print response.response_body
50+
print response.headers
51+
print response.body
5252
```
5353

5454
# Usage

examples/example.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44
from os import sys, path
55
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
66
from python_http_client.client import Client
7-
from python_http_client.config import Config
87

98

10-
local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__)))
11-
Config(local_path)
129
api_key = os.environ.get('SENDGRID_API_KEY')
1310
headers = {
1411
"Authorization": 'Bearer {0}'.format(api_key),
1512
"Content-Type": "application/json"
1613
}
17-
client = Client(host=os.environ.get('LOCAL_HOST'),
14+
client = Client(host='http://localhost:4010',
1815
request_headers=headers,
1916
version=3)
2017

examples/live_sendgrid_example.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import json
33
import python_http_client
44

5-
path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__)))
6-
python_http_client.Config(path)
7-
host = os.environ.get('HOST') # http://api.sendgrid.com
5+
host = "https://api.sendgrid.com"
86
api_key = os.environ.get('SENDGRID_API_KEY')
97
request_headers = {
108
"Authorization": 'Bearer {0}'.format(api_key),
@@ -17,9 +15,9 @@
1715

1816
# GET collection
1917
response = client.api_keys.get()
20-
print(response.response_headers)
2118
print(response.status_code)
22-
print(response.response_body)
19+
print(response.headers)
20+
print(response.body)
2321

2422
# POST
2523
data = {
@@ -31,26 +29,26 @@
3129
]
3230
}
3331
response = client.api_keys.post(request_body=data)
34-
print(response.response_headers)
3532
print(response.status_code)
36-
print(response.response_body)
37-
json_response = json.loads(response.response_body)
33+
print(response.headers)
34+
print(response.body)
35+
json_response = json.loads(response.body)
3836
api_key_id = json_response['api_key_id']
3937

4038
# GET single
4139
response = client.api_keys._(api_key_id).get()
42-
print(response.response_headers)
4340
print(response.status_code)
44-
print(response.response_body)
41+
print(response.headers)
42+
print(response.body)
4543

4644
# PATCH
4745
data = {
4846
"name": "A New Hope"
4947
}
5048
response = client.api_keys._(api_key_id).patch(request_body=data)
51-
print(response.response_headers)
5249
print(response.status_code)
53-
print(response.response_body)
50+
print(response.headers)
51+
print(response.body)
5452

5553
# PUT
5654
data = {
@@ -61,11 +59,12 @@
6159
]
6260
}
6361
response = client.api_keys._(api_key_id).put(request_body=data)
64-
print(response.response_headers)
6562
print(response.status_code)
66-
print(response.response_body)
63+
print(response.headers)
64+
print(response.body)
6765

6866
# DELETE
6967
response = client.api_keys._(api_key_id).delete()
70-
print(response.response_headers)
7168
print(response.status_code)
69+
print(response.headers)
70+

python_http_client/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from .client import Client
2-
from .config import Config

python_http_client/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def __init__(self, response):
2121
:type response: urllib response object
2222
"""
2323
self._status_code = response.getcode()
24-
self._response_body = response.read()
25-
self._response_headers = response.info()
24+
self._body = response.read()
25+
self._headers = response.info()
2626

2727
@property
2828
def status_code(self):
@@ -32,18 +32,18 @@ def status_code(self):
3232
return self._status_code
3333

3434
@property
35-
def response_body(self):
35+
def body(self):
3636
"""
3737
:return: response from the API
3838
"""
39-
return self._response_body
39+
return self._body
4040

4141
@property
42-
def response_headers(self):
42+
def headers(self):
4343
"""
4444
:return: dict of response headers
4545
"""
46-
return self._response_headers
46+
return self._headers
4747

4848

4949
class Client(object):

python_http_client/config.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def getRequires():
1313
return deps
1414

1515
base_url = 'https://github.com/sendgrid/'
16-
version = '1.2.4'
16+
version = '2.0.0'
1717
setup(
1818
name='python_http_client',
1919
version=version,

tests/test_unit.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import unittest2 as unittest
55
except ImportError:
66
import unittest
7-
from python_http_client.config import Config
87
from python_http_client.client import Client, Response
98

109

@@ -47,30 +46,11 @@ def _make_request(self, opener, request):
4746
return MockResponse(self.response_code)
4847

4948

50-
class TestConfig(unittest.TestCase):
51-
def test_initialization(self):
52-
"""Make sure your configuration is setup correctly.
53-
At a minimum, we need a HOST to be defined in .env
54-
to test the configuration module.
55-
"""
56-
local_path = os.path.dirname(path.dirname(path.abspath(__file__)))
57-
config = Config(local_path)
58-
self.assertEqual(config.local_path_to_env,
59-
'{0}/.env'.format(local_path))
60-
61-
6249
class TestClient(unittest.TestCase):
6350
def setUp(self):
6451
self.host = 'http://api.test.com'
6552
self.client = Client(host=self.host)
66-
if os.environ.get('TRAVIS'):
67-
Config(os.path.abspath(os.path.dirname(__file__)))
68-
else:
69-
local_path = '{0}/..'\
70-
.format(os.path.abspath(os.path.dirname(__file__)))
71-
Config(local_path)
72-
self.api_key = os.environ.get('SENDGRID_API_KEY')
73-
self.host = os.environ.get('MOCK_HOST')
53+
self.api_key = "SENDGRID_API_KEY"
7454
self.request_headers = {
7555
'Content-Type': 'application/json',
7656
'Authorization': 'Bearer ' + self.api_key

0 commit comments

Comments
 (0)