Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getGroup(self, id=0):
""" Gets the detail of particular group a user is part of.
Args:
id(long, optional): ID of the group. Default value is 0, and means non-group expenses
Returns:
:obj:`splitwise.group.Group`: Object representing a group
"""
try:
content = self.__makeRequest(Splitwise.GET_GROUP_URL+"/"+str(id))
except SplitwiseNotAllowedException as e:
e.setMessage("You are not allowed to fetch group with id %d" % id)
raise
except SplitwiseNotFoundException as e:
e.setMessage("Group with id %d does not exist" % id)
raise
content = json.loads(content)
group = None
if "group" in content:
group = Group(content["group"])
return group
if response.status_code == 200:
if (response.content and hasattr(response.content, "decode")):
return response.content.decode("utf-8")
return response.content
if response.status_code == 401:
raise SplitwiseUnauthorizedException("Please check your token or consumer id and secret", response=response)
if response.status_code == 403:
raise SplitwiseNotAllowedException("You are not allowed to perform this operation", response=response)
if response.status_code == 400:
raise SplitwiseBadRequestException("Please check your request", response=response)
if response.status_code == 404:
raise SplitwiseNotFoundException("Required resource is not found", response)
raise SplitwiseException("Unknown error happened", response)