Skip to content

Commit

Permalink
ULP-2609: add page templates support to /branding (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebadoom authored Feb 5, 2021
1 parent 6be7d2c commit 37e3715
Show file tree
Hide file tree
Showing 3 changed files with 385 additions and 0 deletions.
79 changes: 79 additions & 0 deletions src/management/BrandingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ var BrandingManager = function(options) {
options.tokenProvider
);
this.resource = new RetryRestClient(auth0RestClient, options.retry);

/**
* Provides an abstraction layer for consuming the
* {@link https://auth0.com/docs/api/management/v2#!/Branding/get_universal_login Branding new universal login template endpoint}.
*
* @type {external:RestClient}
*/
var brandingTemplateAuth0RestClient = new Auth0RestClient(
options.baseUrl + '/branding/templates/universal-login',
clientOptions,
options.tokenProvider
);
this.brandingTemplates = new RetryRestClient(brandingTemplateAuth0RestClient, options.retry);
};

/**
Expand Down Expand Up @@ -101,4 +114,70 @@ utils.wrapPropertyMethod(BrandingManager, 'updateSettings', 'resource.patch');
*/
utils.wrapPropertyMethod(BrandingManager, 'getSettings', 'resource.get');

/**
* Get the new universal login template.
*
* @method getUniversalLoginTemplate
* @memberOf module:management.BrandingManager.prototype
*
* @example
* management.branding.getUniversalLoginTemplate(data, function (err, template) {
* if (err) {
* // Handle error.
* }
*
* // Branding
* console.log(template);
* });
*
* @param {Object} params Branding parameters (leave empty).
* @param {Object} data Branding data (leave empty).
* @param {Function} [cb] Callback function.
*
* @return {Promise|undefined}
*/
utils.wrapPropertyMethod(BrandingManager, 'getUniversalLoginTemplate', 'brandingTemplates.get');

/**
* Set the new universal login template.
*
* @method setUniversalLoginTemplate
* @memberOf module:management.BrandingManager.prototype
*
* @example
* management.branding.setUniversalLoginTemplate({ template: "a template" }, function (err) {
* if (err) {
* // Handle error.
* }
* });
*
* @param {Object} params Branding parameters (leavy empty).
* @param {Object} data Branding data (object with template field).
* @param {Function} [cb] Callback function.
*
* @return {Promise|undefined}
*/
utils.wrapPropertyMethod(BrandingManager, 'setUniversalLoginTemplate', 'brandingTemplates.update');

/**
* Delete the new universal login template (revert to default).
*
* @method deleteUniversalLoginTemplate
* @memberOf module:management.BrandingManager.prototype
*
* @example
* management.branding.deleteUniversalLoginTemplate(data, function (err) {
* if (err) {
* // Handle error.
* }
* });
*
* @param {Object} params Branding parameters (leavy empty).
* @param {Object} data Branding data (leave empty).
* @param {Function} [cb] Callback function.
*
* @return {Promise|undefined}
*/
utils.wrapPropertyMethod(BrandingManager, 'deleteUniversalLoginTemplate', 'brandingTemplates.delete');

module.exports = BrandingManager;
66 changes: 66 additions & 0 deletions src/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3651,6 +3651,72 @@ utils.wrapPropertyMethod(ManagementClient, 'updateBrandingSettings', 'branding.u
*/
utils.wrapPropertyMethod(ManagementClient, 'getBrandingSettings', 'branding.getSettings');

/**
* Get the new universal login template.
*
* @method getBrandingUniversalLoginTemplate
* @memberOf module:management.ManagementClient.prototype
*
* @example
* management.getBrandingUniversalLoginTemplate(data, function (err, template) {
* if (err) {
* // Handle error.
* }
*
* // Branding
* console.log(template);
* });
*
* @param {Object} params Branding parameters (leave empty).
* @param {Object} data Branding data (leave empty).
* @param {Function} [cb] Callback function.
*
* @return {Promise|undefined}
*/
utils.wrapPropertyMethod(ManagementClient, 'getBrandingUniversalLoginTemplate', 'branding.getUniversalLoginTemplate');

/**
* Get the new universal login template.
*
* @method setBrandingUniversalLoginTemplate
* @memberOf module:management.ManagementClient.prototype
*
* @example
* management.setBrandingUniversalLoginTemplate({ template: "a template" }, function (err, template) {
* if (err) {
* // Handle error.
* }
* });
*
* @param {Object} params Branding parameters (leave empty).
* @param {Object} template Branding data (object with template field).
* @param {Function} [cb] Callback function.
*
* @return {Promise|undefined}
*/
utils.wrapPropertyMethod(ManagementClient, 'setBrandingUniversalLoginTemplate', 'branding.setUniversalLoginTemplate');

/**
* Delete the new universal login template.
*
* @method deleteBrandingUniversalLoginTemplate
* @memberOf module:management.ManagementClient.prototype
*
* @example
* management.deleteBrandingUniversalLoginTemplate(template, function (err) {
* if (err) {
* // Handle error.
* }
* });
*
* @param {Object} params Branding parameters (leave empty).
* @param {Object} data Branding data (leave empty).
* @param {Function} [cb] Callback function.
*
* @return {Promise|undefined}
*/
utils.wrapPropertyMethod(ManagementClient, 'deleteBrandingUniversalLoginTemplate', 'branding.deleteUniversalLoginTemplate');

/**
* Update the tenant migrations.
*
Expand Down
Loading

0 comments on commit 37e3715

Please sign in to comment.