@ubti/diligence-fabric-sdk
v0.8.2
Published
SDK for Diligence Framework - Multi Tenant
Downloads
134
Readme
DiligenceFabricClient SDK
The DiligenceFabricClient SDK provides a client library for interacting with the DiligenceFabric API. This README document will guide you through the installation process, usage instructions, error handling, and provide sample code for using the SDK.
Table of Contents
Installation
You can install the DiligenceFabricClient SDK using npm or yarn:
npm install @ubti/diligence-fabric-sdk
Usage
To use the DiligenceFabricClient SDK, follow the steps below:
Import the necessary classes from the SDK
import { DiligenceFabricClient, UserInfo } from 'diligence-fabric-sdk';
Setup the configuration using
config/default.json
or.env
Note: You can refer
env.sample
orconfig/default.json
# Required DF_TENANT_ID= DF_APP_ID= # Optional DF_API_URL= DF_API_VERSION=
Create an instance of the DiligenceFabricClient class
/* Please get the above config from environment variables based on the technology that you use like dotenv, etc.. Its the most recommended way */ const client = new DiligenceFabricClient();
Set the authenticated user token
a. You can use the AuthService to login and getToken
const resp = client.getAuthService().login("**your auth request model**)
b. Now get the access token from the response and set token in the SDK
const authUser = { Token: 'your_auth_token', }; client.setAuthUser(authUser);
Access the services and perform actions
const applicationService = client.getApplicationService(); // Use the applicationService to interact with the Application service const userService = client.getUserService(); // Use the userService to interact with the User service const menuService = client.getMenuService(); // Use the menuService to interact with the Menu service const authService = client.getAuthService(); // Use the authService for authentication-related operations
Note: Ensure that you have set the authenticated user token using setAuthUser() before accessing the services.
Error Handling
If the user token is not set before accessing the services, an error will be thrown. To handle this error, wrap the code in a try-catch block:
try {
// Access the services and perform actions here
} catch (error) {
// Handle the error here
console.error('Error:', error);
}
Examples
Here are some samples of the DiligenceFabricClient SDK:
Authentication
const authService = client.getAuthService(); try { const loginResponse = await authService.login(); console.log('Auth Response:', loginResponse); } catch (error) { console.error('Error in Login:', error); }
Get All application menu based on the user token
const appRoleService = client.getApplicationRoleService(); try { const response = await appRoleService.getAllAppMenus(); console.log('Response:', loginResponse); } catch (error) { console.error('Error in Getting All App Menus:', error); }
Feel free to explore the SDK and its available methods to suit your specific use cases.
To publish to NPM registry
Use the following command
npm publish @ubti/diligence-fabric-sdk --access=public
Give a Star! :star:
If you liked the project or if this project helped you, please give a star. And also please fork this repository and send us pull-requests. If you find any problem please open issue.
Did the sample not work for you as expected? Did you encounter issues trying this sample? Then please reach out to us using the GitHub Issues page.
Feedback
If you have any feedback, please reach out to us at [email protected]