import axios from "axios"; import {AuthApi} from "~/utils/AuthApi"; export class Account { firstname?: string; lastname?: string; username?: string; email?: string; password?: string; roles?: string[]; initial?: boolean; static get(id: string, token: string, onSuccess: (account: Account) => void) { AuthApi.get(StringUtils.format('/accounts/%s', id), { headers: { Authorization: StringUtils.format("Bearer %s", token) } }) .then((response) => { onSuccess(response.data); }); } static create(user: AccountCreation, onSuccess: () => void) { AuthApi.post('/accounts', user) .then(() => { onSuccess(); }); } } export class AccountCreation { firstname?: string; lastname?: string; email?: string; password?: string; username?: string; role: string = "USER"; }