Skip to content

Commit

Permalink
feat: added overtimecarry model and api request
Browse files Browse the repository at this point in the history
  • Loading branch information
dsumer committed Oct 9, 2023
1 parent 8b5e133 commit b062946
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/clockodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
WorkTimeChangeRequestStatus,
WorkTimeDay,
} from "./models/workTimes.js";
import { OvertimecarryRow } from "./models/overtimecarry.js";

export class Clockodo {
api: Api;
Expand Down Expand Up @@ -765,6 +766,12 @@ export class Clockodo {
remainingParams
);
}

async getOvertimecarry(
params?: Params<OvertimecarryRowParams>
): Promise<OvertimecarryRowReturnType> {
return this.api.get("/overtimecarry", params);
}
}

export type AbsenceReturnType = { absence: Absence };
Expand Down Expand Up @@ -1053,3 +1060,13 @@ export type AddWorkTimesChangeRequestReturnType =
**/
replacedChangeRequest: null;
};

export type OvertimecarryRowReturnType = {
overtimecarry: Array<OvertimecarryRow>;
};
export type OvertimecarryRowParams = {
/** The user ID by which the overtime carry rows should be filtered */
usersId?: number;
/** The year to which the data should be restricted to */
year?: number;
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from "./models/holidaysquota.js";
export * from "./models/lumpsumService.js";
export * from "./models/nonbusinessDay.js";
export * from "./models/nonbusinessGroup.js";
export * from "./models/overtimecarry.js";
export * from "./models/project.js";
export * from "./models/service.js";
export * from "./models/targethours.js";
Expand Down
1 change: 1 addition & 0 deletions src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from "./models/entry.mocks.js";
// export * from "./models/holidaysquota.mocks.js";
export * from "./models/lumpsumService.mocks.js";
export * from "./models/nonbusinessDay.mocks.js";
export * from "./models/overtimecarry.mocks.js";
export * from "./models/project.mocks.js";
// export * from "./models/service.mocks.js";
export * from "./models/targethours.mocks.js";
Expand Down
16 changes: 16 additions & 0 deletions src/models/overtimecarry.mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { faker } from "@faker-js/faker";
import { OvertimecarryRow } from "./overtimecarry.js";

export const createOvertimecarryMocks = ({
count = 1,
usersId = 0,
}: { count?: number; usersId?: number } = {}) => {
return Array.from({ length: count }, (): OvertimecarryRow => {
return {
usersId,
year: faker.datatype.number({ min: 1900, max: 2024 }),
note: faker.datatype.boolean() ? faker.lorem.sentences(2) : null,
hours: faker.datatype.number({ min: 0, max: 100 }),
};
});
};
12 changes: 12 additions & 0 deletions src/models/overtimecarry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export type OvertimecarryRow = {
/** The related employee's ID */
usersId: number;
/**
* Year for which the overtime carryover applies
* Format YYYY
*/
year: number;
/** Number of hours */
hours: number;
note: string | null;
};

0 comments on commit b062946

Please sign in to comment.