"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeviceController = void 0;
class DeviceController {
    createDeviceUseCase;
    getDeviceByIdUseCase;
    getAllDevicesUseCase;
    updateDeviceStatusUseCase;
    updateDevicePushTokenUseCase;
    constructor(createDeviceUseCase, getDeviceByIdUseCase, getAllDevicesUseCase, updateDeviceStatusUseCase, updateDevicePushTokenUseCase) {
        this.createDeviceUseCase = createDeviceUseCase;
        this.getDeviceByIdUseCase = getDeviceByIdUseCase;
        this.getAllDevicesUseCase = getAllDevicesUseCase;
        this.updateDeviceStatusUseCase = updateDeviceStatusUseCase;
        this.updateDevicePushTokenUseCase = updateDevicePushTokenUseCase;
    }
    create = async (req, res, next) => {
        try {
            const device = await this.createDeviceUseCase.execute(req.body);
            res.status(201).json({ success: true, data: device });
        }
        catch (error) {
            next(error);
        }
    };
    getById = async (req, res, next) => {
        try {
            const device = await this.getDeviceByIdUseCase.execute(req.params.id);
            res.status(200).json({ success: true, data: device });
        }
        catch (error) {
            next(error);
        }
    };
    getAll = async (req, res, next) => {
        try {
            const devices = await this.getAllDevicesUseCase.execute(req.query);
            res.status(200).json({ success: true, data: devices });
        }
        catch (error) {
            next(error);
        }
    };
    updateStatus = async (req, res, next) => {
        try {
            const device = await this.updateDeviceStatusUseCase.execute(req.params.id, req.body);
            res.status(200).json({ success: true, data: device });
        }
        catch (error) {
            next(error);
        }
    };
    updatePushToken = async (req, res, next) => {
        try {
            const input = req.body;
            console.log('[DeviceController] Updating push token', {
                deviceId: req.params.id,
                pushToken: input.pushToken,
            });
            const device = await this.updateDevicePushTokenUseCase.execute(req.params.id, input);
            res.status(200).json({ success: true, data: device });
        }
        catch (error) {
            next(error);
        }
    };
}
exports.DeviceController = DeviceController;
//# sourceMappingURL=device.controller.js.map