UNPKG

@nepse-helper/core

Version:

A helper library for NEPSE

32 lines (31 loc) 1.21 kB
import { Auth, NepseData, Security } from "./api"; import { TokenHelper } from "./helpers/token.helper"; export * from "./interfaces/api"; class Nepse { _auth; _nepseData; _security; constructor(auth, nepseData, security) { this._auth = auth; this._nepseData = nepseData; this._security = security; } getMarketStatus = async () => this._auth.refreshToken().then(() => this._nepseData.getMarketOpen()); getSecurityList = async () => this._auth.refreshToken().then(() => this._security.getSecurityList()); getTodayPrice = async (page = 0, pageSize = 500) => this._auth .refreshToken() .then(() => this._nepseData.getTodayPrice(page, pageSize)); getSecurityDetail = async (symbol) => this._auth .refreshToken() .then(() => this._security.getSecurityDetail(symbol)); } export class NepseBuilder { static async build() { const tokenHelper = await TokenHelper.instance(); const nepseData = new NepseData(); const auth = new Auth(nepseData, tokenHelper); await auth.authenticate(); const security = new Security(); return new Nepse(auth, nepseData, security); } }