|
1 | 1 | # ox3apiclient
|
2 | 2 |
|
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. |
6 | 5 |
|
7 |
| -It currently supports Python 2.4 - 2.7, with 3.x support comming in the future. |
| 6 | +It currently supports Python 2.6 - 2.7, with 3.x support coming in the future. |
8 | 7 |
|
9 | 8 | As of version 0.4.0, ox3apiclient supports API v2. If your instance is v2,
|
10 | 9 | set the api_path option to "/ox/4.0".
|
11 | 10 |
|
| 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 | + |
12 | 17 | Basic usage:
|
13 | 18 |
|
14 | 19 | ````python
|
15 | 20 | import ox3apiclient
|
| 21 | +import logging |
16 | 22 |
|
17 | 23 | ox = ox3apiclient.client_from_file().logon()
|
18 | 24 |
|
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') |
20 | 31 |
|
21 | 32 | order = {
|
22 | 33 | 'status': 'Active',
|
23 | 34 | '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': '2016-06-01 00:00:00'} |
26 | 37 |
|
27 |
| -new_order = ox.post('/a/order', data=order) |
| 38 | +new_order = ox.post('/order', data=order) |
28 | 39 |
|
29 |
| -ox.delete('/a/order/%s' % new_order['id']) |
| 40 | +ox.delete('/order/%s' % new_order['uid']) |
30 | 41 |
|
31 | 42 | ox.logoff()
|
32 | 43 | ````
|
33 | 44 |
|
34 | 45 |
|
35 | 46 | ## Installation
|
36 | 47 |
|
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: |
38 | 49 |
|
39 | 50 | ````
|
40 |
| -$ pip install ox3apiclient |
41 |
| -```` |
42 |
| -This should install the [oauth2](https://github.com/simplegeo/python-oauth2) dependency, but you can manually install if needed. |
43 |
| -```` |
44 |
| -$ pip install oauth2 |
| 51 | +$ git clone https://github.com/openx/OX3-Python-API-Client.git |
45 | 52 | ````
|
46 | 53 |
|
47 |
| -Note that Python 2.4 and 2.5 support requires simplejson. You will need |
48 |
| -simplejson 2.1.0 specifically for Python 2.4. You can install this version with: |
| 54 | +Install the downloaded library: |
49 | 55 | ````
|
50 |
| -$ pip install simplejson==2.1.0 |
| 56 | +python setup.py install |
51 | 57 | ````
|
52 |
| - |
| 58 | +this will install the current dependencies. |
53 | 59 |
|
54 | 60 | ## Authentication
|
55 | 61 |
|
@@ -104,4 +110,4 @@ ox = ox3apiclient.Client(
|
104 | 110 | consumer_secret=consumer_secret)
|
105 | 111 |
|
106 | 112 | ox.logon(email, password)
|
107 |
| -```` |
| 113 | +```` |
0 commit comments