Skip to content

Commit

Permalink
update absences api to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
anki247 committed Dec 1, 2023
1 parent e80e6d7 commit 28adc7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/clockodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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 });
Expand Down Expand Up @@ -915,7 +917,7 @@ describe("Clockodo (instance)", () => {
};

const nockScope = nock(CLOCKODO_API)
.post("/absences", expectedParameters)
.post("/v2/absences", expectedParameters)
.reply(200, {});

await clockodo.addAbsence({
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down
10 changes: 5 additions & 5 deletions src/clockodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ export class Clockodo {

const { id, ...remainingParams } = params;

return this.api.get("/absences/" + id, remainingParams);
return this.api.get("/v2/absences/" + id, remainingParams);
}

async getAbsences(
params: Params<{ year: number; usersId?: User["id"] | Array<User["id"]> }>
): Promise<AbsencesReturnType> {
REQUIRED.checkRequired(params, REQUIRED.GET_ABSENCES);

return this.api.get("/absences", params);
return this.api.get("/v2/absences", params);
}

async getUsersAccessCustomersProjects(
Expand Down Expand Up @@ -442,7 +442,7 @@ export class Clockodo {
): Promise<AbsenceReturnType> {
REQUIRED.checkRequired(params, REQUIRED.ADD_ABSENCE);

return this.api.post("/absences", params);
return this.api.post("/v2/absences", params);
}

async addCustomer(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 28adc7d

Please sign in to comment.