Skip to content

Commit

Permalink
feature/api-v1-presences (#4)
Browse files Browse the repository at this point in the history
* added presences api description

* updated params for index

* added namespace

* added namespace

* more up to date examples
  • Loading branch information
agileapplications committed Nov 1, 2018
1 parent 465481e commit 450701c
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ All the entities exposed via the API can be found in their respective sections.
* [Schedules](sections/schedules.md)
* [Units / Teams](sections/units.md)
* [Users](sections/users.md)
* [User Presences](sections/presences.md)

## Authentication

Expand Down
100 changes: 100 additions & 0 deletions sections/presences.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# User Presences
German: "Arbeitszeiten"

## Attributes

Presences contain among the standard fields also:
* User (creator)

```json
{
"id": 982237015,
"date": "2018-07-03",
"from": "07:30",
"to": "13:15",
"user": {
"id": 933590696,
"firstname": "John",
"lastname": "Doe"
}
}
```

## GET /users/presences

Retrieve all presences:

```bash
curl -X GET \
'https://{domain}.mocoapp.com/api/v1/users/presences?from=2018-06-01&to=2018-06-30' \
-H 'Authorization: Token token={api-key}'
```

This returns an array of all presences.

The following parameters can be supplied:

* **from, to** – "2018-06-01", "2018-06-30" (from and to have to be provided together)
* **user_id** – 123


## GET /users/presences/{id}

Retrieve a single presence:

```bash
curl -X GET \
'https://{domain}.mocoapp.com/api/v1/users/presences/{id}' \
-H 'Authorization: Token token={api-key}'
```

## POST /users/presences

Create a presence:

Every presence is created for the user that the API key belongs to.

```bash
curl -X POST \
'https://{domain}.mocoapp.com/api/v1/users/presences' \
-H 'Authorization: Token token={api-key}' \
-H 'Content-Type: application/json' \
-d '{
"date": "2018-06-11",
"from": "08:00",
"to": "10:00"
}'
```

Mandatory fields are marked with a star (*):

* **date*** – "2018-06-11"
* **from*** – "08:00"
* **to** – "12:30" (End time, can be left blank)

## PUT /users/presences/{id}

Update a presence.

```bash
curl -X PUT \
'https://{domain}.mocoapp.com/api/v1/users/presences/{id}' \
-H 'Authorization: Token token={api-key}' \
-H 'Content-Type: application/json' \
-d '{
"to": "14:00"
}'
```

All fields are analogous to the POST request.

## DELETE /users/presences/{id}

Delete a presence.

```bash
curl -X DELETE \
'https://{domain}.mocoapp.com/api/v1/users/presences/{id}' \
-H 'Authorization: Token token={api-key}'
```

0 comments on commit 450701c

Please sign in to comment.