ringfinger/js/api/UserGetApiRequest.ts

25 lines
700 B
TypeScript
Raw Permalink Normal View History

2020-09-06 12:07:26 +02:00
import ApiRequest from "./ApiRequest.js";
import RequestMethod from "./RequestMethod.js";
import UserGetEvent from "../event/UserGetEvent.js";
import User from "../types/User.js";
2020-09-06 12:07:26 +02:00
export default class UserGetApiRequest extends ApiRequest
{
public constructor(userId: number)
{
super('user/' + userId, RequestMethod.GET);
this.onSuccess = (response: string) => {
let json = JSON.parse(response);
let user = new User(json.result.userId);
user.setUsername(json.result.username);
user.setJabberAddress(json.result.jabberAddress);
user.setAdmin(json.result.isAdmin);
user.setFingerprintIds(json.result.fingerprintIds);
window.dispatchEvent(new UserGetEvent(user));
}
2020-09-06 12:07:26 +02:00
}
}