Repository: auth0/node-auth0
Pull request #386 (2019-07-17 20:54:20)

Complete/fix addition of branding and prompts endpoints.
### Changes

Please describe both what is changing and why this is important. Include:

- This completes the intended changes in #370 which were unintentionally left out.

### References

- #370 

### Testing

Use with `auth0-deploy-cli` and it should now export/import branding and prompts data.

- [ ] This change adds unit test coverage
- [ ] This change adds integration test coverage

### Checklist

- [X] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
- [X] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
- [ ] All existing and new tests complete without errors


Patch:
diff --git a/src/management/index.js b/src/management/index.js
index 9ea1dc562..47ad449b7 100644
--- a/src/management/index.js
+++ b/src/management/index.js
@@ -30,6 +30,8 @@ var EmailTemplatesManager = require('./EmailTemplatesManager');
 var GuardianManager = require('./GuardianManager');
 var CustomDomainsManager = require('./CustomDomainsManager');
 var RolesManager = require('./RolesManager');
+var BrandingManager = require('./BrandingManager');
+var PromptsManager = require('./PromptsManager');
 
 var BASE_URL_FORMAT = 'https://%s/api/v2';
 var MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/';
@@ -304,6 +306,22 @@ var ManagementClient = function(options) {
    * @type {RolesManager}
    */
   this.roles = new RolesManager(managerOptions);
+
+  /**
+   * Simple abstraction for performing CRUD operations on the
+   * branding endpoint.
+   *
+   * @type {BrandingManager}
+   */
+  this.branding = new BrandingManager(managerOptions);
+
+  /**
+   * Simple abstraction for performing CRUD operations on the
+   * prompts endpoint.
+   *
+   * @type {PromptsManager}
+   */
+  this.prompts = new PromptsManager(managerOptions);
 };
 
 /**
@@ -2826,4 +2844,85 @@ utils.wrapPropertyMethod(ManagementClient, 'getUsersInRole', 'roles.getUsers');
  */
 utils.wrapPropertyMethod(ManagementClient, 'getAccessToken', 'tokenProvider.getAccessToken');
 
+/** Get branding settings.
+ *
+ * @method    getBrandingSettings
+ * @memberOf  module:management.ManagementClient.prototype
+ *
+ * @example
+ * management.getBrandingSettings(function (err, settings) {
+ *   if (err) {
+ *     // Handle error.
+ *   }
+ *
+ *   console.log(settings);
+ * });
+ *
+ * @param   {Function}  [cb]  Callback function.
+ *
+ * @return  {Promise|undefined}
+ */
+utils.wrapPropertyMethod(ManagementClient, 'getBrandingSettings', 'branding.getSettings');
+
+/**
+ * Update branding settings.
+ *
+ * @method    updateBrandingSettings
+ * @memberOf  module:management.ManagementClient.prototype
+ *
+ * @example
+ * management.updateBrandingSettings(data, function (err) {
+ *   if (err) {
+ *     // Handle error.
+ *   }
+ * });
+ *
+ * @param   {Object}    data  The new branding settings.
+ * @param   {Function}  [cb]  Callback function.
+ *
+ * @return  {Promise|undefined}
+ */
+utils.wrapPropertyMethod(ManagementClient, 'updateBrandingSettings', 'branding.updateSettings');
+
+/**
+ * Get prompts settings..
+ *
+ * @method    getPromptsSettings
+ * @memberOf  module:management.ManagementClient.prototype
+ *
+ * @example
+ * management.getPromptsSettings(function (err, settings) {
+ *   if (err) {
+ *     // Handle error.
+ *   }
+ *
+ *   console.log(settings);
+ * });
+ *
+ * @param   {Function}  [cb]  Callback function.
+ *
+ * @return  {Promise|undefined}
+ */
+utils.wrapPropertyMethod(ManagementClient, 'getPromptsSettings', 'prompts.getSettings');
+
+/**
+ * Update prompts settings.
+ *
+ * @method    updatePromptsSettings
+ * @memberOf  module:management.ManagementClient.prototype
+ *
+ * @example
+ * management.updatePromptsSettings(data, function (err) {
+ *   if (err) {
+ *     // Handle error.
+ *   }
+ * });
+ *
+ * @param   {Object}    data  The new prompts settings.
+ * @param   {Function}  [cb]  Callback function.
+ *
+ * @return  {Promise|undefined}
+ */
+utils.wrapPropertyMethod(ManagementClient, 'updatePromptsSettings', 'prompts.updateSettings');
+
 module.exports = ManagementClient;


Test patch:
diff --git a/test/management/management-client.tests.js b/test/management/management-client.tests.js
index c70bdde50..95e3ac9ed 100644
--- a/test/management/management-client.tests.js
+++ b/test/management/management-client.tests.js
@@ -807,7 +807,11 @@ describe('ManagementClient', function() {
       'unblockUser',
       'getUserBlocksByIdentifier',
       'unblockUserByIdentifier',
-      'getAccessToken'
+      'getAccessToken',
+      'getBrandingSettings',
+      'updateBrandingSettings',
+      'getPromptsSettings',
+      'updatePromptsSettings'
     ];
 
     before(function() {