// Webhook Dispatcher — service uniquement (commandes enregistrées sous `webhook` par webhook_listener.js)

export class WHD {
    constructor(program, logger, services) {
        this.logger = logger;
        this.services = services;
        services['whd'] = this;

        this.logger.debug('WHD.constructor');
    }



    async getSubscriptionSnapshot(subscriptionId) {
        this.logger.debug('WHD.getSubscriptionSnapshot');

        const json = await this.services['rest'].restCall('GET', `/api/rainbow/event-dispatcher/v1.0/subscription/${subscriptionId}/snapshot`,
            [], {},
            { 'Accept': 'application/json' }
        );
        return json;
    }

    async getSubscriptionStatus(subscriptionId) {
        this.logger.debug('WHD.getSubscriptionStatus');

        const json = await this.services['rest'].restCall('GET', `/api/rainbow/event-dispatcher/v1.0/subscription/${subscriptionId}/status`,
            [], {},
            { 'Accept': 'application/json' }
        );
        return json;
    }
}