63 lines
1.2 KiB
TypeScript
63 lines
1.2 KiB
TypeScript
export class Token
|
|
{
|
|
static baseURL: "http://localhost:8080";
|
|
|
|
constructor(
|
|
public id: string,
|
|
public name: string,
|
|
public createdAt: Date,
|
|
public expiresAt: Date
|
|
)
|
|
{
|
|
}
|
|
|
|
static get(onSuccess: (tokens: Token[]) => void)
|
|
{
|
|
MavenApi.create().get<Token[]>("/tokens")
|
|
.then((response) =>
|
|
{
|
|
onSuccess(response.data);
|
|
});
|
|
}
|
|
|
|
static delete(id: string, onSuccess: () => void)
|
|
{
|
|
MavenApi.create().delete("/tokens/" + id)
|
|
.then(() =>
|
|
{
|
|
onSuccess();
|
|
});
|
|
}
|
|
}
|
|
|
|
export class TokenCreation
|
|
{
|
|
constructor(
|
|
public name: string,
|
|
public expiresAt: Date
|
|
)
|
|
{
|
|
}
|
|
|
|
static create(tokenCreation: TokenCreation, onSuccess: (token: TokenSecret) => void)
|
|
{
|
|
MavenApi.create().post<TokenSecret>("/tokens", tokenCreation)
|
|
.then((response) =>
|
|
{
|
|
onSuccess(response.data);
|
|
});
|
|
}
|
|
}
|
|
|
|
export class TokenSecret
|
|
{
|
|
constructor(
|
|
public id: string,
|
|
public name: string,
|
|
public expiresAt: Date,
|
|
public createdAt: Date,
|
|
public token: string
|
|
)
|
|
{
|
|
}
|
|
} |