UNPKG

cobinhood-rx

Version:

CobinhoodRx is a rxjs node wrapper for the CobinhoodRx Api.

29 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Model = require("../../Model"); const DataKeys_1 = require("../../Enum/DataKeys"); const Observable_1 = require("rxjs/Observable"); const HttpMethod_1 = require("../../Enum/HttpMethod"); const Validator_1 = require("../../Helpers/Validator"); class ChartAPI { constructor(transportManager, config) { this.transportManager = transportManager; this.apiVersion = config.apiVersion; this.baseUrl = config.baseUrl; this.baseEndPoint = `${this.baseUrl}${this.apiVersion}/chart`; } getCandles(market, timeframe, startPeriod, endPeriod) { return this.transportManager.publicRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/candles/${Validator_1.default.market(market)}`, { start_time: (startPeriod) ? startPeriod.valueOf() : undefined, end_time: (endPeriod) ? endPeriod.valueOf() : undefined, timeframe }) .map(data => this.transportManager.processResponse(data, Model.Candle, DataKeys_1.DataKeyValues.Candles)) .catch(this.catchErrorHandler); } catchErrorHandler(res) { return Observable_1.Observable.throw(res); } } exports.ChartAPI = ChartAPI; //# sourceMappingURL=ChartAPI.js.map