Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add branding theme routes #725

Merged
merged 3 commits into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
122 changes: 122 additions & 0 deletions src/management/BrandingManager.js
Expand Up @@ -56,6 +56,19 @@ class BrandingManager {
options.tokenProvider
);
this.brandingTemplates = new RetryRestClient(brandingTemplateAuth0RestClient, options.retry);

/**
* Provides an abstraction layer for consuming the
* {@link https://auth0.com/docs/api/management/v2#!/Branding/get_branding_theme Branding theme endpoint}.
*
* @type {external:RestClient}
*/
const brandingThemesAuth0RestClient = new Auth0RestClient(
`${options.baseUrl}/branding/themes/:id`,
clientOptions,
options.tokenProvider
);
this.brandingThemes = new RetryRestClient(brandingThemesAuth0RestClient, options.retry);
}

/**
Expand Down Expand Up @@ -156,6 +169,115 @@ class BrandingManager {
deleteUniversalLoginTemplate(...args) {
return this.brandingTemplates.delete(...args);
}

/**
* Get the new universal login theme by id.
*
* @example
* var params = { id: THEME_ID };
*
* management.branding.getTheme(params, function (err, theme) {
* if (err) {
* // Handle error.
* }
*
* // Theme
* console.log(theme);
* });
* @param {object} params Theme params
* @param {object} params.id Theme identifier.
* @param {Function} [cb] Callback function.
* @returns {Promise|undefined}
*/
getTheme(...args) {
return this.brandingThemes.get(...args);
}

/**
* Get the default new universal login theme.
*
* @example
* management.branding.getDefaultTheme(function (err, theme) {
* if (err) {
* // Handle error.
* }
*
* // Theme
* console.log(theme);
* });
* @param {Function} [cb] Callback function.
* @returns {Promise|undefined}
*/
getDefaultTheme(...args) {
return this.brandingThemes.get(...[{ id: 'default' }].concat(args));
}

/**
* Create a new theme.
*
* @example
* management.branding.createTheme(data, function (err, theme) {
* if (err) {
* // Handle error.
* }
*
* // Theme created.
* console.log(theme);
* });
* @param {object} data theme data object.
* @param {Function} [cb] Callback function.
* @returns {Promise|undefined}
*/
createTheme(...args) {
return this.brandingThemes.create(...args);
}

/**
* Update a theme.
*
* @example
* var data = THEME_OBJ;
* var params = { id: THEME_ID };
*
* management.branding.updateTheme(params, data, function (err, theme) {
* if (err) {
* // Handle error.
* }
*
* // Theme updated.
* console.log(theme);
* });
* @param {object} params Theme parameters.
* @param {object} params.id Theme identifier.
* @param {object} data Updated theme data.
* @param {Function} [cb] Callback function.
* @returns {Promise|undefined}
*/
updateTheme(...args) {
return this.brandingThemes.patch(...args);
}

/**
* Delete a theme.
*
* @example
* var params = { id: THEME_ID };
*
* management.branding.deleteTheme(params, function (err) {
* if (err) {
* // Handle error.
* }
*
* // Theme deleted.
* });
* @param {object} params Theme parameters.
* @param {object} params.id Theme identifier.
* @param {Function} [cb] Callback function.
* @returns {Promise|undefined}
*/
deleteTheme(...args) {
return this.brandingThemes.delete(...args);
}
}

module.exports = BrandingManager;
74 changes: 74 additions & 0 deletions test/data/theme.json
@@ -0,0 +1,74 @@
{
"borders": {
"button_border_radius": 3,
"button_border_weight": 1,
"buttons_style": "rounded",
"input_border_radius": 3,
"input_border_weight": 1,
"inputs_style": "rounded",
"show_widget_shadow": true,
"widget_border_weight": 0,
"widget_corner_radius": 5
},
"colors": {
"body_text": "#1e212a",
"error": "#d03c38",
"header": "#1e212a",
"icons": "#65676e",
"input_background": "#ffffff",
"input_border": "#c9cace",
"input_filled_text": "#000000",
"input_labels_placeholders": "#65676e",
"links_focused_components": "#635dff",
"primary_button": "#de7878",
"primary_button_label": "#ffffff",
"secondary_button_border": "#c9cace",
"secondary_button_label": "#1e212a",
"success": "#13a688",
"widget_background": "#ffffff",
"widget_border": "#c9cace"
},
"fonts": {
"body_text": {
"bold": false,
"size": 87.5
},
"buttons_text": {
"bold": false,
"size": 100
},
"font_url": "",
"input_labels": {
"bold": false,
"size": 100
},
"links": {
"bold": true,
"size": 87.5
},
"links_style": "normal",
"reference_text_size": 16,
"subtitle": {
"bold": false,
"size": 87.5
},
"title": {
"bold": false,
"size": 150
}
},
"page_background": {
"background_color": "#000000",
"background_image_url": "",
"page_layout": "center"
},
"widget": {
"header_text_alignment": "center",
"logo_height": 52,
"logo_position": "center",
"logo_url": "",
"social_buttons_layout": "bottom"
},
"themeId": "themeid1",
"displayName": "default theme"
}