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.

25 lines (24 loc) 1.32 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const models_1 = require("../models"); const Client_1 = __importDefault(require("./Client")); class InsightsClient extends Client_1.default { constructor() { super(...arguments); this._path = '/open-finances/insights'; } getAnalysis(userId, insightsOptions) { const { accountIds, dateFrom, dateTo } = insightsOptions || {}; const uri = `${this._path}/analysis?userId=${userId}${accountIds ? `&accountIds=${accountIds}` : ''}${dateFrom ? `?dateFrom=${dateFrom}` : ''}${dateTo ? `?dateTo=${dateTo}` : ''}`; return this.apiCore.doGet(uri, (response) => response.data.map((analysis) => new models_1.Analysis(analysis))); } getResume(userId, insightsOptions) { const { accountIds, dateFrom, dateTo } = insightsOptions || {}; const uri = `${this._path}/resume?userId=${userId}${accountIds ? `&accountIds=${accountIds}` : ''}${dateFrom ? `?dateFrom=${dateFrom}` : ''}${dateTo ? `?dateTo=${dateTo}` : ''}`; return this.apiCore.doGet(uri, (response) => new models_1.Resume(response)); } } exports.default = InsightsClient;