Skip to content

Commit

Permalink
error handling of bad post requests
Browse files Browse the repository at this point in the history
  • Loading branch information
philipithomas committed Feb 23, 2016
1 parent 9155650 commit 6a85132
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

setup(name="staffjoy",
packages=find_packages(),
version="0.7",
version="0.8",
description="Staffjoy API Wrapper in Python",
author="Philip Thomas",
author_email="[email protected]",
license="MIT",
url="https://github.com/staffjoy/client_python",
download_url="https://github.com/StaffJoy/client_python/archive/0.7.tar.gz",
download_url="https://github.com/StaffJoy/client_python/archive/0.8.tar.gz",
keywords=["staffjoy-api", "staffjoy", "staff joy"],
install_requires=["requests[security]"], )
3 changes: 3 additions & 0 deletions staffjoy/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ def create(cls, parent=None, **kwargs):

response = requests.post(obj._url(), auth=(obj.key, ""), data=kwargs)

if response.status_code not in cls.TRUTHY_CODES:
return base_obj._handle_request_exception(response)

# No envelope on post requests
data = response.json()
obj.route[obj.ID_NAME] = data.get("id")
Expand Down

0 comments on commit 6a85132

Please sign in to comment.