@softledger/node v0.3.0
Softledger TypeScript SDK 0.2.0
Welcome to the Softledger SDK documentation. This guide will help you get started with integrating and using the Softledger SDK in your project.
Versions
- API version:
1.0.0
- SDK version:
0.2.0
About the API
SoftLedger General Ledger Accounting API
Table of Contents
Setup & Configuration
Supported Language Versions
This SDK is compatible with the following versions: TypeScript >= 4.8.4
Installation
To get started with the SDK, we recommend installing using npm
:
npm install @softledger/node
Authentication
Access Token Authentication
The Softledger API uses an Access Token for authentication.
This token must be provided to authenticate your requests to the API.
Setting the Access Token
When you initialize the SDK, you can set the access token as follows:
const sdk = new Softledger({ token: 'YOUR_TOKEN' });
If you need to set or update the access token after initializing the SDK, you can use:
const sdk = new Softledger();
sdk.token = 'YOUR_TOKEN';
OAuth Authentication
The Softledger API uses OAuth for authentication.
You need to provide the OAuth parameters when initializing the SDK.
const sdk = new Softledger({ clientId: 'CLIENT_ID', clientSecret: 'CLIENT_SECRET' });
If you need to set or update the OAuth parameters after the SDK initialization, you can use:
const sdk = new Softledger();
sdk.clientId = 'CLIENT_ID';
sdk.clientSecret = 'CLIENT_SECRET';
Setting a Custom Timeout
You can set a custom timeout for the SDK's HTTP requests as follows:
const softledger = new Softledger({ timeout: 10000 });
Sample Usage
Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
import { AddressFilter, FilterOptions, Softledger } from '@softledger/node';
(async () => {
const softledger = new Softledger({
token: 'YOUR_TOKEN',
});
const equals = 'fugiat ';
const not = 'sint in eu tem';
const gt = 'culpa pariatu';
const gte = 'nisi ea D';
const lt = 'conseq';
const lte = 'non q';
const filterOptionsIn = 'irure anim al';
const filterOptions: FilterOptions = {
equals: equals,
contains: 'contains',
not: not,
gt: gt,
gte: gte,
lt: lt,
lte: lte,
in: [filterOptionsIn],
isNull: true,
};
const addressFilter: AddressFilter = {
_id: filterOptions,
label: filterOptions,
line1: filterOptions,
line2: filterOptions,
city: filterOptions,
state: filterOptions,
zip: filterOptions,
country: filterOptions,
isDefault: filterOptions,
isVerified: filterOptions,
createdAt: filterOptions,
updatedAt: filterOptions,
CustomerId: filterOptions,
VendorId: filterOptions,
};
const addressesSearchFilterType = 'all';
const addressesSearchOrder = '_id:ASC';
const { data } = await softledger.addresses.addressesSearch({
filter: addressFilter,
filterType: addressesSearchFilterType,
cursor: 'cursor',
limit: 25,
order: addressesSearchOrder,
});
console.log(data);
})();
Services
The SDK provides various services to interact with the API.
Models
The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.