@xompass/sdk-cloud-api
Version:
Xompass Client for cloud-api
158 lines (152 loc) • 3.49 kB
text/typescript
import {ModelDefinition} from './BaseModels';
import {Device} from './Device';
import {DeviceEvent} from './DeviceEvent';
import {Log} from './Log';
declare var Object: any;
export interface DeviceEventDataInterface {
id?: string;
type: string;
hash: string;
tags?: Array<any>;
content: any;
meta?: any;
level?: string;
created?: Date;
modified?: Date;
deleted?: Date;
deviceId?: string;
deviceEventId?: string;
device?: Device;
event?: DeviceEvent;
trackingLogs?: Log[];
}
export class DeviceEventData implements DeviceEventDataInterface {
id: string;
type: string;
hash: string;
tags: Array<any> = [];
content: any;
meta: any;
level: string = 'NONE';
created: Date;
modified: Date;
deleted: Date;
deviceId: string;
deviceEventId: string;
device?: Device;
event?: DeviceEvent;
trackingLogs?: Log[];
constructor(data?: DeviceEventDataInterface) {
Object.assign(this, data);
}
/**
* The name of the model represented by this $resource,
* i.e. `DeviceEventData`.
*/
public static getModelName(): string {
return 'DeviceEventData';
}
/**
* @method factory
* @author Jonathan Casarrubias
* @license MIT
* This method creates an instance of DeviceEventData for dynamic purposes.
*/
public static factory(data: DeviceEventDataInterface): DeviceEventData{
return new DeviceEventData(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: 'DeviceEventData',
plural: 'DeviceEventData',
path: 'DeviceEventData',
idName: 'id',
properties: {
id: {
name: 'id',
type: 'string'
},
type: {
name: 'type',
type: 'string'
},
hash: {
name: 'hash',
type: 'string'
},
tags: {
name: 'tags',
type: 'Array<any>',
default: []
},
content: {
name: 'content',
type: 'any'
},
meta: {
name: 'meta',
type: 'any'
},
level: {
name: 'level',
type: 'string',
default: 'NONE'
},
created: {
name: 'created',
type: 'Date'
},
modified: {
name: 'modified',
type: 'Date'
},
deleted: {
name: 'deleted',
type: 'Date',
default: undefined
},
deviceId: {
name: 'deviceId',
type: 'string'
},
deviceEventId: {
name: 'deviceEventId',
type: 'string'
},
},
relations: {
device: {
name: 'device',
type: 'Device',
model: 'Device',
relationType: 'belongsTo',
keyFrom: 'deviceId',
keyTo: 'id'
},
event: {
name: 'event',
type: 'DeviceEvent',
model: 'DeviceEvent',
relationType: 'belongsTo',
keyFrom: 'deviceEventId',
keyTo: 'id'
},
trackingLogs: {
name: 'trackingLogs',
type: 'Log[]',
model: 'Log',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'trackingModelId'
},
}
};
}
}