ringfinger/js/api/UserGetApiRequest.ts

25 lines
700 B
TypeScript

import ApiRequest from "./ApiRequest.js";
import RequestMethod from "./RequestMethod.js";
import UserGetEvent from "../event/UserGetEvent.js";
import User from "../types/User.js";
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));
}
}
}