diff --git a/src/lib/reports/clients.test.ts b/src/lib/reports/clients.test.ts new file mode 100644 index 0000000..7989112 --- /dev/null +++ b/src/lib/reports/clients.test.ts @@ -0,0 +1,7 @@ +import { Reports } from './reports' + +describe('Clients', () => { + it('creates', () => { + expect(new Reports({} as never, {} as never)).toBeTruthy() + }) +}) diff --git a/src/lib/reports/reports.ts b/src/lib/reports/reports.ts new file mode 100644 index 0000000..317c4dc --- /dev/null +++ b/src/lib/reports/reports.ts @@ -0,0 +1,19 @@ +import { AxiosInstance } from 'axios' +import { TimelyAppConfig } from '../types' + +export class Reports { + constructor(private readonly http: AxiosInstance, private readonly config: TimelyAppConfig) {} + + async getByExternalId( + externalId: string, + filter: { + group_by?: string[] + project_ids?: number[] + since?: string + until?: string + }, + ) { + const { data } = await this.http.post(`/${this.config.accountId}/reports/filter`, filter) + return data + } +} diff --git a/src/lib/timely-app.ts b/src/lib/timely-app.ts index ecfd1ca..c69ccec 100644 --- a/src/lib/timely-app.ts +++ b/src/lib/timely-app.ts @@ -8,6 +8,7 @@ import { Projects } from './projects/projects' import { Users } from './users/users' import { createHttpClient } from './http/http' import { Teams } from './teams/teams' +import { Reports } from './reports/reports' export class TimelyApp { readonly accounts: Accounts @@ -26,6 +27,8 @@ export class TimelyApp { readonly users: Users + readonly reports: Reports + constructor(private readonly config: TimelyAppConfig) { this.validateConfig() const httpConfig = { @@ -44,6 +47,7 @@ export class TimelyApp { this.projects = new Projects(this.http, this.config) this.teams = new Teams(this.http, this.config) this.users = new Users(this.http, this.config) + this.reports = new Reports(this.http, this.config) } private validateConfig() {