import api from './api';

const fidoKeyService = {
    /**
     * Get all FIDO keys
     */
    getAll: async () => {
        const response = await api.get('/fido-keys');
        return response.data.data;
    },

    /**
     * Get FIDO key by ID
     */
    getById: async (id) => {
        const response = await api.get(`/fido-keys/${id}`);
        return response.data.data;
    },

    /**
     * Get FIDO key by serial number
     */
    getBySerial: async (serialNumber) => {
        const response = await api.get(`/fido-keys/serial/${serialNumber}`);
        return response.data.data;
    },

    /**
     * Get FIDO keys by status
     */
    getByStatus: async (status) => {
        const response = await api.get(`/fido-keys/status/${status}`);
        return response.data.data;
    },

    /**
     * Create new FIDO key
     */
    create: async (keyData) => {
        const response = await api.post('/fido-keys', keyData);
        return response.data.data;
    },

    /**
     * Update FIDO key
     */
    update: async (id, keyData) => {
        const response = await api.put(`/fido-keys/${id}`, keyData);
        return response.data.data;
    },

    /**
     * Update FIDO key status
     */
    updateStatus: async (id, status) => {
        const response = await api.put(`/fido-keys/${id}/status`, { status });
        return response.data.data;
    },

    /**
     * Delete FIDO key
     */
    delete: async (id) => {
        const response = await api.delete(`/fido-keys/${id}`);
        return response.data;
    },

    /**
     * Get statistics
     */
    getStatistics: async () => {
        const response = await api.get('/fido-keys/stats');
        return response.data.data;
    },
};

export default fidoKeyService;
