UNPKG

bitpay-sdk

Version:

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

71 lines 2.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SettlementClient = void 0; const index_1 = require("../index"); const BitPayExceptionProvider_1 = require("../Exceptions/BitPayExceptionProvider"); class SettlementClient { constructor(bitPayClient, tokenContainer) { this.bitPayClient = bitPayClient; this.tokenContainer = tokenContainer; } /** * Retrieves a summary of the specified settlement. * * @param settlementId Settlement Id * @returns Settlement * @throws BitPayApiException BitPayApiException class * @throws BitPayGenericException BitPayGenericException class */ async get(settlementId) { const params = { token: this.tokenContainer.getToken(index_1.Facade.Merchant) }; try { const result = await this.bitPayClient.get('settlements/' + settlementId, params, true); return JSON.parse(result); } catch (e) { BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Settlement', e.message); throw new Error(); } } /** * Retrieves settlement reports for the calling merchant filtered by query. * * @param params * @returns Settlement[] * @throws BitPayApiException BitPayApiException class * @throws BitPayGenericException BitPayGenericException class */ async getSettlements(params) { params['token'] = this.tokenContainer.getToken(index_1.Facade.Merchant); const result = await this.bitPayClient.get('settlements', params, true); try { return JSON.parse(result); } catch (e) { BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Settlement', e.message); throw new Error(); } } /** * Gets a detailed reconciliation report of the activity within the settlement period. * * @param settlementId * @param token * @returns Settlement * @throws BitPayApiException BitPayApiException class * @throws BitPayGenericException BitPayGenericException class */ async getReconciliationReport(settlementId, token) { const params = { token: token }; const result = await this.bitPayClient.get('settlements/' + settlementId + '/reconciliationReport', params, true); try { return JSON.parse(result); } catch (e) { BitPayExceptionProvider_1.BitPayExceptionProvider.throwDeserializeResourceException('Settlement', e.message); throw new Error(); } } } exports.SettlementClient = SettlementClient; //# sourceMappingURL=SettlementClient.js.map