diff --git a/mkdocs.yml b/mkdocs.yml index 84182a2..ad43cb0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,6 +13,7 @@ nav: - Using the Package: - APIs & Components: - getIntegration: using-the-package/apis-&-components/get-integration.md + - getRoles: using-the-package/apis-&-components/get-roles.md - Module Exports: using-the-package/module-exports.md - TypeScript Types: using-the-package/typescript-types.md - Troubleshooting: using-the-package/troubleshooting.md diff --git a/techdocs/docs/using-the-package/apis-&-components/get-integration.md b/techdocs/docs/using-the-package/apis-&-components/get-integration.md index f0db2e1..bcbbdc3 100644 --- a/techdocs/docs/using-the-package/apis-&-components/get-integration.md +++ b/techdocs/docs/using-the-package/apis-&-components/get-integration.md @@ -36,7 +36,7 @@ export const getProjectName = async () => { ### Response Type -The type `GetIntegrationResponse` of `Promise`. +The type `GetIntegrationResponse` of `Promise`: ```TypeScript { diff --git a/techdocs/docs/using-the-package/apis-&-components/get-roles.md b/techdocs/docs/using-the-package/apis-&-components/get-roles.md new file mode 100644 index 0000000..a752203 --- /dev/null +++ b/techdocs/docs/using-the-package/apis-&-components/get-roles.md @@ -0,0 +1,54 @@ +# getRoles + +The `getRoles` function is used to get role details from your integration in Common Hosted Single Sign-on service. + +!!! warning "Reminder" + This function is asynchronous and must be awaited in order to get a response. + +## Import + +```JavaScript +// ESModule Syntax (preferred) +import { getRoles } from "@bcgov/citz-imb-sso-css-api"; + +// CommonJS Syntax +const { getRoles } = require('@bcgov/citz-imb-sso-css-api'); +``` + +## Usage + +A basic example of using the `getRoles` function to get an array of role names. + +```JavaScript +import { getRoles } from "@bcgov/citz-imb-sso-css-api"; + +export const getRoleList = async () => { + const roles = await getRoles(); + return roles.data.map((role) => role.name); +} +``` + +## TypeScript Type + +```TypeScript +() => Promise; +``` + +### Response Type + +The type `RolesArrayResponse` of `Promise`: + +```TypeScript +{ + data: RoleResponse[]; +} +``` + +The type `RoleResponse`: + +```TypeScript +{ + name: string; + composite: boolean; +} +```