Skip to content

Commit

Permalink
bumped services and lumpsumservices to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
dsumer committed Nov 2, 2023
1 parent 78185eb commit c4053ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
26 changes: 14 additions & 12 deletions src/clockodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe("Clockodo (instance)", () => {
describe("getLumpSumService()", () => {
it("correctly builds getLumpSumService() request", async () => {
const nockScope = nock(CLOCKODO_API)
.get("/v2/lumpsumservices/777")
.get("/v3/lumpsumservices/777")
.reply(200, {});

await clockodo.getLumpSumService({ id: 777 });
Expand All @@ -209,7 +209,7 @@ describe("Clockodo (instance)", () => {
describe("getLumpSumServicesPage()", () => {
it("correctly builds getLumpSumServicesPage() request", async () => {
const nockScope = nock(CLOCKODO_API)
.get("/v2/lumpsumservices")
.get("/v3/lumpsumservices")
.reply(200, {});

await clockodo.getLumpSumServicesPage();
Expand All @@ -221,7 +221,7 @@ describe("Clockodo (instance)", () => {
describe("getLumpSumServices()", () => {
it("requests all lumpSumService pages", async () => {
const nockScope = setupPaginatedApiMock({
baseUrl: "/v2/lumpsumservices?",
baseUrl: "/v3/lumpsumservices?",
countPages: 3,
createPageResponse: (page) => ({ lumpSumServices: [page] }),
});
Expand Down Expand Up @@ -445,7 +445,9 @@ describe("Clockodo (instance)", () => {

describe("getService()", () => {
it("correctly builds getService() request", async () => {
const nockScope = nock(CLOCKODO_API).get("/services/10").reply(200, {});
const nockScope = nock(CLOCKODO_API)
.get("/v3/services/10")
.reply(200, {});

await clockodo.getService({ id: 10 });

Expand All @@ -455,7 +457,7 @@ describe("Clockodo (instance)", () => {

describe("getServicesPage()", () => {
it("correctly builds getServicesPage() request", async () => {
const nockScope = nock(CLOCKODO_API).get("/v2/services").reply(200, {});
const nockScope = nock(CLOCKODO_API).get("/v3/services").reply(200, {});

await clockodo.getServicesPage();

Expand All @@ -466,7 +468,7 @@ describe("Clockodo (instance)", () => {
describe("getServices()", () => {
it("requests all getServices pages", async () => {
const nockScope = setupPaginatedApiMock({
baseUrl: "/v2/services?",
baseUrl: "/v3/services?",
countPages: 3,
createPageResponse: (page) => ({ services: [page] }),
});
Expand Down Expand Up @@ -751,7 +753,7 @@ describe("Clockodo (instance)", () => {
};

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

await clockodo.addLumpsumService({
Expand Down Expand Up @@ -793,7 +795,7 @@ describe("Clockodo (instance)", () => {
};

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

await clockodo.addService({ name: "Thinking", active: true });
Expand Down Expand Up @@ -1045,7 +1047,7 @@ describe("Clockodo (instance)", () => {
};

const nockScope = nock(CLOCKODO_API)
.put("/v2/lumpsumservices/15", mapRequestBody(lumpsumService))
.put("/v3/lumpsumservices/15", mapRequestBody(lumpsumService))
.reply(200, {});

await clockodo.editLumpsumService(lumpsumService);
Expand Down Expand Up @@ -1080,7 +1082,7 @@ describe("Clockodo (instance)", () => {
};

const nockScope = nock(CLOCKODO_API)
.put("/v2/services/23", mapRequestBody(service))
.put("/v3/services/23", mapRequestBody(service))
.reply(200, {});

await clockodo.editService(service);
Expand Down Expand Up @@ -1210,7 +1212,7 @@ describe("Clockodo (instance)", () => {
describe("deleteService()", () => {
it("correctly builds deleteService() request", async () => {
const nockScope = nock(CLOCKODO_API)
.delete("/v2/services/94")
.delete("/v3/services/94")
.reply(200, {});

await clockodo.deleteService({ id: 94 });
Expand All @@ -1222,7 +1224,7 @@ describe("Clockodo (instance)", () => {
describe("deleteLumpsumService()", () => {
it("correctly builds deleteLumpsumService() request", async () => {
const nockScope = nock(CLOCKODO_API)
.delete("/v2/lumpsumservices/94")
.delete("/v3/lumpsumservices/94")
.reply(200, {});

await clockodo.deleteLumpsumService({ id: 94 });
Expand Down
24 changes: 12 additions & 12 deletions src/clockodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,14 @@ export class Clockodo {

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

return this.api.get("/services/" + id, remainingParams);
return this.api.get("/v3/services/" + id, remainingParams);
}

async getServices(
params?: Params<ServiceParams>
): Promise<ResponseWithoutPaging<ServicesReturnType>> {
const pages = await this.api.getAllPages<ServicesReturnType>(
"/v2/services",
"/v3/services",
params
);
const [{ paging, ...remainingResponse }] = pages;
Expand All @@ -289,7 +289,7 @@ export class Clockodo {
async getServicesPage(
params?: Params<ServiceParams & ParamsWithPage>
): Promise<ServicesReturnType> {
return this.api.get("/v2/services", params);
return this.api.get("/v3/services", params);
}

async getTeam(params: Params<{ id: Team["id"] }>): Promise<TeamReturnType> {
Expand All @@ -312,15 +312,15 @@ export class Clockodo {

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

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

// This endpoint still uses the old lumpSum casing
async getLumpSumServices(
params?: Params<LumpsumServiceParams>
): Promise<ResponseWithoutPaging<LumpsumServicesReturnType>> {
const pages = await this.api.getAllPages<LumpsumServicesReturnType>(
"/v2/lumpsumservices",
"/v3/lumpsumservices",
params
);
const [{ paging, ...remainingResponse }] = pages;
Expand All @@ -338,7 +338,7 @@ export class Clockodo {
async getLumpSumServicesPage(
params?: Params<LumpsumServiceParams & ParamsWithPage>
): Promise<LumpsumServicesReturnType> {
return this.api.get("/v2/lumpsumservices", params);
return this.api.get("/v3/lumpsumservices", params);
}

async getTargethoursRow(
Expand Down Expand Up @@ -443,7 +443,7 @@ export class Clockodo {
): Promise<LumpsumServiceReturnType> {
REQUIRED.checkRequired(params, REQUIRED.ADD_LUMPSUM_SERVICE);

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

async addEntry(
Expand Down Expand Up @@ -480,7 +480,7 @@ export class Clockodo {
): Promise<ServiceReturnType> {
REQUIRED.checkRequired(params, REQUIRED.ADD_SERVICE);

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

async addTeam(
Expand Down Expand Up @@ -558,7 +558,7 @@ export class Clockodo {

const { id } = params;

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

async editEntry(
Expand Down Expand Up @@ -596,7 +596,7 @@ export class Clockodo {

const { id } = params;

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

async editTeam(
Expand Down Expand Up @@ -646,7 +646,7 @@ export class Clockodo {

const { id } = params;

return this.api.delete("/v2/services/" + id, params);
return this.api.delete("/v3/services/" + id, params);
}

async deleteUser(
Expand Down Expand Up @@ -686,7 +686,7 @@ export class Clockodo {

const { id } = params;

return this.api.delete("/v2/lumpsumservices/" + id, params);
return this.api.delete("/v3/lumpsumservices/" + id, params);
}

async deleteEntryGroup(
Expand Down

0 comments on commit c4053ab

Please sign in to comment.