Days Off
System starts with no off days defined:
But we can add single or multi day events:
Response: HTTP 200, application/json (Hide)
POST /day-offs
Payload:
1 2 3 4 5 6
{
"name": "Christmas",
"start_date": "2014-12-25",
"end_date": "2014-12-25",
"repeat_yearly": true
}Response:
1 2 3 4 5 6 7 8 9 10 11 12
{
"single": {
"id": 1,
"class": "DayOff",
"url_path": "\/day-offs\/1",
"name": "Christmas",
"start_date": 1419465600,
"end_date": 1419465600,
"is_multi_day": false,
"repeat_yearly": true
}
}Response: HTTP 200, application/json (Hide)
POST /day-offs
Payload:
1 2 3 4 5 6
{
"name": "My 1st",
"start_date": "2014-05-01",
"end_date": "2014-05-03",
"repeat_yearly": true
}Response:
1 2 3 4 5 6 7 8 9 10 11 12
{
"single": {
"id": 2,
"class": "DayOff",
"url_path": "\/day-offs\/2",
"name": "My 1st",
"start_date": 1398902400,
"end_date": 1399075200,
"is_multi_day": true,
"repeat_yearly": true
}
}To update a record, simply send a PUT request, like we did in case of the spelling error for the second event that we added:
Response: HTTP 200, application/json (Hide)
PUT /day-offs/2
Payload:
1 2 3
{
"name": "May 1st"
}Response:
1 2 3 4 5 6 7 8 9 10 11 12
{
"single": {
"id": 2,
"class": "DayOff",
"url_path": "\/day-offs\/2",
"name": "May 1st",
"start_date": 1398902400,
"end_date": 1399075200,
"is_multi_day": true,
"repeat_yearly": true
}
}Now we can check /day-offs collection:
Response: HTTP 200, application/json (Hide)
GET /day-offs
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
[
{
"id": 2,
"class": "DayOff",
"url_path": "\/day-offs\/2",
"name": "May 1st",
"start_date": 1398902400,
"end_date": 1399075200,
"is_multi_day": true,
"repeat_yearly": true
},
{
"id": 1,
"class": "DayOff",
"url_path": "\/day-offs\/1",
"name": "Christmas",
"start_date": 1419465600,
"end_date": 1419465600,
"is_multi_day": false,
"repeat_yearly": true
}
]Dropping records is easy - just send a DELETE request:
Response: HTTP 200, text/html
DELETE /day-offs/2