Skip to content

Commit

Permalink
feat: added edit company endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dsumer committed Oct 24, 2023
1 parent b395cf2 commit 5ec3be5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/clockodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,23 @@ describe("Clockodo (instance)", () => {
});
});

describe("editCompany()", () => {
it("correctly builds editCompany() request", async () => {
const company = {
id: 33,
name: "Moalo Loco",
};

const nockScope = nock(CLOCKODO_API)
.put("/v2/company/33", mapRequestBody(company))
.reply(200, {});

await clockodo.editCompany(company);

nockScope.done();
});
});

describe("editEntryGroup()", () => {
it("correctly builds editEntryGroup() request", async () => {
const entryGroup = {
Expand Down
11 changes: 11 additions & 0 deletions src/clockodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,16 @@ export class Clockodo {
return this.api.put("/users/" + id, params);
}

async editCompany(
params: Params<Pick<Company, typeof REQUIRED.EDIT_COMPANY[number]>>
): Promise<CompanyReturnType> {
REQUIRED.checkRequired(params, REQUIRED.EDIT_COMPANY);

const { id } = params;

return this.api.put("/v2/company/" + id, params);
}

async deactivateCustomer(
params: Params<Pick<Customer, typeof REQUIRED.DEACTIVATE_CUSTOMER[number]>>
): Promise<CustomerReturnType> {
Expand Down Expand Up @@ -810,6 +820,7 @@ export type LumpsumServicesReturnType = {
};
export type UserReturnType = { user: User };
export type UsersReturnType = { users: Array<User> };
export type CompanyReturnType = { company: Company };
export type EntryReturnType = { entry: Entry };
export type AddEntryReturnType = { entry: Entry; stopped?: Entry };
export type EditEntryReturnType = {
Expand Down
1 change: 1 addition & 0 deletions src/lib/requiredParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const EDIT_PROJECT = ["id"] as const;
export const EDIT_SERVICE = ["id"] as const;
export const EDIT_TEAM = ["id"] as const;
export const EDIT_USER = ["id"] as const;
export const EDIT_COMPANY = ["id"] as const;
export const EDIT_ENTRY_GROUP = ["timeSince", "timeUntil"] as const;
export const EDIT_ABSENCE = ["id"] as const;
export const EDIT_ENTRY = ["id"] as const;
Expand Down

0 comments on commit 5ec3be5

Please sign in to comment.