Skip to content

Commit

Permalink
Rename deactivate to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Oct 24, 2023
1 parent 0fb6afe commit be49a6e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -754,38 +754,38 @@ 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 });
```

---
Expand Down
18 changes: 9 additions & 9 deletions src/clockodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1054,37 +1054,37 @@ 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")
.reply(200, {});

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

nockScope.done();
});
Expand Down
18 changes: 9 additions & 9 deletions src/clockodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,30 +557,30 @@ export class Clockodo {
return this.api.put("/v2/users/" + id, params);
}

async deactivateCustomer(
params: Params<Pick<Customer, typeof REQUIRED.DEACTIVATE_CUSTOMER[number]>>
async deleteCustomer(
params: Params<Pick<Customer, typeof REQUIRED.DELETE_CUSTOMER[number]>>
): Promise<CustomerReturnType> {
REQUIRED.checkRequired(params, REQUIRED.DEACTIVATE_CUSTOMER);
REQUIRED.checkRequired(params, REQUIRED.DELETE_CUSTOMER);

const { id } = params;

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

async deactivateProject(
params: Params<Pick<Project, typeof REQUIRED.DEACTIVATE_PROJECT[number]>>
async deleteProject(
params: Params<Pick<Project, typeof REQUIRED.DELETE_PROJECT[number]>>
): Promise<ProjectReturnType> {
REQUIRED.checkRequired(params, REQUIRED.DEACTIVATE_PROJECT);
REQUIRED.checkRequired(params, REQUIRED.DELETE_PROJECT);

const { id } = params;

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

async deactivateService(
params: Params<Pick<Service, typeof REQUIRED.DEACTIVATE_SERVICE[number]>>
async deleteService(
params: Params<Pick<Service, typeof REQUIRED.DELETE_SERVICE[number]>>
): Promise<ServiceReturnType> {
REQUIRED.checkRequired(params, REQUIRED.DEACTIVATE_SERVICE);
REQUIRED.checkRequired(params, REQUIRED.DELETE_SERVICE);

const { id } = params;

Expand Down
6 changes: 3 additions & 3 deletions src/lib/requiredParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const CHANGE_CLOCK_DURATION = [
"durationBefore",
"duration",
] as const;
export const DEACTIVATE_CUSTOMER = ["id"] as const;
export const DEACTIVATE_PROJECT = ["id"] as const;
export const DEACTIVATE_SERVICE = ["id"] as const;
export const DELETE_CUSTOMER = ["id"] as const;
export const DELETE_PROJECT = ["id"] as const;
export const DELETE_SERVICE = ["id"] as const;
export const DELETE_USER = ["id"] as const;
export const DELETE_ENTRY = ["id"] as const;
export const DELETE_ENTRY_GROUP = ["timeSince", "timeUntil"] as const;
Expand Down

0 comments on commit be49a6e

Please sign in to comment.