UNPKG

@c8y/client

Version:

Client application programming interface to access the Cumulocity IoT-Platform REST services.

130 lines 3.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventService = void 0; const index_js_1 = require("../core/index.js"); /** * This class allows managing for events. */ class EventService extends index_js_1.Service { constructor() { super(...arguments); this.baseUrl = 'event'; this.listUrl = 'events'; this.propertyName = 'events'; this.channel = '/events/*'; } /** * Gets the details of a specific event. * * @param {string|number|IIdentified} entityOrId Entity or Id of the entity. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const eventId: number = 1; * * (async () => { * const {data, res} = await eventService.detail(eventId); * })(); * ``` */ async detail(entityOrId) { return super.detail(entityOrId); } /** * Creates a new event. * * @param {IEvent} entity Event object with mandantory fragments. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const mandantoryObject: IEvent = { * source: device, * text: 'I am an Event!', * time: '2018-05-02T10:08:00Z', * type: 'device-type-here', * }; * * (async () => { * const {data, res} = await eventService.create(mandantoryObject); * })(); * ``` */ async create(entity) { return super.create(entity); } /** * Updates event data. * * @param {Partial<IEvent>} entity Event is partially updatable. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const partialUpdateObject: Partial<IEvent> = { * source: device, * text: 'Changed Event!' * }; * * (async () => { * const {data, res} = await eventService.update(partialUpdateObject); * })(); * ``` */ async update(entity) { return super.update(entity); } /** * Gets the list of events filtered by parameters. * * @returns Response wrapped in [[IResultList]] * * @param {object} filter Object containing filters for querying events. * * **Example** * ```typescript * * const filter: object = { * pageSize: 100, * withTotalPages: true * }; * * (async () => { * const {data, res, paging} = await eventService.list(filter); * })(); * ``` */ async list(filter = {}) { return super.list(filter); } /** * Removes an event with given id. * * @returns Response wrapped in [[IResult]] * * @param {string | number | IIdentified} entityOrId entity or id of the event. * * **Example** * ```typescript * * const eventId: number = 1; * * (async () => { * const {data, res} = await eventService.delete(eventId); * // data will be null * })(); * ``` */ async delete(entityOrId) { return super.delete(entityOrId); } } exports.EventService = EventService; //# sourceMappingURL=EventService.js.map