Skip to content

Commit

Permalink
Merge branch 'main' into get-worktimeregulations
Browse files Browse the repository at this point in the history
  • Loading branch information
dsumer committed Nov 9, 2023
2 parents 2cced6b + 7de751e commit 3504e3e
Show file tree
Hide file tree
Showing 15 changed files with 414 additions and 71 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# [22.2.0](https://github.com/peerigon/clockodo/compare/v22.1.0...v22.2.0) (2023-11-06)

### Features

- Use v3 API for services and lumpsum services ([#131](https://github.com/peerigon/clockodo/issues/131)) ([1a8ba9d](https://github.com/peerigon/clockodo/commit/1a8ba9d1fad6a6251a1116a39bfd1886a048bce1))

# [22.1.0](https://github.com/peerigon/clockodo/compare/v22.0.0...v22.1.0) (2023-11-06)

### Features

- Add testData property to targethoursRow ([#140](https://github.com/peerigon/clockodo/issues/140)) ([9c2e511](https://github.com/peerigon/clockodo/commit/9c2e5119004eeb89c95b53e42815e95fbf5e071e))

# [22.0.0](https://github.com/peerigon/clockodo/compare/v21.15.0...v22.0.0) (2023-10-24)

### Features

- Replace deactivate... with delete... ([67e0b33](https://github.com/peerigon/clockodo/commit/67e0b336a342886c04df8a70636c020a58a02f28))

### BREAKING CHANGES

- There are no `deactivate...` methods anymore. In order to deactivate a customer, project, ..., you need to call `edit...` with `active: false`.

# [21.15.0](https://github.com/peerigon/clockodo/compare/v21.14.0...v21.15.0) (2023-10-24)

### Features

- Add overtimecarry endpoint ([db9aca4](https://github.com/peerigon/clockodo/commit/db9aca46e6fec0366767e8c63d3d6509e11381d8))
- added overtimecarry model and api request ([b062946](https://github.com/peerigon/clockodo/commit/b0629465e8213cd3e5ef8e6e29acf9fa6eb1bab2))

# [21.14.0](https://github.com/peerigon/clockodo/compare/v21.13.0...v21.14.0) (2023-10-24)

### Features
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -754,50 +754,50 @@ await clockodo.editUser({ id: 33, name: "Moalo Loco" });

## Delete methods

### deactivateCustomer()
### deleteCustomer()

Deactivates (not deletes) customer.
Deletes the customer.

#### Example:

```js
await clockodo.deactivateCustomer({ id: 343 });
await clockodo.deleteCustomer({ id: 343 });
```

---

### deactivateProject()
### deleteProject()

Deactivates (not deletes) project.
Deletes the project.

#### Example:

```js
await clockodo.deactivateProject({ id: 8 });
await clockodo.deleteProject({ id: 8 });
```

---

### deactivateService()
### deleteService()

Deactivates (not deletes) service.
Deletes the service.

#### Example:

```js
await clockodo.deactivateService({ id: 94 });
await clockodo.deleteService({ id: 94 });
```

---

### deactivateUser()
### deleteUser()

Deactivates (not deletes) user.
Deletes user.

#### Example:

```js
await clockodo.deactivateUser({ id: 7 });
await clockodo.deleteUser({ id: 7 });
```

---
Expand Down
171 changes: 147 additions & 24 deletions src/clockodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,46 @@ describe("Clockodo (instance)", () => {
});
});

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

await clockodo.getLumpSumService({ id: 777 });

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

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

await clockodo.getLumpSumServicesPage();

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

describe("getLumpSumServices()", () => {
it("requests all lumpSumService pages", async () => {
const nockScope = setupPaginatedApiMock({
baseUrl: "/v3/lumpsumservices?",
countPages: 3,
createPageResponse: (page) => ({ lumpSumServices: [page] }),
});

const { lumpSumServices } = await clockodo.getLumpSumServices();

expect(lumpSumServices).toMatchObject([1, 2, 3]);

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

describe("getEntry()", () => {
it("correctly builds getEntry() request", async () => {
const nockScope = nock(CLOCKODO_API)
Expand Down Expand Up @@ -405,19 +445,37 @@ 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 });

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

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

await clockodo.getServicesPage();

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

describe("getServices()", () => {
it("correctly builds getServices() request", async () => {
const nockScope = nock(CLOCKODO_API).get("/services").reply(200, {});
it("requests all getServices pages", async () => {
const nockScope = setupPaginatedApiMock({
baseUrl: "/v3/services?",
countPages: 3,
createPageResponse: (page) => ({ services: [page] }),
});

await clockodo.getServices();
const { services } = await clockodo.getServices();

expect(services).toMatchObject([1, 2, 3]);

nockScope.done();
});
Expand Down Expand Up @@ -447,7 +505,9 @@ describe("Clockodo (instance)", () => {

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

await clockodo.getUser({ id: 1263 });

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

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

await clockodo.getUsers();

Expand Down Expand Up @@ -593,6 +653,18 @@ describe("Clockodo (instance)", () => {
});
});

describe("getOvertimecarry()", () => {
it("correctly builds getOvertimecarry() request", async () => {
const nockScope = nock(CLOCKODO_API)
.get("/overtimecarry?users_id=17&year=2028")
.reply(200, {});

await clockodo.getOvertimecarry({ usersId: 17, year: 2028 });

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

describe("getHolidaysquota()", () => {
it("correctly builds getHolidaysquota() request", async () => {
const nockScope = nock(CLOCKODO_API)
Expand Down Expand Up @@ -685,6 +757,26 @@ describe("Clockodo (instance)", () => {
});
});

describe("addLumpsumService()", () => {
it("correctly builds addLumpsumService() request", async () => {
const expectedParameters = {
name: "Weyland-Yutani",
price: 1,
};

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

await clockodo.addLumpsumService({
name: "Weyland-Yutani",
price: 1,
});

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

describe("addProject()", () => {
it("correctly builds addProject() request", async () => {
const expectedParameters = {
Expand Down Expand Up @@ -715,7 +807,7 @@ describe("Clockodo (instance)", () => {
};

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

await clockodo.addService({ name: "Thinking", active: true });
Expand All @@ -734,7 +826,7 @@ describe("Clockodo (instance)", () => {
};

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

await clockodo.addUser({
Expand Down Expand Up @@ -959,6 +1051,23 @@ describe("Clockodo (instance)", () => {
});
});

describe("editLumpsumService()", () => {
it("correctly builds editLumpsumService() request", async () => {
const lumpsumService = {
id: 15,
name: "Mystery Gang",
};

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

await clockodo.editLumpsumService(lumpsumService);

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

describe("editProject()", () => {
it("correctly builds editProject() request", async () => {
const project = {
Expand All @@ -985,7 +1094,7 @@ describe("Clockodo (instance)", () => {
};

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

await clockodo.editService(service);
Expand All @@ -1002,7 +1111,7 @@ describe("Clockodo (instance)", () => {
};

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

await clockodo.editUser(user);
Expand Down Expand Up @@ -1088,47 +1197,61 @@ describe("Clockodo (instance)", () => {
});
});

describe("deactivateCustomer()", () => {
it("correctly builds deactivateCustomer() request", async () => {
describe("deleteCustomer()", () => {
it("correctly builds deleteCustomer() request", async () => {
const nockScope = nock(CLOCKODO_API)
.delete("/v2/customers/343")
.reply(200, {});

await clockodo.deactivateCustomer({ id: 343 });
await clockodo.deleteCustomer({ id: 343 });

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

describe("deactivateProject()", () => {
it("correctly builds deactivateProject() request", async () => {
describe("deleteProject()", () => {
it("correctly builds deleteProject() request", async () => {
const nockScope = nock(CLOCKODO_API)
.delete("/v2/projects/8")
.reply(200, {});

await clockodo.deactivateProject({ id: 8 });
await clockodo.deleteProject({ id: 8 });

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

describe("deactivateService()", () => {
it("correctly builds deactivateService() request", async () => {
describe("deleteService()", () => {
it("correctly builds deleteService() request", async () => {
const nockScope = nock(CLOCKODO_API)
.delete("/services/94")
.delete("/v3/services/94")
.reply(200, {});

await clockodo.deactivateService({ id: 94 });
await clockodo.deleteService({ id: 94 });

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

describe("deactivateUser()", () => {
it("correctly builds deactivateUser() request", async () => {
const nockScope = nock(CLOCKODO_API).delete("/users/7").reply(200, {});
describe("deleteLumpsumService()", () => {
it("correctly builds deleteLumpsumService() request", async () => {
const nockScope = nock(CLOCKODO_API)
.delete("/v3/lumpsumservices/94")
.reply(200, {});

await clockodo.deleteLumpsumService({ id: 94 });

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

describe("deleteUser()", () => {
it("correctly builds deleteUser() request", async () => {
const nockScope = nock(CLOCKODO_API)
.delete("/v2/users/7")
.reply(200, {});

await clockodo.deactivateUser({ id: 7 });
await clockodo.deleteUser({ id: 7 });

nockScope.done();
});
Expand Down
Loading

0 comments on commit 3504e3e

Please sign in to comment.