Skip to content

Commit

Permalink
feat(getbyexternalid): XXX-0 add method to clients/projects (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
noticeeverything authored Jan 26, 2022
1 parent 0bd89fa commit 0d7b7a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/clients/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export class Clients {
return client
}

async getByExternalId(customerId: string): Promise<TimelyClient | undefined> {
const clients = await this.getAll()
return clients.find((e) => e.external_id === customerId)
}

async add(client: AddTimelyClient): Promise<TimelyClient> {
const { data } = await this.http.post(`/${this.config.accountId}/clients`, { client })
return data
Expand Down
6 changes: 6 additions & 0 deletions src/lib/projects/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export class Projects {
return data
}

async getByExternalId(externalId: string): Promise<TimelyProject | undefined> {
const projects = await this.getAll()
if (!(projects && projects.length)) return undefined
return projects.find((e) => e?.external_id === externalId)
}

async add(project: AddTimelyProject): Promise<TimelyProject> {
const { data } = await this.http.post(`/${this.config.accountId}/projects`, { project })
return data
Expand Down

0 comments on commit 0d7b7a0

Please sign in to comment.