UNPKG

open-banking-pfm-sdk

Version:

The Open Banking PFM SDK uses Client classes and with **Promises** to get responses from the Open Banking PFM API in an easier way and structured as data models.

39 lines (38 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiCore = exports.SERVER_URL = void 0; const helpers_1 = require("../helpers"); exports.SERVER_URL = 'http://tecbantest@ec2-3-21-18-54.us-east-2.compute.amazonaws.com:8081/api/v1/'; class ApiCore { constructor(apiSettings) { this.doGet = (url, success) => new Promise((resolve, reject) => { this._apiInstance .get(url) .then((response) => resolve(success(response.data))) .catch((error) => (0, helpers_1.processErrors)(error, reject)); }); this.doPost = (url, body, success) => new Promise((resolve, reject) => { this._apiInstance .post(url, body) .then((response) => resolve(success(response.data))) .catch((error) => (0, helpers_1.processErrors)(error, reject)); }); this.doPut = (url, body, success) => new Promise((resolve, reject) => { this._apiInstance .put(url, body) .then((response) => resolve(success(response.data))) .catch((error) => (0, helpers_1.processErrors)(error, reject)); }); this.doDelete = (url) => new Promise((resolve, reject) => { this._apiInstance .delete(url) .then(() => resolve(true)) .catch((error) => (0, helpers_1.processErrors)(error, reject)); }); this._apiInstance = apiSettings; } get serverUrl() { return this._apiInstance.defaults.baseURL || ''; } } exports.ApiCore = ApiCore;