From b8013865e92e456900bd0cd33108ffd3aa093a67 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 28 Sep 2021 13:27:21 -0700 Subject: [PATCH] fix(teams&users): XXX-0 fix timely api path in teams and return values --- src/lib/teams/teams.ts | 6 ++---- src/lib/types.ts | 3 ++- src/lib/users/users.ts | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib/teams/teams.ts b/src/lib/teams/teams.ts index 89ebc85..73a98db 100644 --- a/src/lib/teams/teams.ts +++ b/src/lib/teams/teams.ts @@ -13,13 +13,11 @@ export class Teams { const { data: response }: { data: TimelyTeam[] } = await this.http.get( `/${this.config.accountId}/teams`, ) - const team = response.find((u) => u.name === name) - if (!team) throw new Error(`Can't find team with name ${name}`) - return team + return response.find((u) => u.name === name) as TimelyTeam } async update(teamId: number, team: Partial): Promise { - const { data } = await this.http.put(`/${this.config.accountId}/teams${teamId}`, { team }) + const { data } = await this.http.put(`/${this.config.accountId}/teams/${teamId}`, { team }) return data } } diff --git a/src/lib/types.ts b/src/lib/types.ts index 62a4c98..d006344 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -118,6 +118,7 @@ export interface TimelyUser { id: number name: string } + projects?: { project_id: number; hour_rate?: number }[] } export interface TimelyLabel { @@ -377,7 +378,7 @@ export type TimelyEventBulkUpdate = OptionalExceptFor export type AddTimelyClient = OptionalExceptFor -export type AddTimelyUser = OptionalExceptFor +export type AddTimelyUser = OptionalExceptFor export type AddTimelyLabel = OptionalExceptFor diff --git a/src/lib/users/users.ts b/src/lib/users/users.ts index d4840f3..7dfeba9 100644 --- a/src/lib/users/users.ts +++ b/src/lib/users/users.ts @@ -26,12 +26,10 @@ export class Users { const { data: response }: { data: TimelyUser[] } = await this.http.get( `/${this.config.accountId}/users?limit=999`, ) - const user = response.find((u) => u.email === userEmail) - if (!user) throw new Error(`Can't find user with email of ${userEmail}`) - return user + return response.find((u) => u.email === userEmail) as TimelyUser } - async add(user: TimelyUser): Promise { + async add(user: AddTimelyUser): Promise { const { data } = await this.http.post(`/${this.config.accountId}/users`, { user }) return data }