1.0.2 • Published 5 months ago

accrue-sdk v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

Logo

Accrue TypeScript Library

Accrue is a TypeScript library that provides convenient access to the Accrue API for managing various financial operations.

Installation

Install accrue with npm

  npm install accrue-sdk

Usage/Examples

  • Initialization
import { Accrue } from 'accrue-sdk';

const accrue = new Accrue({
  // configuration options
}, 'your-secret-key');

// OR
const accrue = new Accrue() // assuming you have a .env file with ACCRUE_SECRET_KEY variable
  • Get Account Details
async function getAccountDetails() {
  try {
    const details = await accrue.account.getAccountDetails();
    console.log('Account Balance:', details.accountBalance);
    console.log('Account ID:', details.id);
    console.log('Account address:', details.depositAddress);
  } catch (error: any) {
    console.error('Error:', error.message);
  }
}

getAccountDetails();

For more examples see the examples folder

API Reference

Accrue Class

Initialize the Accrue SDK with optional configuration options and a secret key.

constructor(config?: SdkOptions, secretKey?: string): Accrue
interface SdkOptions  {
    errorHandler?: IErrorHandler;
    deserializer?: IResponseDeserializer;
    responseValidator?: IResponseValidation;
}

interface IErrorHandler {
    handleErrors(error: any): Promise<boolean>;
}

interface IResponseDeserializer { 
    deserialize<TReturnType>(action:string, response: AxiosResponse): Promise<TReturnType>;
}

interface IResponseValidation {
    validateResponse: (response: AxiosResponse) => Promise<any | null>;
}

Account

Get account details.

getAccountDetails(): Promise<IAccount>

interface IAccount {
    id: string
    accountBalance: number | null
    depositAddress: string | null
}

See the examples section for more usage examples.

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

License

This library is licensed under the MIT License - see the LICENSE file for details.

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

2 years ago