-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2562002
commit 4b0ae69
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Teams } from './teams' | ||
|
||
describe('Teams', () => { | ||
it('creates', () => { | ||
expect(new Teams({} as never, {} as never)).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { AxiosInstance } from 'axios' | ||
import { TimelyAppConfig, TimelyTeam, TimelyUser } from '../types' | ||
|
||
export class Teams { | ||
constructor(private readonly http: AxiosInstance, private readonly config: TimelyAppConfig) {} | ||
|
||
async getAll(): Promise<TimelyUser[]> { | ||
const { data } = await this.http.get(`/${this.config.accountId}/teams`) | ||
return data | ||
} | ||
|
||
async getByName(name: string): Promise<TimelyTeam> { | ||
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 | ||
} | ||
|
||
async update(teamId: number, team: Partial<TimelyTeam>): Promise<TimelyTeam> { | ||
const { data } = await this.http.put(`/${this.config.accountId}/teams${teamId}`, { team }) | ||
return data | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters