UNPKG

@xompass/sdk-cloud-api

Version:

Xompass Client for cloud-api

199 lines (193 loc) 4.69 kB
import {ModelDefinition} from './BaseModels'; import {Device} from './Device'; import {DeviceEventComment} from './DeviceEventComment'; import {DeviceEventData} from './DeviceEventData'; import {DeviceEventStateChange} from './DeviceEventStateChange'; import {Log} from './Log'; declare var Object: any; export interface DeviceEventInterface { id?: string; type: string; hash: string; tags?: Array<any>; muted: boolean; seen: boolean; hidden: boolean; starred: boolean; currentState?: string; created?: Date; modified?: Date; deleted?: Date; deviceId?: string; _comments?: Array<any>; _stateChanges?: Array<any>; device?: Device; comments?: DeviceEventComment[]; data?: DeviceEventData[]; stateChanges?: DeviceEventStateChange[]; trackingLogs?: Log[]; } export class DeviceEvent implements DeviceEventInterface { id: string; type: string; hash: string; tags: Array<any> = []; muted: boolean; seen: boolean; hidden: boolean; starred: boolean; currentState: string; created: Date; modified: Date; deleted: Date; deviceId: string; _comments: Array<any> = []; _stateChanges: Array<any> = []; device?: Device; comments?: DeviceEventComment[]; data?: DeviceEventData[]; stateChanges?: DeviceEventStateChange[]; trackingLogs?: Log[]; constructor(data?: DeviceEventInterface) { Object.assign(this, data); } /** * The name of the model represented by this $resource, * i.e. `DeviceEvent`. */ public static getModelName(): string { return 'DeviceEvent'; } /** * @method factory * @author Jonathan Casarrubias * @license MIT * This method creates an instance of DeviceEvent for dynamic purposes. */ public static factory(data: DeviceEventInterface): DeviceEvent{ return new DeviceEvent(data); } /** * @method getModelDefinition * @author Julien Ledun * @license MIT * This method returns an object that represents some of the model * definitions. */ public static getModelDefinition(): ModelDefinition { return { name: 'DeviceEvent', plural: 'DeviceEvents', path: 'DeviceEvents', idName: 'id', properties: { id: { name: 'id', type: 'string' }, type: { name: 'type', type: 'string' }, hash: { name: 'hash', type: 'string' }, tags: { name: 'tags', type: 'Array&lt;any&gt;', default: [] }, muted: { name: 'muted', type: 'boolean' }, seen: { name: 'seen', type: 'boolean' }, hidden: { name: 'hidden', type: 'boolean' }, starred: { name: 'starred', type: 'boolean' }, currentState: { name: 'currentState', type: 'string' }, created: { name: 'created', type: 'Date' }, modified: { name: 'modified', type: 'Date' }, deleted: { name: 'deleted', type: 'Date', default: undefined }, deviceId: { name: 'deviceId', type: 'string' }, _comments: { name: '_comments', type: 'Array&lt;any&gt;', default: [] }, _stateChanges: { name: '_stateChanges', type: 'Array&lt;any&gt;', default: [] }, }, relations: { device: { name: 'device', type: 'Device', model: 'Device', relationType: 'belongsTo', keyFrom: 'deviceId', keyTo: 'id' }, comments: { name: 'comments', type: 'DeviceEventComment[]', model: 'DeviceEventComment', relationType: 'embedsMany', keyFrom: '_comments', keyTo: 'id' }, data: { name: 'data', type: 'DeviceEventData[]', model: 'DeviceEventData', relationType: 'hasMany', keyFrom: 'id', keyTo: 'deviceEventId' }, stateChanges: { name: 'stateChanges', type: 'DeviceEventStateChange[]', model: 'DeviceEventStateChange', relationType: 'embedsMany', keyFrom: '_stateChanges', keyTo: 'id' }, trackingLogs: { name: 'trackingLogs', type: 'Log[]', model: 'Log', relationType: 'hasMany', keyFrom: 'id', keyTo: 'trackingModelId' }, } }; } }