UNPKG

blockchain-wallet-ts

Version:

TypeScript wrapper for Blockchain.info's wallet API

26 lines (25 loc) 784 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class ApiClient { /** * API Client constructor. */ constructor(config) { this.http = config.http; this.apiKey = config.apiKey; } /** * Attach default request parameters. */ requestParams(params) { return Object.assign(Object.assign(Object.assign({}, this.baseParams), { api_code: this.apiKey }), params); } /** * Send an API request. */ request(path, params) { const endpoint = this.basePath.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, ''); return this.http.get(endpoint, { params: this.requestParams(params) }).then(({ data }) => data); } } exports.default = ApiClient;