2020-09-06 12:07:26 +02:00
|
|
|
import ApiRequest from "./ApiRequest.js";
|
|
|
|
import RequestMethod from "./RequestMethod.js";
|
2020-09-07 22:45:52 +02:00
|
|
|
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);
|
2020-09-07 22:45:52 +02:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|