From 28adc7d09676cff28388cbe39013952709f28e4c Mon Sep 17 00:00:00 2001 From: Anki Batsukh Date: Fri, 1 Dec 2023 13:38:23 +0100 Subject: [PATCH] update absences api to v2 --- src/clockodo.test.ts | 12 +++++++----- src/clockodo.ts | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/clockodo.test.ts b/src/clockodo.test.ts index 9f6f891d..e0a0a784 100644 --- a/src/clockodo.test.ts +++ b/src/clockodo.test.ts @@ -120,7 +120,9 @@ describe("Clockodo (instance)", () => { describe("GET", () => { describe("getAbsence()", () => { it("correctly builds getAbsence() request", async () => { - const nockScope = nock(CLOCKODO_API).get("/absences/7").reply(200, {}); + const nockScope = nock(CLOCKODO_API) + .get("/v2/absences/7") + .reply(200, {}); await clockodo.getAbsence({ id: 7 }); @@ -135,7 +137,7 @@ describe("Clockodo (instance)", () => { }; const nockScope = nock(CLOCKODO_API) - .get("/absences?" + qs.stringify(expectedParameters)) + .get("/v2/absences?" + qs.stringify(expectedParameters)) .reply(200, {}); await clockodo.getAbsences({ year: 218 }); @@ -915,7 +917,7 @@ describe("Clockodo (instance)", () => { }; const nockScope = nock(CLOCKODO_API) - .post("/absences", expectedParameters) + .post("/v2/absences", expectedParameters) .reply(200, {}); await clockodo.addAbsence({ @@ -1179,7 +1181,7 @@ describe("Clockodo (instance)", () => { }; const nockScope = nock(CLOCKODO_API) - .put("/absences/74", mapRequestBody(absence)) + .put("/v2/absences/74", mapRequestBody(absence)) .reply(200, {}); await clockodo.editAbsence(absence); @@ -1339,7 +1341,7 @@ describe("Clockodo (instance)", () => { describe("deleteAbsence()", () => { it("correctly builds deleteAbsence() request", async () => { const nockScope = nock(CLOCKODO_API) - .delete("/absences/31") + .delete("/v2/absences/31") .reply(200, {}); await clockodo.deleteAbsence({ id: 31 }); diff --git a/src/clockodo.ts b/src/clockodo.ts index 9e02574f..dd46534e 100644 --- a/src/clockodo.ts +++ b/src/clockodo.ts @@ -67,7 +67,7 @@ export class Clockodo { const { id, ...remainingParams } = params; - return this.api.get("/absences/" + id, remainingParams); + return this.api.get("/v2/absences/" + id, remainingParams); } async getAbsences( @@ -75,7 +75,7 @@ export class Clockodo { ): Promise { REQUIRED.checkRequired(params, REQUIRED.GET_ABSENCES); - return this.api.get("/absences", params); + return this.api.get("/v2/absences", params); } async getUsersAccessCustomersProjects( @@ -442,7 +442,7 @@ export class Clockodo { ): Promise { REQUIRED.checkRequired(params, REQUIRED.ADD_ABSENCE); - return this.api.post("/absences", params); + return this.api.post("/v2/absences", params); } async addCustomer( @@ -563,7 +563,7 @@ export class Clockodo { const { id } = params; - return this.api.put("/absences/" + id, params); + return this.api.put("/v2/absences/" + id, params); } async editCustomer( @@ -717,7 +717,7 @@ export class Clockodo { const { id } = params; - return this.api.delete("/absences/" + id, params); + return this.api.delete("/v2/absences/" + id, params); } async deleteEntry(