import {
    BaseAdapter,
    MessagingQueue,
    NotifyBulkCategorizedHourReviewedBody,
    QueueMessageTypes,
    QueuePort,
    SqsMessagingQueue,
} from '@humand-packages/common';
import { Service } from 'typedi';
import { getConfig } from '../../../../apiConfig/configSetup';
import { TimeTrackingNotifyBulkCategorizedHourReviewedPort } from '../../business/ports/timeTrackingNotifyBulkCategorizedHourReviewedPort';

@Service()
export class TimeTrackingNotifyBulkCategorizedHourReviewedAdapter extends BaseAdapter implements TimeTrackingNotifyBulkCategorizedHourReviewedPort {
    private readonly queue: MessagingQueue;

    constructor(private readonly queuePort: QueuePort) {
        super();
        this.queue = new SqsMessagingQueue(getConfig().awsSqsTimeTrackingCategorizedHoursQueueUrl!, false);
    }

    enqueue = async (payload: NotifyBulkCategorizedHourReviewedBody): Promise<void> => {
        await this.queuePort.sendMessage(this.queue, QueueMessageTypes.TIME_TRACKING_NOTIFY_BULK_CATEGORIZED_HOUR_REVIEWED, payload);
    };
}
