Skip to content

Latest commit

 

History

History
470 lines (402 loc) · 13.9 KB

user.md

File metadata and controls

470 lines (402 loc) · 13.9 KB

User class The User class is a client for interacting with the Kross API's user-related endpoints. It extends the KrossClientBase class and provides methods for checking user information, user register/unregister and user virtual account information.

Table of Contents


Constructor

Methods
- userData()
- getVirtualAccCertificate()
- checkVirtualAccount()
- registerMember()
- unRegisterMemeber()
- releaseDepositControl()
- accountData()
- userDataUpdate()
- passwordCheck()
- userAccountLogs()
- kftcBalance()
- userNoteLogs()
- portfolio()

Hooks
- useUserHooks()

Constructor

The User 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 { User } from 'kross-sdk';

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

Methods

- userData()
The userData() method is used to get user details.

user.userData(
  {
  userQuery :{
    take: '1',
    skip: '0'
     }, 
   enabled
   });
Arguments

select (optional): A string that specifies which columns to select in the query. If not provided, all columns will be selected.
skip (optional): A string that specifies the number of rows to skip in the result set. If not provided, no rows will be skipped.
take (optional): A string that specifies the maximum number of rows to return in the result set. If not provided, all rows will be returned.
order (optional): A string that specifies the sorting order for the result set. It can be used to sort data based on one or more columns in ascending or descending order. If not provided, the result set will not be sorted.
filter (optional): A string that specifies the filter conditions to apply to the result set. It can be used to select rows that meet certain criteria based on the values of one or more columns. If not provided, no filters will be applied.
join (optional): A string that specifies the join conditions to use when querying data from multiple tables. It can be used to retrieve data from related tables by specifying how the tables are related to each other. If not provided, no joins will be performed.
enabled (0ptional): enabled to true means make request to backend false means don't make request to backend

Return an array of users data response on success

[{     
      "id": "string",
      "memberNo": "string",
      "keyid": "string",
      "name": "string",
      "memberType": "string",
      "state": "string",
      "nickName": "string",
      "birthday": "string",
      "ssn": "string",
      "email": "string",
      "mobile": "string",
      "zip": "string",
      "address1": "string",
      "address2": "string",
      "joinPath": "string",
      "kftcType": "string",
      "phoneVerified": true,
      "idCardVerified": true,
      "bankAccountVerified": true,
      "financialProvider": true,
      "isCorp": true,
      "fdsExcept": true,
      "depositControl": true,
      "notifyOnNewProducts": true,
      "notifyOnRepayments": true,
      "retireAt": "2023-03-30T10:55:44.490Z"
}]

- getVirtualAccCertificate()
The getVirtualAccCertificate() method is used to get virtual account certificate.

user.getVirtualAccCertificate();

Return a response on success

{
  url: string
}

- checkVirtualAccount()

The checkVirtualAccount() method is used to get virtual account details.

user.checkVirtualAccount();

Return a response on success

{
    insertDt: string,
    depoctlYn: string,
    useStatus: string,
    vaccntOwnerName: string,
    depoctlDepoBankAccNo: string
}

- registerMember()
The registerMember() method is used to register a user.

user.registerMember({
    keyid: 124;
    password: 'abcdefghsd';
    password2: 'abcdefghsd';
});
Arguments

keyid - email or business resgiteration number. password - password (length must be >= 8).
password2 - confirm password
isBusiness(optional) - in case if user registering is a business
isBorrower(optional) - in case user registering is borrower
email(optional) - email
corpRegNo(optional) - corporation resgiteration number
name(optional) - name of user/corporation/business

Return a response on success

{
  token: string
}

- unRegisterMemeber()
The unRegisterMemeber() method is used to unregister user.

user.unRegisterMemeber();

Return a response on success

{
  data: {},
  okay: boolean,
  message: string | undefined
}

- releaseDepositControl()
The releaseDepositControl() method is used unlock deposit control (that mean to allow to deposit any bank account).

user.releaseDepositControl({
    idempotency_key
});

Return a response on success

{
  vaccntNo: string
}

- accountData()
The accountData() method is used to get user account data.

user.accountData(
  {
    accountQuery : {
      limit: '1',
      offset: '0'
    },
    enabled: true
  }
{
 
});
Arguments

query - query for filtering user data.
limit, offset : pagination props
sort_by: order lets you sort users data based on fields

Return an array of user data in response on success

[{
    "available_withdraw_amount": 0,
    "amount": 0,
    "pending_withdrawal": 0,
    "pending_investment": 0,
    "pending_etc": 0,
    "impossible_withdraw_sub_deposit_amount": 0,
    "bank_code": "string",
    "account_no": "string",
    "v_account_no": "string",
    "v_bank_code": "string"
}]

- userDataUpdate()
The userDataUpdate() method is used to update user data.

user.userDataUpdate({
 name: 'updatedName'
});
Arguments

password: A string representing the user's updated password.
email: A string representing the user's updated email address.
name: A string representing the user's updated name.
memberType: A string representing the user's updated membership type.
kftcType: A string representing the user's updated KFTC type.
state: A string representing the user's updated state.
nickName: A string representing the user's updated nickname.
mobile: A string representing the user's updated mobile phone number.
zip: A string representing the user's updated ZIP code.
address1: A string representing the user's updated address line 1.
address2: A string representing the user's updated address line 2.
joinPath: A string representing the user's updated join path.
retireAt: A string representing the user's updated retirement date.
expireDate: A string representing the user's updated expiration date.
fdsExcept: A boolean representing whether the user has opted out of FDS (Financial Data Services).
depositControl: A boolean representing whether the user has enabled deposit control.
notifyOnNewProducts: A boolean representing whether the user wants to be notified of new products.
notifyOnRepayments: A boolean representing whether the user wants to be notified of repayments.

