mnubo-sdk
Version:
mnubo SmartObjects JavaScript client
42 lines (33 loc) • 996 B
text/typescript
import { Client } from '../mnubo';
import { authenticate } from '../decorators';
export class Objects {
private path: string;
constructor(private client: Client) {
this.path = '/api/v3/objects';
}
create(payload: any): Promise<any> {
return this.client.post(this.path, payload);
}
update(deviceId: string, payload: any): Promise<any> {
return this.client.put(`${this.path}/${deviceId}`, payload);
}
createUpdate(payload: Array<any>): Promise<any> {
return this.client.put(`${this.path}`, payload);
}
delete(deviceId: string): Promise<any> {
return this.client.delete(`${this.path}/${deviceId}`);
}
exists(deviceIds: Array<string> | string): Promise<any> {
const path = `${this.path}/exists`;
if (Array.isArray(deviceIds)) {
return this.client.post(`${path}`, deviceIds);
} else {
return this.client.get(`${path}/${deviceIds}`);
}
}
}