From d155f49ab00307bd8eac11390a1ee2ca217f22c0 Mon Sep 17 00:00:00 2001 From: Dominik Sumer Date: Mon, 23 Oct 2023 13:34:33 +0200 Subject: [PATCH 1/3] implemented get breakrules endpoint --- src/clockodo.test.ts | 12 ++++++++++++ src/clockodo.ts | 9 +++++++++ src/index.ts | 1 + src/models/breakRule.ts | 2 ++ src/models/worktimeRegulation.ts | 2 +- 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/clockodo.test.ts b/src/clockodo.test.ts index 2de9ed85..443a3888 100644 --- a/src/clockodo.test.ts +++ b/src/clockodo.test.ts @@ -604,6 +604,18 @@ describe("Clockodo (instance)", () => { nockScope.done(); }); }); + + describe("getBreakRules()", () => { + it("correctly builds getBreakRules() request", async () => { + const nockScope = nock(CLOCKODO_API) + .get("/v2/breakrules") + .reply(200, {}); + + await clockodo.getBreakRules(); + + nockScope.done(); + }); + }); }); describe("POST", () => { diff --git a/src/clockodo.ts b/src/clockodo.ts index bfc265f6..b496d5c8 100644 --- a/src/clockodo.ts +++ b/src/clockodo.ts @@ -44,6 +44,7 @@ import { WorkTimeChangeRequestStatus, WorkTimeDay, } from "./models/workTimes.js"; +import { BreakRule } from "./models/breakRule.js"; export class Clockodo { api: Api; @@ -774,6 +775,10 @@ export class Clockodo { ): Promise { return this.api.get("/v2/worktimeregulations", params); } + + async getBreakRules(params?: Params): Promise { + return this.api.get("/v2/breakrules", params); + } } export type AbsenceReturnType = { absence: Absence }; @@ -1067,3 +1072,7 @@ export type AddWorkTimesChangeRequestReturnType = export type WorktimeRegulationsReturnType = { worktimeregulations: Array; }; + +export type BreakRulesReturnType = { + breakrules: Array; +}; diff --git a/src/index.ts b/src/index.ts index f7c29bf8..9c11e25c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ export * from "./models/absence.js"; export * from "./models/access.js"; +export * from "./models/breakRule.js"; export * from "./models/company.js"; export * from "./models/customer.js"; export * from "./models/dateTime.js"; diff --git a/src/models/breakRule.ts b/src/models/breakRule.ts index eff35f22..8c512057 100644 --- a/src/models/breakRule.ts +++ b/src/models/breakRule.ts @@ -1,4 +1,6 @@ export type BreakRule = { + /** ID of the break rule */ + id: number; /** ID of the corresponding worktime regulation */ worktimeRegulationsId: number; /** Daily worktime (in hours), above which the rule applies */ diff --git a/src/models/worktimeRegulation.ts b/src/models/worktimeRegulation.ts index e78f1722..f674e61c 100644 --- a/src/models/worktimeRegulation.ts +++ b/src/models/worktimeRegulation.ts @@ -22,5 +22,5 @@ export type WorktimeRegulationWithRules = Omit< "name" | "preset" > & { /** Contains objects of the type "breakrule" */ - rules: Array>; + rules: Array>; }; From bf28e6fe440379d4a80be68fc31295249183fa00 Mon Sep 17 00:00:00 2001 From: Dominik Sumer Date: Tue, 24 Oct 2023 16:11:50 +0200 Subject: [PATCH 2/3] renaming --- src/clockodo.test.ts | 6 +++--- src/clockodo.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/clockodo.test.ts b/src/clockodo.test.ts index 99cd0b3d..737aff9e 100644 --- a/src/clockodo.test.ts +++ b/src/clockodo.test.ts @@ -629,13 +629,13 @@ describe("Clockodo (instance)", () => { }); }); - describe("getBreakRules()", () => { - it("correctly builds getBreakRules() request", async () => { + describe("getWorktimeBreakRules()", () => { + it("correctly builds getWorktimeBreakRules() request", async () => { const nockScope = nock(CLOCKODO_API) .get("/v2/worktimeBreakRules") .reply(200, {}); - await clockodo.getBreakRules(); + await clockodo.getWorktimeBreakRules(); nockScope.done(); }); diff --git a/src/clockodo.ts b/src/clockodo.ts index 904a2630..e2b94980 100644 --- a/src/clockodo.ts +++ b/src/clockodo.ts @@ -790,7 +790,9 @@ export class Clockodo { return this.api.get("/v2/worktimeRegulations", params); } - async getBreakRules(params?: Params): Promise { + async getWorktimeBreakRules( + params?: Params + ): Promise { return this.api.get("/v2/worktimeBreakRules", params); } } From 0b6582f761a1ed86a5f5e336c6e15426103e4eb2 Mon Sep 17 00:00:00 2001 From: Dominik Sumer Date: Tue, 24 Oct 2023 16:14:51 +0200 Subject: [PATCH 3/3] renaming --- src/clockodo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clockodo.ts b/src/clockodo.ts index e2b94980..571923b4 100644 --- a/src/clockodo.ts +++ b/src/clockodo.ts @@ -1108,5 +1108,5 @@ export type WorktimeRegulationsReturnType = { }; export type WorktimeBreakRulesReturnType = { - workTimeBreakRules: Array; + worktimeBreakRules: Array; };