Fingerprint creation implemented.

This commit is contained in:
Mal 2020-09-08 14:21:04 +02:00
parent 894ba92016
commit ab86081dd9
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,29 @@
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));
}
);
}
}

View File

@ -0,0 +1,18 @@
import RingfingerEvent from "./RingfingerEvent.js";
import Fingerprint from "../types/Fingerprint.js";
export default class FingerprintCreatedEvent extends RingfingerEvent
{
private fingerprint: Fingerprint;
public constructor(fingerprint: Fingerprint) {
super(FingerprintCreatedEvent.name);
this.fingerprint = fingerprint;
}
public getFingerprint(): Fingerprint
{
return this.fingerprint;
}
}