Skip to content

Commit

Permalink
Merge pull request #24 from flaker/master
Browse files Browse the repository at this point in the history
API-3187 - Merge develop into customer
  • Loading branch information
emilyzzz authored Jul 27, 2016
2 parents 9f3ebae + 50a9728 commit 8a098a5
Show file tree
Hide file tree
Showing 7 changed files with 519 additions and 233 deletions.
12 changes: 12 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
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
* Refined docstrings throughout code

0.3.1 / 2013-06-04
==================
* Removed: Realm Support
Expand Down
48 changes: 28 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +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 @@ -102,4 +111,3 @@ ox = ox3apiclient.Client(

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

0 comments on commit 8a098a5

Please sign in to comment.