class Account { constructor (client) { this.client = client; } async create(username, password) { let response = await this.client._post("/api/accounts/register", {username: username, password: password}); let response_data = await response.json() if (response_data == "user created") { this._logged = true; return null; } return response_data } async delete(password) { let response = await this.client._delete("/api/accounts/delete", {password: password}); let response_data = await response.json(); if (response_data === "user deleted") this.client._logged = false; return response_data; } async get() { let response = await this.client._get("/api/accounts/edit"); let response_data = await response.json(); if (JSON.stringify(response_data) == JSON.stringify({'detail': 'Authentication credentials were not provided.'})) { console.log("error, client is not logged"); return null; } return response_data; } async update(data, password) { data.password = password; let response = await this.client._patch_json("/api/accounts/edit", data); let response_data = await response.json(); if (JSON.stringify(response_data) == JSON.stringify({'detail': 'Authentication credentials were not provided.'})) { console.log("error, client is not logged"); return null; } return response_data; } } export { Account }