2024-02-16 19:42:26 +00:00
|
|
|
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;
|
2024-03-19 17:37:24 +00:00
|
|
|
public letterxpressAccount: plugins.letterxpress.LetterXpressAccount;
|
|
|
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
2024-02-16 19:42:26 +00:00
|
|
|
|
|
|
|
constructor(platformServiceRefArg: SzPlatformService, optionsArg: ILetterConstructorOptions) {
|
|
|
|
this.platformServiceRef = platformServiceRefArg;
|
|
|
|
this.options = optionsArg;
|
2024-03-19 17:37:24 +00:00
|
|
|
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();
|
2024-02-16 19:42:26 +00:00
|
|
|
}
|
2024-03-19 17:37:24 +00:00
|
|
|
|
|
|
|
public async stop() {}
|
2024-02-16 19:42:26 +00:00
|
|
|
}
|