Return updated user data in response on success

{
  "id": "string",
  "memberNo": "string",
  "keyid": "string",
  "name": "string",
  "memberType": "string",
  "state": "string",
  "nickName": "string",
  "birthday": "string",
  "ssn": "string",
  "email": "string",
  "mobile": "string",
  "zip": "string",
  "address1": "string",
  "address2": "string",
  "joinPath": "string",
  "kftcType": "string",
  "phoneVerified": true,
  "idCardVerified": true,
  "bankAccountVerified": true,
  "financialProvider": true,
  "isCorp": true,
  "fdsExcept": true,
  "depositControl": true,
  "notifyOnNewProducts": true,
  "notifyOnRepayments": true,
  "retireAt": "2023-03-30T10:35:31.908Z"
}

- passwordCheck()
The passwordCheck() method is check validate password before doing secured manipulation.

user.passwordCheck({
 password: '1234567890'
});
Arguments

password - password to validate the user

Return response on success

{
    status: 0
}

- userAccountLogs()
The userAccountLogs() method is used to get user account logs

user.userAccountLogs({
 take: '1',
 skip: '0'
});
Arguments

select (optional): A string that specifies which columns to select in the query. If not provided, all columns will be selected.
skip (optional): A string that specifies the number of rows to skip in the result set. If not provided, no rows will be skipped.
take (optional): A string that specifies the maximum number of rows to return in the result set. If not provided, all rows will be returned.
order (optional): A string that specifies the sorting order for the result set. It can be used to sort data based on one or more columns in ascending or descending order. If not provided, the result set will not be sorted.
filter (optional): A string that specifies the filter conditions to apply to the result set. It can be used to select rows that meet certain criteria based on the values of one or more columns. If not provided, no filters will be applied.
join (optional): A string that specifies the join conditions to use when querying data from multiple tables. It can be used to retrieve data from related tables by specifying how the tables are related to each other. If not provided, no joins will be performed.

Return response on success

{
"userAccountLogs": [
    {
      "id": 0,
      "userId": 0,
      "saveDate": "string",
      "bankCode": "string",
      "accountNo": "string",
      "vBankCode": "string",
      "vAccountNo": "string",
      "amount": 0,
      "pendingWithdrawal": 0,
      "pendingInvestment": 0,
      "pendingEtc": 0,
      "createdAt": "2023-03-30T10:55:03.973Z",
      "updatedAt": "2023-03-30T10:55:03.973Z"
    }
  ]
}

- userNoteLogs()
The userNoteLogs() method is used to get user notes log.

user.userNoteLogs({
 take: '1',
 skip: '0'
});
Arguments

select (optional): A string that specifies which columns to select in the query. If not provided, all columns will be selected.
skip (optional): A string that specifies the number of rows to skip in the result set. If not provided, no rows will be skipped.
take (optional): A string that specifies the maximum number of rows to return in the result set. If not provided, all rows will be returned.
order (optional): A string that specifies the sorting order for the result set. It can be used to sort data based on one or more columns in ascending or descending order. If not provided, the result set will not be sorted.
filter (optional): A string that specifies the filter conditions to apply to the result set. It can be used to select rows that meet certain criteria based on the values of one or more columns. If not provided, no filters will be applied.
join (optional): A string that specifies the join conditions to use when querying data from multiple tables. It can be used to retrieve data from related tables by specifying how the tables are related to each other. If not provided, no joins will be performed.

Return response on success

{
"userNotesLogs": [
    {
       "id": 0,
      "userId": 0,
      "saveDate": "string",
      "noteCount": 0,
      "principal": 0,
      "repaidPrincipal": 0,
      "remainPrincipal": 0,
      "data": {},
      "createdAt": "2023-03-30T10:53:41.936Z",
      "updatedAt": "2023-03-30T10:53:41.936Z"
    }
  ]
}

- kftcBalance()
The kftcBalance() get how much borrower loan amount.

user.kftcBalance();

Return response on success

{
    data: {
         "rsp_code": "string",
         "rsp_message": "string",
        "borrower_info": {},
        "in_progress_result_info": {},
        "complete_result_info": {}
    }
}

- portfolio()
The portfolio() method is used to get user portfolio data.

user.portfolio({
  enabled: true
});

Return a response on success

{
    depositsAmount: number;
    notesAmount: number;
    totalAssetsAmount: number;
    totalNotes: number;
    totalExpectedReturn: number;
    returnAfterTax: number;
    actualReturn: number;
    totalTodayInvestment: number;
    totalInvestmentAmount: number;
    totalTodayRepayment: number;
    totalRepaymentAmount: number;
    notes: any[];
}

Hooks

- useUserHooks()
The useUserHooks() method is used to return the react-query hooks for myPageData(), userData(), totalAssets() and methods above.

const {myPageData} = user.useUserHooks();
const {data, isFetching} = myPageData();

Return a response with react-query hooks for myPageData(), userData(), totalAssets() and methods above.

myPageData - myPageData provides profile overview of the user like repayments, account and investments analysis totalAssets - totalAssets gives overview and data of accounts and money that can be invested/withdrawn