@ubti/diligence-fabric-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.8.2 • Public • Published

DiligenceFabricClient SDK

TypeScript CSS3

Version npm npm Downloads

NPM

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:

  1. Import the necessary classes from the SDK

    import { DiligenceFabricClient, UserInfo } from 'diligence-fabric-sdk';
  2. Setup the configuration using config/default.json or .env

    Note: You can refer env.sample or config/default.json

    # Required
    DF_TENANT_ID=
    DF_APP_ID=
    # Optional
    DF_API_URL=
    DF_API_VERSION=
  3. 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();
  4. 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);
  5. 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:

  1. Authentication

    const authService = client.getAuthService();
    
    try {
      const loginResponse = await authService.login();
      console.log('Auth Response:', loginResponse);
    } catch (error) {
      console.error('Error in Login:', error);
    }
  2. 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! ⭐

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 nanthakumar.j@ubtiinc.com

Logo

Readme

Keywords

none

Package Sidebar

Install

npm i @ubti/diligence-fabric-sdk

Weekly Downloads

13

Version

0.8.2

License

UNLICENSED

Unpacked Size

381 kB

Total Files

246

Last publish

Collaborators

  • glenaravind
  • nanthakumar.j