import { Observable } from 'rxjs/Observable'; import { AxiosInstance } from 'axios'; import { TemporalPage, Data, BatchedData } from '../types'; export declare abstract class DataClient { protected host: string; protected ax: AxiosInstance; constructor(host: string, axiosInstance: AxiosInstance); /** * The item collection over which the MultiClient iterates (sourceIds or geohashes). */ protected abstract getMultiItems(): string[]; /** * The path portion of the api, starting with '/' ending with '/events'. * @param item The injected item of the item collection returned by getMultiItems() */ protected abstract getBaseApiPath(item: string): string; private generateLatestUrls(metric); private generateEventUrls(metric, queryStr); private generateStatsUrls(metric, type, timeStr); /** * Methods for retrieving data of a particual metric * @param metric metric name */ getData(metric: string): IData; /** * Methods for retrieving statistics of a particular metric */ getStats(metric: string): IStats; } /** * Methods for retrieving data */ export interface IData { /** * Returns the latest data of each item (location or source). */ latest: () => Observable; /** * Poll for the latest data of each item (location or source). Every update will be sent through, * hence it is mandatory to check the data for the key. * @param period {number} The period in milliseconds of the polling. * @param fromTS {number=} The UNIX UTC timestamp from which to start polling. If not present the last data will be polled. * @see Util.Time.timestampOf to easily create a UTC timestamp */ poll: (period: number, fromTS?: number) => Observable; /** * Returns data for each item (location or source) within the assigned areas as a single array of TemporalPageData objects. * @param fromTS {number} Timestamp (UNIX UTC) from which to start the requested range * @param toTS {number} Timestamp (UNIX UTC) until which to query * @returns An Observable containing an array of objects. * @see Util.Time.timestampOf to easily create a UTC timestamp */ range: (fromTS: number, toTS: number) => Observable; } /** * Methods for retrieving statistics */ export interface IStats { /** * Methods for retrieving a single statistics unit (of an hour/day) */ getUnit: () => IStatsUnit; /** * Methods for retrieving a group of statistics (of a day) */ getBatch: () => IStatsBatch; } export interface IStatsUnit { /** * Returns statistics for all measured values in one hour. * @param hourTS The UTC timestamp of a single hour * @see Util.Time.timestampOf to easily create a UTC timestamp */ getHour: (hourTS: number) => Observable; /** * Returns statistics for all measured values per hour in a range. * @param fromTS The UTC timestamp of a single hour to start the range from * @param toTS The UTC timestamp of a single hour to end the range with * @see Util.Time.timestampOf to easily create a UTC timestamp */ getHourRange: (fromTS: number, toTS: number) => Observable; /** * Get a single statistics hour unit as a recap representing the requested range. * @param fromTS The UTC timestamp of a single hour to start the range from * @param toTS The UTC timestamp of a single hour to end the range with * @see Util.Time.timestampOf to easily create a UTC timestamp */ getHourRecap: (fromTS: number, toTS: number) => Observable; /** * Get a single statistics hour unit as a recap representing the requested hours. * @param hourTS All timestamps representing the hours to get a recap from * @see Util.Time.timestampOf to easily create a UTC timestamp */ getHourRecapOf: (...hourTS: number[]) => Observable; /** * Returns statistics for all measured values in one day. * @param dayTS The UTC timestamp of a single day * @see Util.Time.timestampOf to easily create a UTC timestamp */ getDay: (dayTS: number) => Observable; /** * Returns statistics for all measured values per day in an range. * @param fromTS The UTC timestamp of a single day to start the range from * @param toTS The UTC timestamp of a single day to end the range with * @see Util.Time.timestampOf to easily create a UTC timestamp */ getDayRange: (fromTS: number, toTS: number) => Observable; /** * Get a single statistics day unit as a recap representing the requested range. * @param fromTS The UTC timestamp of a single day to start the range from * @param toTS The UTC timestamp of a single day to end the range with * @see Util.Time.timestampOf to easily create a UTC timestamp */ getDayRecap: (fromTS: number, toTS: number) => Observable; /** * Get a single statistics day unit as a recap representing the requested days. * @param dayTS All timestamps representing the days to get a recap from * @see Util.Time.timestampOf to easily create a UTC timestamp */ getDayRecapOf: (...dayTS: number[]) => Observable; } export interface IStatsBatch { /** * Returns a disgest of statistics for all measured values of a single day. The batch contains an overview of multiple bins. * @param dayTS The UTC timestamp of a single day * @see Util.Time.timestampOf to easily create a UTC timestamp */ getDay: (dayTS: number) => Observable; /** * Returns a batch of statistics for all measured values per day in an range. * @param fromTS The UTC timestamp of a single day to start the range from * @param toTS The UTC timestamp of a single day to end the range with * @see Util.Time.timestampOf to easily create a UTC timestamp */ getDayRange: (fromTS: number, toTS: number) => Observable; /** * Get a single statistics day batch as a recap representing the requested range * @param fromTS The UTC timestamp of a single day to start the range from * @param toTS The UTC timestamp of a single day to end the range with */ getDayRecap: (fromTS: number, toTS: number) => Observable; /** * Get a single statistics day batch as a recap representing the requested days. * @param dayTS All timestamps representing the days to get a recap from * @see Util.Time.timestampOf to easily create a UTC timestamp */ getDayRecapOf: (...dayTS: number[]) => Observable; }