Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reports): IN-1 add reports module #88

Merged
merged 1 commit into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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