/** * Device API service */ import { getApiClient } from './api-client'; import type { Device, DeviceRegistration, DeviceListResponse } from '../types'; export class DeviceService { private api = getApiClient(); async registerDevice(data: DeviceRegistration): Promise { const response = await this.api.post('/api/v1/devices/register', data); return response.data; } async updatePushToken(pushToken: string): Promise { const response = await this.api.patch('/api/v1/devices/push-token', { pushToken, }); return response.data; } async getDevices(): Promise { const response = await this.api.get('/api/v1/devices'); return response.data; } async getDevice(deviceId: string): Promise { const response = await this.api.get(`/api/v1/devices/${deviceId}`); return response.data; } async deleteDevice(deviceId: string): Promise { await this.api.delete(`/api/v1/devices/${deviceId}`); } async getCurrentDevice(): Promise { try { const response = await this.api.get('/api/v1/devices/current'); return response.data; } catch { return null; } } } export const deviceService = new DeviceService();