From 5421ece7e4121568c274cee30cdce05a06239b83 Mon Sep 17 00:00:00 2001 From: Vladimir Berdnikov Date: Fri, 5 Aug 2022 14:46:54 +0300 Subject: [PATCH] feat: added methods for working with account properties (#2003) --- package-lock.json | 4 ++-- package.json | 2 +- src/dispatcher.js | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc66159..4c292d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ulms/api-clients", - "version": "5.8.0", + "version": "5.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@ulms/api-clients", - "version": "5.8.0", + "version": "5.9.0", "license": "MIT", "dependencies": { "events": "3.3.0", diff --git a/package.json b/package.json index 5423096..9831721 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ulms/api-clients", - "version": "5.8.0", + "version": "5.9.0", "description": "JavaScript API clients for ULMS platform", "keywords": [], "homepage": "https://github.com/foxford/ulms-api-clients-js#readme", diff --git a/src/dispatcher.js b/src/dispatcher.js index 596684f..8758baf 100644 --- a/src/dispatcher.js +++ b/src/dispatcher.js @@ -28,6 +28,26 @@ class Dispatcher extends BasicClient { } } + /** + * Class properties enum + * @returns {{IS_ADULT: string}} + */ + static get classKeys() { + return { + IS_ADULT: 'is_adult', + } + } + + /** + * Account properties enum + * @returns {{ONBOARDING: string}} + */ + static get accountKeys() { + return { + ONBOARDING: 'onboarding', + } + } + /** * Commit edition by scope * @param {string} audience @@ -46,10 +66,13 @@ class Dispatcher extends BasicClient { * @param {string} kind * @param {string} audience * @param {string} scope + * @param {object} options * @returns {Promise} */ - readScope(kind, audience, scope) { - return this.get(`${this.baseUrl}/audiences/${audience}/${kind}/${scope}`) + readScope(kind, audience, scope, options) { + return this.get( + this.url(`/audiences/${audience}/${kind}/${scope}`, options) + ) } /** @@ -80,6 +103,25 @@ class Dispatcher extends BasicClient { ) } + /** + * Read account property + * @param {string} propertyId + * @returns {Promise} + */ + readAccountProperty(propertyId) { + return this.get(`${this.baseUrl}/account/properties/${propertyId}`) + } + + /** + * Update account property + * @param {string} propertyId + * @param {object} data + * @returns {Promise} + */ + updateAccountProperty(propertyId, data) { + return this.put(`${this.baseUrl}/account/properties/${propertyId}`, data) + } + /** * Update dispatcher scope * @param {string} kind