import { ExportFileType, UploadFileType } from './Urls'; import { CookieJar } from 'tough-cookie'; import { GCActivityId, GCBadgeId, GCUserHash, Gear, IActivity, IActivityDetails, IBadge, ISocialConnections, ISocialProfile, IUserInfo } from './types'; export type EventCallback = (data: T) => void; export interface GCCredentials { username: string; password: string; } export interface Listeners { [event: string]: EventCallback[]; } export declare enum Event { sessionChange = "sessionChange" } export interface Session { cookies: CookieJar.Serialized | undefined; userHash: string | undefined; } export default class GarminConnect { private client; private _userHash; private credentials; private listeners; constructor(credentials?: GCCredentials | undefined); get userHash(): GCUserHash; get sessionJson(): Session; set sessionJson(json: Session); /** * Add an event listener callback * @param event * @param callback */ on(event: Event, callback: EventCallback): void; /** * Method for triggering any event * @param event * @param data */ triggerEvent(event: Event, data: T): void; /** * Add a callback to the 'sessionChange' event * @param callback */ onSessionChange(callback: EventCallback): void; /** * Restore an old session from storage and fallback to regular login * @param json * @param username * @param password * @returns {Promise} */ restoreOrLogin(json: Session, username: string, password: string): Promise; /** * Restore an old session from storage * @param json * @returns {Promise} */ restore(json: Session): Promise; /** * Login to Garmin Connect * @param username * @param password * @returns {Promise<*>} */ login(username?: string, password?: string): Promise; /** * Get basic user information * @returns {Promise<*>} */ getUserInfo(): Promise; /** * Get social user information * @returns {Promise<*>} */ getSocialProfile(): Promise; /** * Get a list of all social connections * @returns {Promise<*>} */ getSocialConnections(): Promise; /** * Get a list of all registered devices * @returns {Promise<*>} */ getDeviceInfo(): Promise; /** * Get detailed sleep data for a specific date * @param date * @returns {Promise<*>} */ getSleepData(date?: Date): Promise; /** * Get sleep data summary for a specific date * @param date * @returns {Promise<*>} */ getSleep(date?: Date): Promise; /** * Get heart rate measurements for a specific date * @param date * @returns {Promise<*>} */ getHeartRate(date?: Date): Promise; /** * Post a new body weight * @param weight * @returns {Promise<*>} */ setBodyWeight(weight: number): Promise; /** * Get list of activites * @param start * @param limit * @returns {Promise<*>} */ getActivities(start: number, limit: number): Promise; /** * Get details about an activity * @param activityId * @returns {Promise} */ getActivityDetails(activityId: GCActivityId): Promise; /** * Get metrics details about an activity * @param activity * @param maxChartSize * @param maxPolylineSize * @returns {Promise<*>} */ getActivity(activity: { activityId: GCActivityId; }, maxChartSize: number, maxPolylineSize: number): Promise; /** * Get weather data from an activity * @param activity * @returns {Promise<*>} */ getActivityWeather(activity: { activityId: GCActivityId; }): Promise; /** * Updates an activity * @param activity * @returns {Promise<*>} */ updateActivity(activity: { activityId: GCActivityId; }): Promise; /** * Deletes an activity * @param activity * @returns {Promise<*>} */ deleteActivity(activity: { activityId: GCActivityId; }): Promise; /** * Get list of activities in your news feed * @param start * @param limit * @returns {Promise<*>} */ getNewsFeed(start: number, limit: number): Promise; /** * Get step count for a specific date * @param date * @returns {Promise<*>} */ getSteps(date?: Date): Promise; /** * Get list of workouts * @param start * @param limit * @returns {Promise<*>} */ getWorkouts(start: number, limit: number): Promise; /** * Download original activity data to disk as zip * Resolves to absolute path for the downloaded file * @param activity : any * @param dir Will default to current working directory * @param type : string - Will default to 'zip'. Other possible values are 'tcx', 'gpx' or 'kml'. * @returns {Promise<*>} */ downloadOriginalActivityData(activity: { activityId: GCActivityId; }, dir: string, type?: ExportFileType): Promise; /** * Uploads an activity file ('gpx', 'tcx', or 'fit') * @param file the file to upload * @param format the format of the file. If undefined, the extension of the file will be used. * @returns {Promise<*>} */ uploadActivity(file: string, format: UploadFileType): Promise; /** * Adds a running workout with one step of completeing a set distance. * @param name * @param meters * @param description * @returns {Promise<*>} */ addRunningWorkout(name: string, meters: number, description: string): Promise; /** * Add a new workout preset. * @param workout * @returns {Promise<*>} */ addWorkout(workout: any): Promise; /** * Add a workout to your workout calendar. * @param workout * @param date * @returns {Promise<*>} */ scheduleWorkout(workout: any, date: Date): Promise; /** * Delete a workout based on a workout object. * @param workout * @returns {Promise<*>} */ deleteWorkout(workout: any): Promise; /** * Get list of earned badges * @returns {Promise<*>} */ getBadgesEarned(): Promise; /** * Get list of available badges * @returns {Promise<*>} */ getBadgesAvailable(): Promise; /** * Get details about an badge * @param badge * @returns {Promise<*>} */ getBadge(badge: { badgeId: GCBadgeId; }): Promise; /** * Uploads an image to an activity * @param activity * @param file the file to upload * @returns {Promise<*>} */ uploadImage(activity: { activityId: GCActivityId; }, file: string): Promise; /** * Delete an image from an activity * @param activity * @param imageId, can be found in `activityImages` array of the activity * @returns {Promise} */ deleteImage(activity: { activityId: GCActivityId; }, imageId: string): Promise; /** * List the gear available at a certain date * @param userProfilePk, user profile private key (can be found in user or activity details) * @param availableGearDate, list gear available at this date only * @returns {Promise} */ listGear(userProfilePk: number, availableGearDate?: Date): Promise; /** * Link gear to activity * @param activityId, Activity ID * @param gearUuid, UUID of the gear * @returns {Promise} */ linkGear(activityId: GCActivityId, gearUuid: string): Promise; /** * Unlink gear to activity * @param activityId, Activity ID * @param gearUuid, UUID of the gear * @returns {Promise} */ unlinkGear(activityId: GCActivityId, gearUuid: string): Promise; get(url: string, data?: any): Promise; post(url: string, data: any): Promise; put(url: string, data: any): Promise; }