eightsleep
Version:
eightsleep api client
43 lines (42 loc) • 1.6 kB
TypeScript
import ApiClient, { QueryParamsType } from 'simple-api-client';
import { OauthSession } from './validateOauth';
import { SessionType } from './validateSession';
import { EightSleepAppApi } from './EightSleepAppApi';
export { Sides } from './EightSleepAppApi';
declare type OauthClientType = {
id: string;
secret: string;
};
export declare type OptsType = {
email: string;
password: string;
oauthClient?: OauthClientType;
oauthSession?: OauthSession;
session?: SessionType;
};
export { NetworkError, StatusCodeError, InvalidResponseError, } from 'simple-api-client';
export default class EightSleepClientApi extends ApiClient {
private readonly auth;
private readonly appApiClient?;
session?: SessionType;
oauthClient?: OauthClientType;
oauthSession?: OauthSession;
constructor({ email, password, oauthClient, oauthSession, session, }: OptsType);
toJSON(): OptsType;
login: () => Promise<SessionType>;
refreshSession(): Promise<SessionType>;
oauth: () => Promise<OauthSession>;
getAppApiClient(): EightSleepAppApi;
refreshOauth(): Promise<OauthSession>;
getMe(query?: QueryParamsType): Promise<any>;
updateMe(json: MeUpdateType, query?: QueryParamsType): Promise<any>;
getUser: (id: string, query?: Record<string, string | string[]> | undefined) => Promise<any>;
getDevice: (id: string, query?: Record<string, string | string[]> | undefined) => Promise<any>;
}
export declare type MeUpdateType = {
firstName?: string;
lastName?: string;
gender?: string;
dob?: Date;
zip?: number | string;
};