29 lines
854 B
TypeScript
29 lines
854 B
TypeScript
import ApiRequest from "./ApiRequest.js";
|
|
import RequestMethod from "./RequestMethod.js";
|
|
import Fingerprint from "../types/Fingerprint.js";
|
|
import FingerprintCreatedEvent from "../event/FingerprintCreatedEvent.js";
|
|
|
|
export default class FingerprintPostApiRequest extends ApiRequest
|
|
{
|
|
private fingerprint: string;
|
|
private userId: number;
|
|
|
|
public constructor(fingerprint: string, userId: number) {
|
|
super('fingerprint', RequestMethod.POST);
|
|
|
|
this.fingerprint = fingerprint;
|
|
this.userId = userId;
|
|
|
|
this.addParameter('fingerprint', this.fingerprint);
|
|
this.addParameter('userId', this.userId);
|
|
|
|
this.setOnSuccess(
|
|
(response: string) => {
|
|
let json = JSON.parse(response);
|
|
let fingerprint = new Fingerprint(json.userId, this.fingerprint, this.userId);
|
|
|
|
window.dispatchEvent(new FingerprintCreatedEvent(fingerprint));
|
|
}
|
|
);
|
|
}
|
|
} |