Skip to content

Commit

Permalink
API-3187 merge develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Delgado committed Jul 26, 2016
2 parents b8e816c + e7ec06e commit 50a9728
Show file tree
Hide file tree
Showing 7 changed files with 450 additions and 252 deletions.
7 changes: 7 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.5.0 / 2015-07-26
==================
* Replaced: urllib2 with requests package
* Replaced: oauth2 with requests_oauthlib package
* Added: optional timeout parameter
* Removed: support for Python 2.4/2.5

0.4.0 / 2013-07-23
==================
* Added handling for API v2
Expand Down
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
# ox3apiclient

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

It currently supports Python 2.4 - 2.7, with 3.x support comming in the future.
It currently supports Python 2.6 - 2.7, with 3.x support coming in the future.

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

As of version 0.5.0 the client.request method returns a requests.Response object instead of
urllib2.Response and throws a requests.exceptions.HTTPError instead of urllib2.HTTPError.
In addition debugging is now available via the standard python logging facility.

See the [requests documentation](http://docs.python-requests.org/en/latest/) for details.

Basic usage:

````python
import ox3apiclient
import logging

ox = ox3apiclient.client_from_file().logon()

account_ids = ox.get('/a/account')
ox.logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ox.logger.addHandler(ch)

accounts = ox.get('/account')

order = {
'status': 'Active',
'name': 'OX3APIClient Object Creation Test',
'account_id': account_ids[0],
'start_date': '2012-08-22 00:00:00'}
'account_uid': accounts['objects'][0]['account_uid'],
'start_date': '2016-06-01 00:00:00'}

new_order = ox.post('/a/order', data=order)
new_order = ox.post('/order', data=order)

ox.delete('/a/order/%s' % new_order['id'])
ox.delete('/order/%s' % new_order['uid'])

ox.logoff()
````


## Installation

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

````
$ pip install ox3apiclient
````
This should install the [oauth2](https://github.com/simplegeo/python-oauth2) dependency, but you can manually install if needed.
````
$ pip install oauth2
$ git clone https://github.com/openx/OX3-Python-API-Client.git
````

Note that Python 2.4 and 2.5 support requires simplejson. You will need
simplejson 2.1.0 specifically for Python 2.4. You can install this version with:
Install the downloaded library:
````
$ pip install simplejson==2.1.0
python setup.py install
````

this will install the current dependencies.

## Authentication

Expand Down Expand Up @@ -104,4 +110,4 @@ ox = ox3apiclient.Client(
consumer_secret=consumer_secret)

ox.logon(email, password)
````
````
Loading

0 comments on commit 50a9728

Please sign in to comment.