Skip to content

Commit 4fc883d

Browse files
TimWhalenFederico Delgado
authored andcommitted
- APPS-5071 - replaced oauth2/urllib2 with requests_oauthlib
- APPS-5071 - fixed some typos in the readme - remove realm from config as it is not used anymore - add arg realm for initializing CLient - add client test with mocking - add few more unit-test for method in ox3apiclient
1 parent 71f30d8 commit 4fc883d

6 files changed

Lines changed: 413 additions & 184 deletions

File tree

History.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.5.0 / 2013-06-09
2+
==================
3+
* Replaced: urllib2 with requests package
4+
* Replaced: oauth2 with requests_oauthlib package
5+
* Added: optional timeout parameter
6+
17
0.4.0 / 2013-07-23
28
==================
39
* Added handling for API v2

README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,58 @@
11
# ox3apiclient
22

3-
A small class to help connect to the OpenX Enterprise API. While it uses [oauth2](https://github.com/simplegeo/python-oauth2),
4-
it does not use [httplib2](http://code.google.com/p/httplib2/) as the transport due to issues with headers created by
5-
httplib2. Instead it uses urllib2 as the HTTP transport.
3+
A small class to help connect to the OpenX Enterprise API. As of version 0.5.0 it uses
4+
[requests_oauthlib](https://github.com/requests/requests-oauthlib) instead of oauth2.
65

7-
It currently supports Python 2.4 - 2.7, with 3.x support comming in the future.
6+
It currently supports Python 2.4 - 2.7, with 3.x support coming in the future.
87

98
As of version 0.4.0, ox3apiclient supports API v2. If your instance is v2,
109
set the api_path option to "/ox/4.0".
1110

12-
Basic usage:
11+
As of version 0.5.0 the client.request method returns a requests.Response object instead of
12+
urllib2.Response and throws a requests.exceptions.HTTPError instead of urllib2.HTTPError.
13+
In addition debugging is now available via the standard python logging facility.
14+
15+
See the [requests documentation](http://docs.python-requests.org/en/latest/) for details.
16+
17+
Basic usage with debugging enabled:
1318

1419
````python
1520
import ox3apiclient
21+
import logging
1622

1723
ox = ox3apiclient.client_from_file().logon()
1824

19-
account_ids = ox.get('/a/account')
25+
ox.logger.setLevel(logging.DEBUG)
26+
ch = logging.StreamHandler()
27+
ch.setLevel(logging.DEBUG)
28+
ox.logger.addHandler(ch)
29+
30+
accounts = ox.get('/account')
2031

2132
order = {
2233
'status': 'Active',
2334
'name': 'OX3APIClient Object Creation Test',
24-
'account_id': account_ids[0],
25-
'start_date': '2012-08-22 00:00:00'}
35+
'account_uid': accounts['objects'][0]['account_uid'],
36+
'start_date': '2015-06-01 00:00:00'}
2637

27-
new_order = ox.post('/a/order', data=order)
38+
new_order = ox.post('/order', data=order)
2839

29-
ox.delete('/a/order/%s' % new_order['id'])
40+
ox.delete('/order/%s' % new_order['uid'])
3041

3142
ox.logoff()
3243
````
3344

3445

3546
## Installation
3647

37-
Install from [PyPi](http://pypi.python.org/pypi) with [pip](http://www.pip-installer.org/en/latest/index.html)
48+
ox3apiclient is currently unavailable at [PyPi](http://pypi.python.org/pypi) so just clone our git repo:
3849

3950
````
40-
$ pip install ox3apiclient
51+
$ git clone https://github.com/openx/OX3-Python-API-Client.git
4152
````
42-
This should install the [oauth2](https://github.com/simplegeo/python-oauth2) dependency, but you can manually install if needed.
53+
Install requests and requests_oauthlib from [PyPi](http://pypi.python.org/pypi) with [pip](http://www.pip-installer.org/en/latest/index.html)
4354
````
44-
$ pip install oauth2
55+
$ pip install requests requests_oauthlib
4556
````
4657

4758
Note that Python 2.4 and 2.5 support requires simplejson. You will need
@@ -104,4 +115,4 @@ ox = ox3apiclient.Client(
104115
consumer_secret=consumer_secret)
105116

106117
ox.logon(email, password)
107-
````
118+
````

0 commit comments

Comments
 (0)