Skip to content

Commit

Permalink
Merge branch 'main' into overtimereduced
Browse files Browse the repository at this point in the history
  • Loading branch information
dsumer committed Nov 28, 2023
2 parents ca04f9d + de86396 commit 81e98a6
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 48 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# [23.0.0](https://github.com/peerigon/clockodo/compare/v22.2.0...v23.0.0) (2023-11-21)

### Bug Fixes

- Rename HolidaysQuota and HolidaysCarryover ([#145](https://github.com/peerigon/clockodo/issues/145)) ([16543bf](https://github.com/peerigon/clockodo/commit/16543bffc60339daf05f1ad1f46efd2a4ef30207))

### BREAKING CHANGES

- We've renamed `HolidayscarryRow` to `HolidaysCarryover` and `HolidaysquotaRow` to `HolidaysQuota` and adjusted all method names accordingly to make the naming more consistent.

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

### Features
Expand Down
24 changes: 12 additions & 12 deletions src/clockodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,25 +677,25 @@ describe("Clockodo (instance)", () => {
});
});

describe("getHolidaysquota()", () => {
it("correctly builds getHolidaysquota() request", async () => {
describe("getHolidaysQuotas()", () => {
it("correctly builds getHolidaysQuotas() request", async () => {
const nockScope = nock(CLOCKODO_API)
.get("/holidaysquota?users_id=17")
.reply(200, {});

await clockodo.getHolidaysquota({ usersId: 17 });
await clockodo.getHolidaysQuotas({ usersId: 17 });

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

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

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

nockScope.done();
});
Expand Down Expand Up @@ -896,8 +896,8 @@ describe("Clockodo (instance)", () => {
describe("addAbsence()", () => {
it("correctly builds addAbsence() request", async () => {
const expectedParameters = {
date_since: "2017-08-18 00:00:00",
date_until: "2018-02-09 00:00:00",
date_since: "2017-08-18",
date_until: "2018-02-09",
type: AbsenceType.SpecialLeave,
note: "elternzeit",
};
Expand All @@ -907,8 +907,8 @@ describe("Clockodo (instance)", () => {
.reply(200, {});

await clockodo.addAbsence({
dateSince: "2017-08-18 00:00:00",
dateUntil: "2018-02-09 00:00:00",
dateSince: "2017-08-18",
dateUntil: "2018-02-09",
type: AbsenceType.SpecialLeave,
note: "elternzeit",
});
Expand All @@ -921,8 +921,8 @@ describe("Clockodo (instance)", () => {
return expect(
// @ts-expect-error Intentional error just for the test
clockodo.addAbsence({
dateSince: "2017-08-18 00:00:00",
dateUntil: "2018-02-09 00:00:00",
dateSince: "2017-08-18",
dateUntil: "2018-02-09",
})
).rejects.toThrowError('Missing required parameter "type"');
});
Expand Down
30 changes: 15 additions & 15 deletions src/clockodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ import {
WorkTimeDay,
} from "./models/workTimes.js";
import { OvertimeCarryover } from "./models/overtimeCarryover.js";
import { HolidaysquotaRow } from "./models/holidaysquota.js";
import { HolidayscarryRow } from "./models/holidayscarry.js";
import { OvertimeReduction } from "./models/overtimeReduction.js";
import { HolidaysQuota } from "./models/holidaysQuota.js";
import { HolidaysCarryover } from "./models/holidaysCarryover.js";

export class Clockodo {
api: Api;
Expand Down Expand Up @@ -847,22 +847,22 @@ export class Clockodo {
return this.api.get("/overtimecarry", params);
}

async getHolidaysquota(
params?: Params<HolidaysquotaRowParams>
): Promise<HolidaysquotaRowReturnType> {
async getHolidaysQuotas(
params?: Params<HolidaysQuotasParams>
): Promise<HolidaysQuotasReturnType> {
return this.api.get("/holidaysquota", params);
}

async getHolidayscarry(
params?: Params<HolidayscarryRowParams>
): Promise<HolidayscarryRowReturnType> {
async getHolidaysCarryovers(
params?: Params<HolidaysCarryoversParams>
): Promise<HolidaysCarryoversReturnType> {
return this.api.get("/holidayscarry", params);
}

async getOvertimeReductions(
params?: Params<OvertimeReductionsParams>
): Promise<OvertimeReductionsReturnType> {
return this.api.get("/overtimeReductions", params);
return this.api.get("/v2/overtimeReductions", params);
}
}

Expand Down Expand Up @@ -1188,18 +1188,18 @@ export type OvertimeReductionsParams = {
usersId?: number;
};

export type HolidaysquotaRowReturnType = {
holidaysquota: Array<HolidaysquotaRow>;
export type HolidaysQuotasReturnType = {
holidaysquota: Array<HolidaysQuota>;
};
export type HolidaysquotaRowParams = {
export type HolidaysQuotasParams = {
/** The user ID by which the holidays quota rows should be filtered */
usersId?: number;
};

export type HolidayscarryRowReturnType = {
holidayscarry: Array<HolidayscarryRow>;
export type HolidaysCarryoversReturnType = {
holidayscarry: Array<HolidaysCarryover>;
};
export type HolidayscarryRowParams = {
export type HolidaysCarryoversParams = {
/** The user ID by which the holidays carry rows should be filtered */
usersId?: number;
/** The year to which the data should be restricted to */
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export * from "./models/dateTime.js";
export * from "./models/entriesText.js";
export * from "./models/entry.js";
export * from "./models/entryGroup.js";
export * from "./models/holidayscarry.js";
export * from "./models/holidaysquota.js";
export * from "./models/holidaysCarryover.js";
export * from "./models/holidaysQuota.js";
export * from "./models/lumpsumService.js";
export * from "./models/nonbusinessDay.js";
export * from "./models/nonbusinessGroup.js";
Expand Down
4 changes: 2 additions & 2 deletions src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export * from "./models/absence.mocks.js";
export * from "./models/customer.mocks.js";
export * from "./models/entry.mocks.js";
// export * from "./models/entryGroup.mocks.js";
export * from "./models/holidayscarry.mocks.js";
export * from "./models/holidaysquota.mocks.js";
export * from "./models/holidaysCarryover.mocks.js";
export * from "./models/holidaysQuota.mocks.js";
export * from "./models/lumpsumService.mocks.js";
export * from "./models/service.mocks.js";
export * from "./models/nonbusinessDay.mocks.js";
Expand Down
10 changes: 6 additions & 4 deletions src/models/absence.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { IsoDate } from "./dateTime.js";

type CommonAbsence = {
/** ID of the absence */
id: number;
/** ID of the corresponding co-worker */
usersId: number;
/** Start date in YYYY-MM-DD format */
dateSince: string;
dateSince: IsoDate;
/**
* End date in YYYY-MM-DD format
* Is the same date as dateSince in case the absence is only one day long
**/
dateUntil: string; // | null (as stated in the docs) doesn't seem to be correct
dateUntil: IsoDate; // | null (as stated in the docs) doesn't seem to be correct
/**
* Status of the absence.
*/
Expand All @@ -27,12 +29,12 @@ type CommonAbsence = {
* Date at which the absence request has been enquired in YYYY-MM-DD format.
* Only with access rights for absence administration or in case of own absences
*/
dateEnquired?: string | null;
dateEnquired?: IsoDate | null;
/**
* Date at which the absence request has been approved, declined or cancelled in format YYYY-MM-DD.
* Only with access rights for absence administration or in case of own absences
*/
dateApproved?: string | null;
dateApproved?: IsoDate | null;
/**
* The ID of the co-worker who has approved, declined or cancelled the request.
* Only with access rights for absence administration or in case of own absences
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { faker } from "@faker-js/faker";
import { HolidayscarryRow } from "./holidayscarry.js";
import { HolidaysCarryover } from "./holidaysCarryover.js";

type Options = {
count?: number;
yearMinMax?: [number, number];
};

export const createHolidayscarryMocks = ({
export const createHolidaysCarryoverMocks = ({
count = 1,
yearMinMax = [1900, 2024],
}: Options = {}) => {
return Array.from({ length: count }, (): HolidayscarryRow => {
return Array.from({ length: count }, (): HolidaysCarryover => {
return {
usersId: 0,
year: faker.datatype.number({ min: yearMinMax[0], max: yearMinMax[1] }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type HolidayscarryRow = {
export type HolidaysCarryover = {
/** The related employee's ID */
usersId: number;
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { faker } from "@faker-js/faker";
import { HolidaysquotaRow } from "./holidaysquota.js";
import { HolidaysQuota } from "./holidaysQuota.js";

type Options = {
count?: number;
yearSinceMinMax?: [number, number];
yearUntilMinMax?: [number, number];
};

export const createHolidaysquotaMocks = ({
export const createHolidaysQuotaMocks = ({
count = 1,
yearSinceMinMax = [2020, 2021],
yearUntilMinMax = [2021, 2022],
}: Options = {}) => {
return Array.from({ length: count }, (_, index): HolidaysquotaRow => {
return Array.from({ length: count }, (_, index): HolidaysQuota => {
const id = index;

return {
Expand Down
7 changes: 1 addition & 6 deletions src/models/holidaysquota.ts → src/models/holidaysQuota.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type HolidaysquotaRow = {
export type HolidaysQuota = {
/** The ID of the holiday quota settings */
id: number;
/** The related employee's ID */
Expand All @@ -15,8 +15,3 @@ export type HolidaysquotaRow = {
count: number;
note: string | null;
};

/**
* @deprecated Please use HolidaysquotaRow type
*/
export type HolidayquotaRow = HolidaysquotaRow;

0 comments on commit 81e98a6

Please sign in to comment.