34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { SzPlatformClient } from '../classes.platformclient.js';
|
|
import * as plugins from '../plugins.js';
|
|
|
|
export class SzPushNotificationConnector {
|
|
public platformClientRef: SzPlatformClient;
|
|
|
|
constructor(platformClientRefArg: SzPlatformClient) {
|
|
this.platformClientRef = platformClientRefArg;
|
|
}
|
|
|
|
public async sendPushNotification(
|
|
optionsArg: plugins.servezoneInterfaces.platformservice.pushnotification.IRequest_SendPushNotification['request']
|
|
) {
|
|
if (this.platformClientRef.debugMode) {
|
|
console.log('sendPushNotification', optionsArg);
|
|
}
|
|
|
|
if (this.platformClientRef.debugMode) {
|
|
return;
|
|
}
|
|
|
|
const typedRequest =
|
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.pushnotification.IRequest_SendPushNotification>(
|
|
'sendPushNotification'
|
|
);
|
|
const response = await typedRequest.fire(optionsArg);
|
|
|
|
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
|
console.log('sendPushNotification response', response);
|
|
}
|
|
|
|
return response.status;
|
|
}
|
|
} |