platformservice/ts/letter/classes.letterservice.ts
2024-03-19 18:37:24 +01:00

42 lines
1.3 KiB
TypeScript

import type { SzPlatformService } from '../classes.platformservice.js';
import * as plugins from '../plugins.js';
export interface ILetterConstructorOptions {
letterxpressUser: string;
letterxpressToken: string;
}
export class LetterService {
public platformServiceRef: SzPlatformService;
public options: ILetterConstructorOptions;
public letterxpressAccount: plugins.letterxpress.LetterXpressAccount;
public typedrouter = new plugins.typedrequest.TypedRouter();
constructor(platformServiceRefArg: SzPlatformService, optionsArg: ILetterConstructorOptions) {
this.platformServiceRef = platformServiceRefArg;
this.options = optionsArg;
this.platformServiceRef.typedrouter.addTypedRouter(this.typedrouter);
this.typedrouter.addTypedHandler<
plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter
>(new plugins.typedrequest.TypedHandler('sendLetter', async dataArg => {
if(dataArg.needsCover) {
}
return {
processId: '',
}
}));
}
public async start() {
this.letterxpressAccount = new plugins.letterxpress.LetterXpressAccount({
username: this.options.letterxpressUser,
apiKey: this.options.letterxpressToken,
});
await this.letterxpressAccount.start();
}
public async stop() {}
}