Skip to content

Commit

Permalink
feat(reports): IN-1 add reports module (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
noticeeverything committed Jan 28, 2022
1 parent 2171411 commit 9c2cb12
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/reports/clients.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Reports } from './reports'

describe('Clients', () => {
it('creates', () => {
expect(new Reports({} as never, {} as never)).toBeTruthy()
})
})
19 changes: 19 additions & 0 deletions src/lib/reports/reports.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
4 changes: 4 additions & 0 deletions src/lib/timely-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +27,8 @@ export class TimelyApp {

readonly users: Users

readonly reports: Reports

constructor(private readonly config: TimelyAppConfig) {
this.validateConfig()
const httpConfig = {
Expand All @@ -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() {
Expand Down

0 comments on commit 9c2cb12

Please sign in to comment.