const BACKEND_URL = "http://127.0.0.1:5000"; export interface Company { ceo: string; "company name": string; description: string; exchange: string; industry: string; logo: string; "market cap": number; sector: string; "short name": string; tags: string[]; ticker: string; website: string; logoSrc: string; 'Valuation': number; 'Financial Health': number; 'Estimated Growth': number; 'Past Performance': number; } export interface EmployeeCount { year: string; [ticker: string]: string | number; // really just number } export interface PriceHistory { date: string; [ticker: string]: string | number; // really just number } export interface BalanceSheet { ticker: string; current_assets: number; current_debt: number; total_assets: number; total_debt: number; } export interface Eps { [ticker: string]: string | number; // really just number quarter: string; } export interface EpsComp { [ticker: string]: string | number; // really just number quarter: string; } export const getCompanies = (tickers?: string[]): Promise => fetch(BACKEND_URL + '/companies' + (tickers ? ('/' + tickers.join('/')) : '')) .then(r => r.json()) .then(list => list.map((e: Company) => ({ ...e, logoSrc: `${BACKEND_URL}/companies/logos/${e.ticker}` }))); export const getEmployees = (tickers: string[]): Promise => fetch(BACKEND_URL + '/employees/' + tickers.join('/').toUpperCase()).then(r => r.json()) export const getPriceHistory = (tickers: string[]): Promise => fetch(BACKEND_URL + '/price_history/' + tickers.join('/').toUpperCase()).then(r => r.json()) export const getBalanceSheet = (tickers: string[]): Promise => fetch(BACKEND_URL + '/assets_debts/' + tickers.join('/')).then(r=>r.json()) export const getEps = (tickers: string[]): Promise => fetch(BACKEND_URL + '/eps/' + tickers.join('/').toUpperCase()).then(r => r.json()) export const getEpsComp = (tickers: string[]): Promise => fetch(BACKEND_URL + '/eps_comp/' + tickers.join('/').toUpperCase()).then(r => r.json())