Skip to content

Latest commit

 

History

History
94 lines (71 loc) · 2.19 KB

client.md

File metadata and controls

94 lines (71 loc) · 2.19 KB

The KrossClint class is a client for interacting with the Kross API's auth-related endpoints and other instances/clients like loans, investments and inquiry. It extends the KrossClientBase class and provides methods for login and refreshing tokens.

Table of Contents


Constructor

Methods
- login()
- updateAuthToken()

Hooks
- useAuthHooks()

Constructor

The KrossClient class constructor accepts a KrossClientOptions object as its only argument. This object is used to configure the underlying Axios instance that makes the HTTP requests to the Kross API.

import { KrossClient } from 'kross-sdk';

const krossClient = new KrossClient({
  baseURL: 'https://api.kross.com',
  accessId: 'afsdfsdfjsdfsd',
  secretKey: 'sdfsdfsdfsdfsdf',
});

Methods

- login()
The login() method is used to login.

krossClient.login({
  'abcd@gmail.com',
  'abcd1234',
   true,
});
Arguments

keyid - email or business registeration number that user used while creating account
password - as name suggest
refreshExpiresIn (Optional) - refreshExpiresIn to set token expiry in milli seconds

Return a response on success

{
  "token": "string",
  "refresh": "string"
}

- updateAuthToken()
The updateAuthToken() method is used to refresh tokens.

client.updateAuthToken();

Return response on success

{
  "token": "string"
}

Hooks

- useAuthHooks()
The useAuthHooks() method is used to return the react-query hooks for useLogin() and updateAuthToken() methods.

const {useLogin} = krossClient.useAuthHooks();
const {mutate: login, status} = useLogin();

login({
  keyid: 12323554646456,
  passoword: 132323555
}, {
  onSuccess : response => {},
  onError: error => {}
})

Return a response with react-query hooks for useLogin() and updateAuthToken() methods.