2022-09-09 22:46:53 +00:00
|
|
|
import { BaseAPI, route } from "./base";
|
2022-09-27 23:52:13 +00:00
|
|
|
import { ApiSummary, TokenResponse, UserRegistration } from "./types/data-contracts";
|
2022-09-01 22:32:03 +00:00
|
|
|
|
|
|
|
export type LoginPayload = {
|
|
|
|
username: string;
|
|
|
|
password: string;
|
|
|
|
};
|
|
|
|
|
2022-09-04 02:42:03 +00:00
|
|
|
export type StatusResult = {
|
|
|
|
health: boolean;
|
|
|
|
versions: string[];
|
|
|
|
title: string;
|
|
|
|
message: string;
|
|
|
|
};
|
|
|
|
|
2022-09-01 22:32:03 +00:00
|
|
|
export class PublicApi extends BaseAPI {
|
2022-09-04 02:42:03 +00:00
|
|
|
public status() {
|
2022-09-27 23:52:13 +00:00
|
|
|
return this.http.get<ApiSummary>({ url: route("/status") });
|
2022-09-04 02:42:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-01 22:32:03 +00:00
|
|
|
public login(username: string, password: string) {
|
2022-09-27 23:52:13 +00:00
|
|
|
return this.http.post<LoginPayload, TokenResponse>({
|
2022-09-09 22:46:53 +00:00
|
|
|
url: route("/users/login"),
|
2022-09-09 06:05:23 +00:00
|
|
|
body: {
|
|
|
|
username,
|
|
|
|
password,
|
|
|
|
},
|
2022-09-02 01:52:40 +00:00
|
|
|
});
|
2022-09-01 22:32:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-27 23:52:13 +00:00
|
|
|
public register(body: UserRegistration) {
|
|
|
|
return this.http.post<UserRegistration, TokenResponse>({ url: route("/users/register"), body });
|
2022-09-01 22:32:03 +00:00
|
|
|
}
|
|
|
|
}
|