UNPKG

bitpay-sdk

Version:

Complete version of the NodeJS library for the new cryptographically secure BitPay API

51 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LedgerClient = void 0; const Facade_1 = require("../Facade"); const BitPayExceptionProvider_1 = require("../Exceptions/BitPayExceptionProvider"); class LedgerClient { constructor(bitPayClient, tokenContainer) { this.bitPayClient = bitPayClient; this.tokenContainer = tokenContainer; } /** * Retrieve a list of ledgers using the merchant facade. * * @return A list of Ledger objects populated with the currency and current balance of each one. * @throws BitPayApiException BitPayApiException class * @throws BitPayGenericException BitPayGenericException class */ async getLedgers() { const params = { token: this.tokenContainer.getToken(Facade_1.Facade.Merchant) }; const result = await this.bitPayClient.get('ledgers', params, true); try { return JSON.parse(result); } catch (e) { BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Ledger', e.message); throw new Error(); } } /** * Retrieve a list of ledgers by params * * @param currency * @param params * @returns ledgers * @throws BitPayApiException BitPayApiException class * @throws BitPayGenericException BitPayGenericException class */ async getEntries(currency, params) { params['token'] = this.tokenContainer.getToken(Facade_1.Facade.Merchant); const result = await this.bitPayClient.get('ledgers/' + currency, params, true); try { return JSON.parse(result); } catch (e) { BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Ledger', e.message); throw new Error(); } } } exports.LedgerClient = LedgerClient; //# sourceMappingURL=LedgerClient.js.map