Skip to content

Commit 8e60d24

Browse files
committed
Updated docstrings and README.md
1 parent a0be806 commit 8e60d24

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ httplib2. Instead it uses urllib2 as the HTTP transport.
66

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

9+
As of version 0.4.0, ox3apiclient supports API v2. If your instance is v2,
10+
set the api_path option to "/ox/4.0".
11+
912
Basic usage:
1013

1114
````python
@@ -101,5 +104,4 @@ ox = ox3apiclient.Client(
101104
consumer_secret=consumer_secret)
102105

103106
ox.logon(email, password)
104-
````
105-
Test
107+
````

ox3apiclient/__init__.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ class UnknownAPIFormatError(ValueError):
4949
pass
5050

5151
class Client(object):
52+
"""Client for making requests to the OX3 API. Maintains
53+
authentication and points all requests at a domain+path
54+
combination. Handles request and response data in the form
55+
of Python dictionaries, translated to and from the JSON and
56+
query string encoding the API itself uses.
57+
58+
"""
5259

5360
def __init__(self, domain, realm, consumer_key, consumer_secret,
5461
callback_url='oob',
@@ -321,7 +328,10 @@ def logoff(self):
321328
return self
322329

323330
def _resolve_url(self, url):
324-
""""""
331+
"""Converts an API path shorthand into a full URL unless
332+
given a full url already.
333+
334+
"""
325335
parse_res = urlparse.urlparse(url)
326336

327337
# 2.4 returns a tuple instead of ParseResult. Since ParseResult is a
@@ -338,12 +348,15 @@ def _resolve_url(self, url):
338348
return url
339349

340350
def get(self, url):
341-
""""""
351+
"""Issue a GET request to the given URL or API shorthand
352+
353+
"""
342354
res = self.request(self._resolve_url(url), method='GET')
343355
return json.loads(res.read())
344356

345357
def options(self, url):
346-
"""Send a request with HTTP method OPTIONS.
358+
"""Send a request with HTTP method OPTIONS to the given
359+
URL or API shorthand.
347360
348361
OX3 v2 uses this method for showing help information.
349362
@@ -352,27 +365,36 @@ def options(self, url):
352365
return json.loads(res.read())
353366

354367
def put(self, url, data=None):
355-
"""Issue a PUT request to url with the data."""
368+
"""Issue a PUT request to url (either a full URL or API
369+
shorthand) with the data.
370+
371+
"""
356372
res = self.request(self._resolve_url(url), method='PUT', data=data,
357373
send_json=(self.api_path in JSON_PATHS))
358374
return json.loads(res.read())
359375

360376
def post(self, url, data=None):
361-
""""""
377+
"""Issue a POST request to url (either a full URL or API
378+
shorthand) with the data.
379+
380+
"""
362381
res = self.request(self._resolve_url(url), method='POST', data=data,
363382
send_json=(self.api_path in JSON_PATHS))
364383
return json.loads(res.read())
365384

366385
def delete(self, url):
367-
""""""
386+
"""Issue a DELETE request to the URL or API shorthand."""
368387
res = self.request(self._resolve_url(url), method='DELETE')
369388
# Catch no content responses from some delete actions.
370389
if res.code == 204:
371390
return json.loads('[]')
372391
return json.loads(res.read())
373392

374393
def upload_creative(self, account_id, file_path):
375-
""""""
394+
"""Upload a media creative to the account with ID
395+
account_id from the local file_path.
396+
397+
"""
376398
# Thanks to nosklo for his answer on SO:
377399
# http://stackoverflow.com/a/681182
378400
boundary = '-----------------------------' + str(int(random.random()*1e10))

0 commit comments

Comments
 (0)