Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get requests support #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ node_modules/

/reports/coverage/lcov-report
eslint_report.json
package-lock.json
yarn.lock
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ import Clockify from "clockify-ts";
const Clockify = require("clockify-ts").default;
```

**Note:** To use the "import"-syntax, you must use a bundler like [Webpack](https://webpack.js.org/),
**Note:** To use the "import"-syntax, you must use a bundler like [Webpack](https://webpack.js.org/),
[Parel](https://parceljs.org/) or [Vite](https://vitejs.dev/) that can handle ECMAScript modules (ESM).


### Authentication

All communication with the Clockify API needs to be authenticated using a Auth-Token. This token can be generated
in the [User Settings](https://clockify.me/user/settings) page and needs to be passed to the clockify instance.
in the [User Settings](https://clockify.me/user/settings) page and needs to be passed to the clockify instance.

If your workspace is on a subdomain (eg. something.clockify.me), you'll need to generate a new API key in your Profile Settings that will work just for that workspace.

Expand Down Expand Up @@ -79,9 +79,9 @@ const project: ProjectType = {

### Features

The following clockify API features are already well implemented and tested.
The following clockify API features are already well implemented and tested.

#### Base Endpoints
#### Base Endpoints

- Client :heavy_check_mark:
- Project :heavy_check_mark:
Expand Down Expand Up @@ -493,6 +493,23 @@ const detailedQuery: RequestDetailedReportType = {
const report = await clockify.workspaces.withId(testWorkspaceId).reports.detailed.post(detailedQuery);
```

## Requests

### Get all requests

[API Documentation](https://clockify.me/developers-api#operation--v1-workspaces--workspaceId--timeOff--requests--post)

```typescript
import type { RequestAllRequestsType } from "clockify-ts";
const clockify = new Clockify("clockifyApiKey");

const requestsAllQuery: RequestAllRequestsType = {
start: new Date(1577836800000), // Jan. 2020
end: new Date(1609459199000), // Jan. 2021
}
const requests = await clockify.workspaces.withId(testWorkspaceId).requests.all.post(requestsAllQuery);
```

## Query, Types and Enums

Here you find an exhaustive list of all Types, Queries and Enums you can import form "clockify-ts".
Expand Down
5 changes: 5 additions & 0 deletions dist/cjs/Api/TimeOffApi/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AxiosInstance } from "axios";
import ClockifyAPI from "../ClockifyApi";
export default class TimeOffApi extends ClockifyAPI {
clockifyApiInstance(apiKey: string): AxiosInstance;
}
40 changes: 40 additions & 0 deletions dist/cjs/Api/TimeOffApi/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/Api/TimeOffApi/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/cjs/Clockify/Workspaces/Workspace/Requests/All/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IPostable } from "../../../../../Api/ClockifyApi";
import { RequestAllRequestsType } from "../../../../../Types/RequestAllRequestsType";
import { AllRequestsType } from "../../../../../Types/AllRequestsType";
import TimeOffApi from "../../../../../Api/TimeOffApi";
export default class All extends TimeOffApi implements IPostable<AllRequestsType> {
workspaceId: string;
constructor(apiKey: string, workspaceId: string);
resourceSubPath(): string;
post(data: RequestAllRequestsType): Promise<AllRequestsType>;
}
38 changes: 38 additions & 0 deletions dist/cjs/Clockify/Workspaces/Workspace/Requests/All/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions dist/cjs/Clockify/Workspaces/Workspace/Requests/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import All from "./All";
import ClockifyAPI from "../../../../Api/ClockifyApi";
export default class Requests extends ClockifyAPI {
workspaceId: string;
constructor(apiKey: string, workspaceId: string);
get all(): All;
}
40 changes: 40 additions & 0 deletions dist/cjs/Clockify/Workspaces/Workspace/Requests/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/cjs/Clockify/Workspaces/Workspace/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CustomFields from "./CustomFields";
import TimeEntries from "./TimeEntries";
import UserGroups from "./UserGroups";
import Reports from "./Reports";
import Requests from "./Requests";
export default class Workspace extends ClockifyAPI {
workspaceId: string;
constructor(apiKey: string, workspaceId: string);
Expand All @@ -19,4 +20,5 @@ export default class Workspace extends ClockifyAPI {
get userGroups(): UserGroups;
get users(): Users;
get reports(): Reports;
get requests(): Requests;
}
8 changes: 8 additions & 0 deletions dist/cjs/Clockify/Workspaces/Workspace/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions dist/cjs/Types/AllRequestsType.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export declare enum AllRequestsStatusEnum {
pending = "PENDING",
approved = "APPROVED",
rejected = "REJECTED"
}
type AllRequestsType = {
count: number;
requests: {
id: string;
workspaceId: string;
policyId: string;
policyName: string;
timeUnit: string;
userId: string;
userName: string;
userEmail: string;
timeOffPeriod: {
period: {
start: Date;
end: Date;
};
halfDay: boolean;
};
note: string;
status: {
statusType: AllRequestsStatusEnum;
changedByUserId: string;
changedByUserName: string;
changedAt: Date;
note: string;
};
balanceDiff: number;
createdAt: Date;
balance: number;
requesterUserId: string;
requesterUserName: string;
}[];
};
export { AllRequestsType, };
10 changes: 10 additions & 0 deletions dist/cjs/Types/AllRequestsType.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/Types/AllRequestsType.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions dist/cjs/Types/RequestAllRequestsType.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export declare enum RequestAllRequestsStatusEnum {
pending = "PENDING",
approved = "APPROVED",
rejected = "REJECTED"
}
type RequestAllRequestsType = {
start: Date;
end: Date;
status: RequestAllRequestsStatusEnum;
users: string[];
userGroups: string[];
page: number;
pageSize: number;
};
export { RequestAllRequestsType };
10 changes: 10 additions & 0 deletions dist/cjs/Types/RequestAllRequestsType.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/Types/RequestAllRequestsType.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading