@pagali/client
v2.1.19
Published
![linecov](https://production-pagali-assets.s3.amazonaws.com/badges/libs/public/pagali-client/linecovbadge.svg) ![stmtcov](https://production-pagali-assets.s3.amazonaws.com/badges/libs/public/pagali-client/statementcovbadge.svg) ![branchcov](https://produ
Downloads
95
Readme
@pagali/client
Package containing SDKs to simplify requests to Pagali API
Usage:
/* Your Api Key and API Url */
const clientConfig = {
accessToken: '<your_api_key>',
url: '<api_url>',
};
const client = new PagaliClient(clientConfig);
const merchants = await client.management.merchants.get({}, { params: { 'page[number]': 1, 'page[size]': 5 } });
The client also comes with a configurable cache layer that uses Redis to store responses from GET requests. See the example below to configure and use it:
/* Your Api Key and API Url */
const clientConfig = {
accessToken: '<your_api_key>',
url: '<api_url>',
};
/* Your Redis Config */
const cacheConfig = {
host: '<your_redis_host>',
port: '<your_redis_port>',
db: '<your_redis_db_number>',
password: '<your_redis_password>',
keyPrefix: '<your_custom_key_prefix>',
};
const client = new PagaliClient(clientConfig, cacheConfig);
/* Specify the ttl value (in seconds) to make use of redis for storing/retrieving the result */
const merchants = await client.management.merchants.get({}, { params: { 'page[number]': 1, 'page[size]': 5 } });
const firstMerchantId = merchants[0].id;
const merchant = await client.management.merchants.getOne(firstMerchantId, {}, { cacheTtlSeconds: 60 });
/* Close the underlying redis connection */
client.shutdown();