2022-09-29 16:38:50 +02:00
|
|
|
import { AccountApiService } from "../../abstractions/account/account-api.service.abstraction";
|
2022-07-29 21:49:58 +02:00
|
|
|
import { AccountService as AccountServiceAbstraction } from "../../abstractions/account/account.service.abstraction";
|
2022-09-29 16:38:50 +02:00
|
|
|
import { LogService } from "../../abstractions/log.service";
|
|
|
|
import { MessagingService } from "../../abstractions/messaging.service";
|
|
|
|
import { UserVerificationService } from "../../abstractions/userVerification/userVerification.service.abstraction";
|
2022-07-29 21:49:58 +02:00
|
|
|
import { Verification } from "../../types/verification";
|
|
|
|
|
|
|
|
export class AccountService implements AccountServiceAbstraction {
|
|
|
|
constructor(
|
|
|
|
private accountApiService: AccountApiService,
|
|
|
|
private userVerificationService: UserVerificationService,
|
|
|
|
private messagingService: MessagingService,
|
|
|
|
private logService: LogService
|
|
|
|
) {}
|
|
|
|
|
2022-08-10 03:31:02 +02:00
|
|
|
async delete(verification: Verification): Promise<void> {
|
2022-07-29 21:49:58 +02:00
|
|
|
try {
|
|
|
|
const verificationRequest = await this.userVerificationService.buildRequest(verification);
|
|
|
|
await this.accountApiService.deleteAccount(verificationRequest);
|
|
|
|
this.messagingService.send("logout");
|
|
|
|
} catch (e) {
|
|
|
|
this.logService.error(e);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|