Skip to content

Commit

Permalink
Add a method for getting and parsing the public URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
tgs committed Jun 9, 2014
1 parent e5414aa commit 915a39b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions badgekit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,16 @@ def require_server_version(self, required_version):
+ "of BadgeKit-API server required, but "
+ "{server_url} is only version {version}.")
.format(**locals()))

def get_public_url(self, url):
"""
GET a URL, and parse its JSON, checking for known errors. Useful for
public URLs on the BadgeKit API server (e.g. assertions).
"""
resp = requests.get(url)
resp_obj = self._json_loads(resp.text)

if resp.status_code != 200:
raise_error(resp_obj, resp.request)

return resp_obj

0 comments on commit 915a39b

Please sign in to comment.