diff --git a/index.d.ts b/index.d.ts index 47fdba7..b582261 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,10 @@ type Callback = (error: any, payload: any) => void; +interface BaseArgs { + access_token?: string; +} + export interface PushSubscriptionRoutes { list(done?: Callback): Promise; create(args: any, done?: Callback): Promise; @@ -43,14 +47,39 @@ export interface RunningRacesRoutes { } export interface ClubsRoutes { - get(args: any, done?: Callback): Promise; - listMembers(args: any, done?: Callback): Promise; - listActivities(args: any, done?: Callback): Promise; - listAnnouncements(args: any, done?: Callback): Promise; - listEvents(args: any, done?: Callback): Promise; - listAdmins(args: any, done?: Callback): Promise; - joinClub(args: any, done?: Callback): Promise; - leaveClub(args: any, done?: Callback): Promise; + get(args: ClubsRoutesArgs, done?: Callback): Promise; + listMembers(args: ClubsRoutesListArgs, done?: Callback): Promise; + listActivities(args: ClubsRoutesListArgs, done?: Callback): Promise; + listAnnouncements(args: ClubsRoutesListArgs, done?: Callback): Promise; + listEvents(args: ClubsRoutesListArgs, done?: Callback): Promise; + listAdmins(args: ClubsRoutesListArgs, done?: Callback): Promise; + joinClub(args: ClubsRoutesListArgs, done?: Callback): Promise; + leaveClub(args: ClubsRoutesListArgs, done?: Callback): Promise; +} + +export interface ClubsRoutesArgs extends BaseArgs { + id: string; +} + +export interface ClubsRoutesListArgs extends ClubsRoutesArgs { + page?: number; + per_page?: number; +} + +export interface ClubActivity { + resource_state: number; + athlete: { + resource_state: number; + firstname: string; + lastname: string; + }; + name: string; + distance: number; + moving_time: number; + elapsed_time: number; + total_elevation_gain: number; + type: string; + workout_type?: number | null; } export interface AthletesRoutes { @@ -83,10 +112,18 @@ export interface AthleteRoutes { export interface OAuthRoutes { getRequestAccessURL(args: any): Promise; getToken(code: string, done?: Callback): Promise; - refreshToken(code: string): Promise; + refreshToken(code: string): Promise; deauthorize(args: any, done?: Callback): Promise; } +export interface RefreshTokenResponse { + token_type: string; + access_token: string; + expires_at: number; + expires_in: number; + refresh_token: string; +} + export interface RateLimiting { exceeded(): boolean; fractionReached(): boolean; diff --git a/lib/httpClient.js b/lib/httpClient.js index 72defd6..2cfce8a 100644 --- a/lib/httpClient.js +++ b/lib/httpClient.js @@ -193,7 +193,7 @@ HttpClient.prototype._requestHelper = function (options, done) { if (e.response && e.response.headers) { limits = rateLimiting.updateRateLimits(e.response.headers) } - + return Promise.reject(e) }) .asCallback(callback)