making separate class for LWS API
parent
65e7e5c4e3
commit
89d6690e90
@ -1,3 +1,21 @@
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from lws import config
|
||||||
|
|
||||||
|
|
||||||
|
class LWS:
|
||||||
|
def __init__(self, admin_key):
|
||||||
|
self.admin_key = admin_key
|
||||||
|
|
||||||
|
def list_accounts(self):
|
||||||
|
endpoint = f"{config.LWS_ADMIN_URL}/list_accounts"
|
||||||
|
data = {"auth": self.admin_key}
|
||||||
|
try:
|
||||||
|
req = requests.post(endpoint, json=data, timeout=5)
|
||||||
|
req.raise_for_status()
|
||||||
|
if req.ok:
|
||||||
|
return req.json()
|
||||||
|
return {}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to list accounts: {e}")
|
||||||
|
return {}
|
||||||
|
Loading…
Reference in New Issue