forked from mirrors/homebox
move to nuxt
This commit is contained in:
parent
890eb55d27
commit
26ecb5a9d4
93 changed files with 5273 additions and 4749 deletions
34
frontend/lib/api/user.ts
Normal file
34
frontend/lib/api/user.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { Requests } from "~~/lib/requests";
|
||||
import { BaseAPI, UrlBuilder } from "./base";
|
||||
import { LocationsApi } from "./classes/locations";
|
||||
|
||||
export type Result<T> = {
|
||||
item: T;
|
||||
};
|
||||
|
||||
export type User = {
|
||||
name: string;
|
||||
email: string;
|
||||
isSuperuser: boolean;
|
||||
id: number;
|
||||
};
|
||||
|
||||
export class UserApi extends BaseAPI {
|
||||
locations: LocationsApi;
|
||||
|
||||
constructor(requests: Requests) {
|
||||
super(requests);
|
||||
|
||||
this.locations = new LocationsApi(requests);
|
||||
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
public self() {
|
||||
return this.http.get<Result<User>>(UrlBuilder("/users/self"));
|
||||
}
|
||||
|
||||
public logout() {
|
||||
return this.http.post<object, void>(UrlBuilder("/users/logout"), {});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue