diff --git a/package-lock.json b/package-lock.json index 163de6d..0ac1665 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ulms/api-clients", - "version": "7.9.0", + "version": "7.9.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ulms/api-clients", - "version": "7.9.0", + "version": "7.9.1", "license": "MIT", "dependencies": { "axios": "1.6.2", diff --git a/package.json b/package.json index 32c39a9..32d5092 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ulms/api-clients", - "version": "7.9.0", + "version": "7.9.1", "description": "JavaScript API clients for ULMS platform", "keywords": [], "homepage": "https://github.com/foxford/ulms-api-clients-js#readme", diff --git a/src/http-event.js b/src/http-event.js index f891d1f..8eb07c4 100644 --- a/src/http-event.js +++ b/src/http-event.js @@ -111,6 +111,7 @@ class HTTPEvent extends BasicClient { /** * Create event + * @deprecated * @param {uuid} roomId * @param {String} type * @param {Object|String|Number} data @@ -131,6 +132,7 @@ class HTTPEvent extends BasicClient { /** * Sets the flag "removed" for the event + * @deprecated * @param {uuid} roomId * @param {String} type * @param {Object|String|Number} data diff --git a/src/ulms.js b/src/ulms.js index 9f7a462..45ebf15 100644 --- a/src/ulms.js +++ b/src/ulms.js @@ -84,6 +84,43 @@ class ULMS extends BasicClient { ) } + /** + * Create event + * @param {uuid} roomId + * @param {String} type + * @param {Object|String|Number} data + * @param {Object} eventParameters event parameters: attribute, is_claim, is_persistent, label, set, removed + * for more information see: https://github.com/foxford/event/blob/master/docs/src/api/event/create.md + * + * @returns {Promise} + */ + createEvent(roomId, type, data, eventParameters = {}) { + const parameters = { + ...eventParameters, + data, + type, + } + + return this.post(`${this.baseUrl}/event_rooms/${roomId}/events`, parameters) + } + + /** + * Sets the flag "removed" for the event + * @param {uuid} roomId + * @param {String} type + * @param {Object|String|Number} data + * @param {Object} eventParameters event parameters: attribute, is_claim, is_persistent, label, set, removed + * for more information see: https://github.com/foxford/event/blob/master/docs/src/api/event/create.md + * + * @returns {Promise} + */ + createRemovalEvent(roomId, type, data, eventParameters = {}) { + return this.createEvent(roomId, type, data, { + ...eventParameters, + removed: true, + }) + } + /** * Perform enter to classroom * @param {string} classroomId