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