|
| 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 |
0 commit comments