UNPKG

bitpay-sdk

Version:

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

71 lines 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TokenContainer = void 0; const Facade_1 = require("./Facade"); const BitPayExceptionProvider_1 = require("./Exceptions/BitPayExceptionProvider"); class TokenContainer { constructor(tokens) { this.data = new Map(); if (tokens !== undefined) { Object.keys(tokens).forEach((key) => { this.add(key, String(tokens[key])); }); } } /** * * @param key * @returns string * @throws BitPayGenericException BitPayGenericException class */ getToken(key) { if (!this.data.has(key)) { BitPayExceptionProvider_1.BitPayExceptionProvider.throwGenericExceptionWithMessage('There is no token for the specified key : ' + key); throw new Error(); } const value = this.data.get(key); if (value === undefined) { throw new Error(); } return value; } /** * * @param token */ addPos(token) { this.data.set(Facade_1.Facade.Pos, token); } /** * * @param token */ addMerchant(token) { this.data.set(Facade_1.Facade.Merchant, token); } /** * * @param token */ addPayout(token) { this.data.set(Facade_1.Facade.Payout, token); } /** * * @param facade * @returns */ isTokenExist(facade) { return this.data.has(facade); } /** * * @param facade * @param token */ add(facade, token) { this.data.set(facade, token); } } exports.TokenContainer = TokenContainer; //# sourceMappingURL=TokenContainer.js.map