UNPKG

@gibme/tablo.tv

Version:

API interface for interacting with a Tablo TV device

102 lines (101 loc) 3.11 kB
import type { Tablo } from './tablo'; type Credentials = { access_key: string; secret_key: string; }; export declare class TabloAPI { private readonly options; readonly device_id: string; private readonly base_uri; private readonly keys; readonly timeout: number; /** * Constructs a new instance of the base API to interact with a Tablo device * @param hostOrUri * @param options */ constructor(hostOrUri: string, options: Partial<TabloAPI.Options> & Credentials); /** * Calculates the end time based upon the specified start time and duration * @param start_time * @param duration * @protected */ protected calculate_endtime(start_time: string, duration: number): string; /** * Returns the current hour timestamps * @protected */ protected get currentHour(): { now: number; start: number; end: number; }; /** * Batch operations are much faster than a bunch of single operations. * For example, instead of making 50 requests for the first 50 recordings * returned by Recordings - Get Airings, you can take those 50 paths * and make 1 request to /batch to receive all the same data. * @param endpoints * @param timeout * @protected */ protected batch<ResponseType = any>(endpoints: string[], timeout?: number): Promise<Record<string, Tablo.Batched.Root & ResponseType>>; /** * Performs a DELETE request against the Tablo device * @param endpoint * @param params * @param timeout * @protected */ protected delete(endpoint: string, params?: Record<string, any>, timeout?: number): Promise<boolean>; /** * Performs a GET request against the Tablo device * @param endpoint * @param params * @param timeout * @param json * @protected */ protected get<ResponseType = any>(endpoint: string, params?: Record<string, any>, timeout?: number, json?: boolean): Promise<ResponseType | undefined>; /** * Performs a PUT request against the Tablo device * @param endpoint * @param params * @param payload * @param timeout * @param json * @protected */ protected post<ResponseType = any>(endpoint: string, params?: Record<string, any>, payload?: object, timeout?: number, json?: boolean): Promise<ResponseType | undefined>; /** * Executes an API call to the Tablo device * @param method * @param endpoint * @param params * @param payload * @param keys * @param timeout * @private */ private execute; /** * Generates the authentication header required for some of the Tablo device API calls * @param method * @param path * @param body * @param keys * @private */ private generateAuthHeader; } export declare namespace TabloAPI { type Options = { ssl: boolean; device_id: string; timeout: number; request_logging: boolean; port: number; }; } export default TabloAPI;