Fingerprint creation implemented.
This commit is contained in:
parent
894ba92016
commit
ab86081dd9
|
@ -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));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue