tsvesync
Version:
A TypeScript library for interacting with VeSync smart home devices
89 lines (88 loc) • 2.68 kB
TypeScript
/**
* Helper functions for VeSync API
*/
import { VeSync } from './vesync';
export declare function getApiBaseUrl(): string;
export declare function setApiBaseUrl(url: string): void;
export declare const API_RATE_LIMIT = 30;
export declare const API_TIMEOUT = 15000;
export declare const APP_VERSION = "2.8.6";
export declare const PHONE_BRAND = "SM N9005";
export declare const PHONE_OS = "Android";
export declare const USER_TYPE = "1";
export declare const DEFAULT_TZ = "America/New_York";
export declare const DEFAULT_REGION = "US";
export declare const MOBILE_ID = "1234567890123456";
export declare const BYPASS_HEADER_UA = "okhttp/3.12.1";
export interface RequestBody {
acceptLanguage?: string;
accountID?: string;
appVersion?: string;
cid?: string;
configModule?: string;
debugMode?: boolean;
deviceRegion?: string;
email?: string;
method?: string;
password?: string;
phoneBrand?: string;
phoneOS?: string;
timeZone?: string;
token?: string;
traceId?: string;
userType?: string;
uuid?: string;
status?: string;
[key: string]: any;
}
export declare class Helpers {
static shouldRedact: boolean;
/**
* Calculate MD5 hash
*/
static hashPassword(text: string): string;
/**
* Build header for legacy api GET requests
*/
static reqHeaders(manager: VeSync): Record<string, string>;
/**
* Build header for api requests on 'bypass' endpoint
*/
static reqHeaderBypass(): Record<string, string>;
/**
* Return universal keys for body of api requests
*/
static reqBodyBase(manager: VeSync): Record<string, string>;
/**
* Keys for authenticating api requests
*/
static reqBodyAuth(manager: VeSync): Record<string, any>;
/**
* Detail keys for api requests
*/
static reqBodyDetails(): Record<string, string>;
/**
* Builder for body of api requests
*/
static reqBody(manager: VeSync, type: string): Record<string, any>;
/**
* Call VeSync API
*/
static callApi(endpoint: string, method: string, data: any | undefined, headers: Record<string, string> | undefined, manager: VeSync): Promise<[any, number]>;
/**
* Calculate hex value from energy response
*/
static calculateHex(hexStr: string): string;
/**
* Build energy dictionary from API response
*/
static buildEnergyDict(result: any): Record<string, any>;
/**
* Build configuration dictionary from API response
*/
static buildConfigDict(result: any): Record<string, any>;
/**
* Calculate MD5 hash
*/
static md5(text: string): string;
}