Skip to content

Commit 9e0071e

Browse files
days_exceptions & leave_types endpoints
1 parent b48e02b commit 9e0071e

5 files changed

Lines changed: 484 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This is the official Paymo API.
1414
* [Filtering](#filtering)
1515
* [Including related content](#includes)
1616
* [Webhooks](#webhooks)
17-
17+
* [Leaves Support](#leaves_support)
1818

1919
The Paymo is a [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer) API that uses JSON/XML for serialization.
2020

@@ -78,6 +78,7 @@ If you exceed the rate limit, you'll get a [429 Too Many Requests](http://tools.
7878
* [Clients](sections/clients.md)
7979
* [Comments](sections/comments.md)
8080
* [Company](sections/company.md)
81+
* [Company-Days-Exceptions](sections/companies_days_exceptions.md)
8182
* [Discussions](sections/discussions.md)
8283
* [Estimate Templates](sections/estimate_templates.md)
8384
* [Estimates](sections/estimates.md)
@@ -86,6 +87,7 @@ If you exceed the rate limit, you'll get a [429 Too Many Requests](http://tools.
8687
* [Invoice Templates](sections/invoice_templates.md)
8788
* [Invoice Payments](sections/invoice_payments.md)
8889
* [Invoices](sections/invoices.md)
90+
* [Leave Types](sections/leave_types.md)
8991
* [Milestones](sections/milestones.md)
9092
* [Project Templates](sections/project_templates.md)
9193
* [Projects](sections/projects.md)
@@ -97,6 +99,7 @@ If you exceed the rate limit, you'll get a [429 Too Many Requests](http://tools.
9799
* [Tasks](sections/tasks.md)
98100
* [Time Entries](sections/entries.md)
99101
* [Users](sections/users.md)
102+
* [Users-Days-Exceptions](sections/users_days_exceptions.md)
100103
* [User-Task Assignments](sections/users_tasks.md)
101104

102105
<a name="data-formats"></a>
@@ -128,6 +131,9 @@ By creating a webhook you create a link between an event in Paymo (e.g. adding a
128131

129132
Read more about [webhooks](sections/webhooks.md)
130133

134+
<a name="leaves_support"></a>
135+
## [Leaves Support](sections/leaves_support.md)
136+
131137
## Help us make it better
132138

133139
Please tell us how we can make the API better. If you have a specific feature request or if you found a bug, please use GitHub issues. Fork these docs and send a pull request with improvements.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Company Days Exceptions
2+
3+
Days-exceptions is a date interval that defines a working or a non-working period of time.
4+
5+
* [Getting days-exceptions intervals](#list)
6+
* [Getting a days-exceptions interval](#get)
7+
* [Creating a days-exceptions interval](#create)
8+
* [Updating a days-exceptions interval](#update)
9+
* [Deleting a days-exceptions interval](#delete)
10+
* [The days-exceptions object](#object)
11+
12+
<a name="list"></a>
13+
14+
## Getting days-exceptions intervals
15+
16+
You can list days-exceptions intervals by making a GET request to:
17+
18+
* `/api/companiesdaysexceptions`.
19+
* `/api/companiesdaysexceptions?where=is_working=false` for a list of leaves.
20+
* `/api/companiesdaysexceptions?where=is_working=true` for a list of additional working days.
21+
22+
Example of response:
23+
24+
```json
25+
{
26+
"companiesdaysexceptions":[
27+
{
28+
"id":12,
29+
"date":"2017-06-25",
30+
"end_date":"2017-06-28",
31+
"leave_type_id":2,
32+
"creator_id":23,
33+
"hours_per_day":8,
34+
"status":"approved",
35+
"description":"This is a leave.",
36+
"is_working":false,
37+
"created_on":"2017-06-07T12:10:32Z",
38+
"updated_on":"2017-06-07T12:10:32Z"
39+
},
40+
{
41+
"id":13,
42+
"date":"2017-06-29",
43+
"end_date":"2017-06-30",
44+
"leave_type_id":4,
45+
"creator_id":21,
46+
"hours_per_day":4,
47+
"status":"pending",
48+
"description":"This is an additional working period.",
49+
"is_working":true,
50+
"created_on":"2017-06-21T18:15:04Z",
51+
"updated_on":"2017-06-21T18:15:04Z"
52+
}
53+
]
54+
}
55+
```
56+
57+
<a name="get"></a>
58+
## Getting a days-exceptions interval
59+
60+
To get a days-exceptions interval, make a GET request to:
61+
62+
* `/api/companiesdaysexceptions/[COMPANY_DAYS_EXCEPTIONS_ID]`
63+
64+
Example response:
65+
66+
```json
67+
{
68+
"companiesdaysexceptions": [
69+
{
70+
"id":12,
71+
"date":"2017-06-25",
72+
"end_date":"2017-06-28",
73+
"leave_type_id":2,
74+
"creator_id":23,
75+
"hours_per_day":8,
76+
"status":"approved",
77+
"description":"This is a leave.",
78+
"is_working":false,
79+
"created_on":"2017-06-07T12:10:32Z",
80+
"updated_on":"2017-06-07T12:10:32Z"
81+
}
82+
]
83+
}
84+
```
85+
86+
You can also [include related content](includes.md) when getting a days-exceptions interval.
87+
88+
<a name="create"></a>
89+
## Creating a days-exceptions interval
90+
91+
To create a days-exceptions interval, make a POST request to:
92+
93+
* `/api/companiesdaysexceptions`
94+
95+
with the request body containing the new days-exceptions info, as in the examples below:
96+
97+
```json
98+
{
99+
"date":"2017-06-25",
100+
"end_date":"2017-06-28",
101+
"is_working":false
102+
}
103+
```
104+
105+
If successful, the response will return `201 Created`. The response header `Location` will contain a link for the new days-exceptions interval. The response body will contain the new days-exceptions info as in the **Getting a days-exceptions interval** section.
106+
107+
<a name="update"></a>
108+
## Updating a days-exceptions interval
109+
110+
To update an existing days-exceptions, make a POST or PUT request to:
111+
112+
* `/api/companiesdaysexceptions/[COMPANY_DAYS_EXCEPTIONS_ID]`
113+
114+
with the request body containing the updated info. You can send only the changed fields.
115+
116+
Example of request body if you want to change the days-exceptions leave_type_id:
117+
118+
```json
119+
{
120+
"leave_type_id": 8
121+
}
122+
```
123+
124+
The response will return `200 OK` and will contain the updated days-exceptions info as in the **Getting a days-exceptions interval** section.
125+
126+
<a name="delete"></a>
127+
## Deleting a days-exceptions interval
128+
129+
To delete a days-exceptions, make a DELETE request to:
130+
131+
* `/api/companiesdaysexceptions/[COMPANY_DAYS_EXCEPTIONS_ID]`
132+
133+
If successful, the response will have a `200 OK` status code.
134+
135+
<a name="object"></a>
136+
## The days-exceptions object
137+
138+
A days-exceptions object has the following attributes:
139+
140+
Attribute|Type|Description
141+
---------|----|-----------
142+
id | integer | _(read-only)_ Unique days-exceptions identifier
143+
date | [datetime](datetime.md) | Interval start date
144+
end_date | [datetime](datetime.md) | Interval end date
145+
leave_type_id | integer | The id of the leave type from the leave_types table (optional)
146+
creator_id | integer | _(read-only)_ The id of the creator
147+
hours_per_day | integer | Number of hours for each day in interval
148+
status | text | Days-exceptions custom status
149+
description | text | Days-exceptions description
150+
is_working | boolean | Defines if a days-exceptions interval is working or it's a leave
151+
created_on | [datetime](datetime.md) | _(read-only)_ Date and time when the days-exceptions was created
152+
updated_on | [datetime](datetime.md) | _(read-only)_ Date and time when the days-exceptions was last updated

sections/leave_types.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#Leave Types
2+
3+
* [Getting leave-types](#list)
4+
* [Getting a leave-type](#get)
5+
* [Creating a leave-type](#create)
6+
* [Updating a leave-type](#update)
7+
* [Deleting a leave-type](#delete)
8+
* [The leave-type object](#object)
9+
10+
<a name="list"></a>
11+
12+
## Getting leave types
13+
14+
You can list leave types by making a GET request to:
15+
16+
* `/api/leavetypes`
17+
* `/api/leavetypes?where=paid=true` for a list of paid leave types.
18+
19+
Example of response:
20+
21+
```json
22+
{
23+
"leavetypes": [
24+
{
25+
"id":1,
26+
"name":"Vacation",
27+
"paid":true,
28+
"created_on":"2017-05-31T14:30:13Z",
29+
"updated_on":"2017-05-31T14:30:13Z"
30+
},
31+
{
32+
"id":2,
33+
"name":"Sick Leave",
34+
"paid":true,
35+
"created_on":"2017-05-31T14:30:13Z",
36+
"updated_on":"2017-05-31T14:30:13Z"
37+
}
38+
]
39+
}
40+
41+
<a name="get"></a>
42+
## Getting a leave-type
43+
44+
To get a leave-type, make a GET request to:
45+
46+
* `/api/leavetypes/[LEAVE_TYPE_ID]`
47+
48+
Example response:
49+
50+
```json
51+
{
52+
"leavetypes": [
53+
{
54+
"id":1,
55+
"name":"Vacation",
56+
"paid":true,
57+
"created_on":"2017-05-31T14:30:13Z",
58+
"updated_on":"2017-05-31T14:30:13Z"
59+
}
60+
]
61+
}
62+
```
63+
64+
You can also [include related content](includes.md) when getting a leave-type.
65+
66+
<a name="create"></a>
67+
## Creating a leave-type
68+
69+
To create a leave-type, make a POST request to:
70+
71+
* `/api/leavetypes`
72+
73+
with the request body containing the new leave-type info, as in the examples below:
74+
75+
```json
76+
{
77+
"name":"Vacation",
78+
"paid":true
79+
}
80+
```
81+
82+
If successful, the response will return `201 Created`. The response header `Location` will contain a link for the new leave-type. The response body will contain the new leave-type info as in the **Getting a leave-type** section.
83+
84+
<a name="update"></a>
85+
## Updating a leave-type
86+
87+
To update an existing leave-type, make a POST or PUT request to:
88+
89+
* `/api/leavetypes/[LEAVE_TYPE_ID]`
90+
91+
with the request body containing the updated info. You can send only the changed fields.
92+
93+
Example of request body if you want to change the leave-type name:
94+
95+
```json
96+
{
97+
"name": "Sick Leave"
98+
}
99+
```
100+
101+
The response will return `200 OK` and will contain the updated leave-type info as in the **Getting a leave-type** section.
102+
103+
<a name="delete"></a>
104+
## Deleting a leave-type
105+
106+
To delete a leave-type, make a DELETE request to:
107+
108+
* `/api/leavetypes/[LEAVE_TYPE_ID]`
109+
110+
If successful, the response will have a `200 OK` status code.
111+
112+
<a name="object"></a>
113+
## The leave-type object
114+
115+
A leave-type object has the following attributes:
116+
117+
Attribute|Type|Description
118+
---------|----|-----------
119+
id | integer | _(read-only)_ Unique leave type identifier
120+
name | text | Leave type description
121+
paid | boolean | Leave type payable status
122+
created_on | [datetime](datetime.md) | _(read-only)_ Date and time when the leave-type was created
123+
updated_on | [datetime](datetime.md) | _(read-only)_ Date and time when the leave-type was last updated

sections/leaves_support.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Leaves Support
2+
3+
There are three endpoints to consider when you want to find working/non-working days in a specific interval of time.
4+
5+
For company, get from the [company info](company.md) "working_days" and verify if contains the numeric representation of the day of the week (ISO-8601) for every date from the interval.
6+
Then, make a GET request to `/api/companiesdaysexceptions?where=date<=interval.end_date&&end_date>=interval.start_date` (see [Company Days Exceptions](companies_days_exceptions.md)) and exclude or include the intervals depending on the field "is_working".
7+
8+
For a user, you need to make a GET request to `/api/usersdaysexceptions?where=user_id=[USER_ID]&&date<=interval.end_date&&end_date>=interval.start_date` (see [Users Days Exceptions](users_days_exceptions.md)) and exclude or include the intervals from those of the company.
9+
10+
You can find the number of the working days for a user in a interval of time by making a POST request to `/api/statsreports` with the body:
11+
12+
```json
13+
{
14+
"params":{
15+
user_id: 76509,
16+
start_date: "2017-05-06T00:00:00",
17+
end_date: "2017-07-30T00:00:00"
18+
},
19+
"type": "user_working_days_count"
20+
}
21+
```
22+
23+
Example of response:
24+
25+
```json
26+
{
27+
"statsreports":[
28+
{
29+
"info": {
30+
"type":"user_working_days_count",
31+
"params": {
32+
"user_id":8,
33+
"start_date":"2017-07-06T00:00:00",
34+
"end_date":"2017-07-30T00:00:00"
35+
}
36+
},
37+
"content":[
38+
{
39+
"working_days_count":17
40+
}
41+
]
42+
}
43+
]
44+
}

0 commit comments

Comments
 (0)