Maybe? Well, I just wanted to post somewhere travaso.py:
#!/usr/bin/env python3
import json
import requests
import getpass
code = "zonarossa"
destination = '"magazzino"'
print(f"Doing da' travaso of {code} to {destination}")
pw = getpass.getpass()
t = requests.Session()
result_login = t.post("https://tarallo.weeeopen.it/v1/session", headers={"Content-Type": "application/json"},
json={"username": "your_name", "password": pw})
print(f"Login: {str(result_login.status_code)}")
if result_login.status_code != 204:
exit(1)
things = t.get(f"https://tarallo.weeeopen.it/v1/items/{code}", headers={"Accept": "application/json"})
codes = []
for inner in json.loads(things.content).get('data').get('contents'):
codes.append(inner.get('code'))
print(f"{len(codes)} items: {str(codes)}")
go = False
while not go:
print("Type 'asd' to continue")
choice = input().lower()
if choice in 'asd':
go = True
for code in codes:
result_move = t.put(f"https://tarallo.weeeopen.it/v1/items/{code}/parent", headers={"Content-Type": "application/json"}, data=destination)
print(f"Moving {code}: {str(result_move.status_code)}")
It's actually a lot simpler, as you shouldn't ask for confirmation and the login part doesn't need to be replicated (obviously), but it needs a lot more error checking.
Maybe? Well, I just wanted to post somewhere
travaso.py
:It's actually a lot simpler, as you shouldn't ask for confirmation and the login part doesn't need to be replicated (obviously), but it needs a lot more error checking.