import * as ReferenceDataAPI from './apis/referenceData' ; import * as StocksAPI from './apis/stocks' ; /**
 * This class handles communication with the IEX API in a type-safe and flexible
 * way. It is usable in Browser, React Native, and NodeJS contexts.
 */ export default class IEXClient { private fetchFunction : typeof fetch ; private httpsEndpoint : string ; param fetchFunction param httpsEndpoint public constructor ( fetchFunction , httpsEndpoint = 'https://api.iextrading.com/1.0' ) { this . fetchFunction = fetchFunction ; this . httpsEndpoint = httpsEndpoint ; this . request = this . request . bind ( this ) ; } example see https param path public request ( path ) { return this . fetchFunction ( `${ this . httpsEndpoint }/${ path }` ) . then ( res => { const contentType = res . headers . get ( 'content-type' ) ; if ( contentType === null ) { return null ; } else if ( contentType . includes ( 'application/json' ) ) { return res . json ( ) ; } else { return res . text ( ) ; } } ) ; } see https public symbols ( ) { return this . request ( '/ref-data/symbols' ) ; } see https param stockSymbol param displayPercent public stockQuote ( stockSymbol , displayPercent ? ) { const queryString = displayPercent ? '?displayPercent=true' : '' ; return this . request ( `/stock/${ stockSymbol }/quote${ queryString }` ) ; } see https param stockSymbol param range public stockChart ( stockSymbol , range ) { return this . request ( `/stock/${ stockSymbol }/chart/${ range }` ) ; } see https param stockSymbol public stockOpenClose ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/open-close` ) ; } see https param stockSymbol public stockPrevious ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/previous` ) ; } see https param stockSymbol public stockCompany ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/company` ) ; } see https param stockSymbol public stockKeyStats ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/stats` ) ; } see https param stockSymbol public stockPeers ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/peers` ) ; } see https param stockSymbol public stockRelevant ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/relevant` ) ; } see https param stockSymbol param range public stockNews ( stockSymbol , range ? ) { if ( range ) { return this . request ( `/stock/${ stockSymbol }/news/last/${ range }` ) ; } else { return this . request ( `/stock/${ stockSymbol }/news` ) ; } } see https param stockSymbol public stockFinancials ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/financials` ) ; } see https param stockSymbol public stockEarnings ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/earnings` ) ; } see https param stockSymbol param range public stockDividends ( stockSymbol , range ) { return this . request ( `/stock/${ stockSymbol }/dividends/${ range }` ) ; } see https param stockSymbol param range public stockSplits ( stockSymbol , range ) { return this . request ( `/stock/${ stockSymbol }/splits/${ range }` ) ; } see https param stockSymbol public stockLogo ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/logo` ) ; } see https param stockSymbol return public stockPrice ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/price` ) ; } see https param stockSymbol public stockDelayedQuote ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/price` ) ; } see https param list param displayPercent public stockMarketListTopTen ( list , displayPercent ? ) { const queryString = displayPercent ? '?displayPercent=true' : '' ; return this . request ( `/stock/market/list/${ list }${ queryString }` ) ; } see https param stockSymbol public stockEffectiveSpread ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/effective-spread` ) ; } see https param stockSymbol public stockVolumeByVenue ( stockSymbol ) { return this . request ( `/stock/${ stockSymbol }/volume-by-venue` ) ; } }