@xompass/sdk-cloud-api
Version:
Xompass Client for cloud-api
121 lines (115 loc) • 2.54 kB
text/typescript
import {ModelDefinition} from './BaseModels';
import {Asset} from './Asset';
import {Log} from './Log';
declare var Object: any;
export interface ControlInterface {
name?: string;
enabled?: boolean;
properties?: any;
created?: Date;
modified?: Date;
deleted?: Date;
id?: any;
assetId?: any;
asset?: Asset;
trackingLogs?: Log[];
}
export class Control implements ControlInterface {
name: string;
enabled: boolean;
properties: any;
created: Date;
modified: Date;
deleted: Date;
id: any;
assetId: any;
asset?: Asset;
trackingLogs?: Log[];
constructor(data?: ControlInterface) {
Object.assign(this, data);
}
/**
* The name of the model represented by this $resource,
* i.e. `Control`.
*/
public static getModelName(): string {
return 'Control';
}
/**
* @method factory
* @author Jonathan Casarrubias
* @license MIT
* This method creates an instance of Control for dynamic purposes.
*/
public static factory(data: ControlInterface): Control{
return new Control(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: 'Control',
plural: 'Controls',
path: 'Controls',
idName: 'id',
properties: {
name: {
name: 'name',
type: 'string'
},
enabled: {
name: 'enabled',
type: 'boolean'
},
properties: {
name: 'properties',
type: 'any'
},
created: {
name: 'created',
type: 'Date'
},
modified: {
name: 'modified',
type: 'Date'
},
deleted: {
name: 'deleted',
type: 'Date',
default: undefined
},
id: {
name: 'id',
type: 'any'
},
assetId: {
name: 'assetId',
type: 'any'
},
},
relations: {
asset: {
name: 'asset',
type: 'Asset',
model: 'Asset',
relationType: 'belongsTo',
keyFrom: 'assetId',
keyTo: 'id'
},
trackingLogs: {
name: 'trackingLogs',
type: 'Log[]',
model: 'Log',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'trackingModelId'
},
}
};
}
}