import { HttpService, Injectable } from '@nestjs/common'; @Injectable() export class CloudService { constructor(private readonly http: HttpService) { } async register(data) { try { const response = await this.http.post('/api/admin/device', data).toPromise(); return response.data; } catch ({ response }) { throw { data: response.data, status: response.status, path: response.config.url }; } } async deleteDevice(id: number) { try { const response = await this.http.delete(`/api/admin/device/${id}`).toPromise(); return response.data; } catch ({ response }) { throw { data: response.data, status: response.status, path: response.config.url }; // throw { data: response.data, status: response.status, path: response.config.url }; } } async updateDeviceStatus(id: number) { try { const response = await this.http.put(`/api/admin/device/${id}/state/2`, null).toPromise(); return response.data; } catch ({ response }) { throw { data: response.data, status: response.status, path: response.config.url }; } } async getCert(id: number) { try { const response = await this.http.get(`/api/admin/device/${id}/certificate/generate`).toPromise(); return response.data; } catch ({ response }) { throw { data: response.data, status: response.status, path: response.config.url }; } } }