Content-Length: 216321 | pFad | http://github.com/WEEE-Open/pytarallo/commit/9b0439e67fc296761b411b76d26951b9559dfa13

19 Add "lose" API · WEEE-Open/pytarallo@9b0439e · GitHub
Skip to content

Commit

Permalink
Add "lose" API
Browse files Browse the repository at this point in the history
  • Loading branch information
lvps committed Mar 9, 2022
1 parent ce21aa4 commit 9b0439e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pytarallo/Tarallo.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,28 @@ def move(self, code: str, location: str):
else:
raise RuntimeError(f"Move failed with {move_status}")

def lose(self, code: str):
"""
Move an item to another location
"""
lose_status = self.delete(f'v2/items/{self.urlencode(code)}/parent').status_code
if lose_status == 204:
return True
elif lose_status == 400:
response_json = json.loads(self.response.content)
if "message" in response_json:
raise ValidationError(f"Cannot lose {code}: {response_json['message']}")
else:
raise ValidationError(f"Cannot lose {code}")
elif lose_status == 404:
response_json = json.loads(self.response.content)
if 'item' in response_json:
raise ItemNotFoundError(f"Item {response_json['item']} doesn't exist")
else:
raise ServerError("Server didn't find an item, but isn't telling us which one")
else:
raise RuntimeError(f"Move failed with {lose_status}")

def delete_product(self, brand: str, model: str, variant: str):
"""
send a DELETE request to the server to remove a product
Expand Down

0 comments on commit 9b0439e

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/WEEE-Open/pytarallo/commit/9b0439e67fc296761b411b76d26951b9559dfa13

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy