-
POST /api/users
-
Headers
- Required: Content-Type: application/json
-
Data Params
{ "user": { "email": [string], "password": [string], "password_confirmation": [string] } }
-
Success Response:
- Code: 201 CREATED
Content:{"data":{"id":[integer],"type":"users","attributes":{"email":[string]}}}
- Code: 201 CREATED
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "errors" : ["Email has already been taken"] }
- Code: 400 BAD REQUEST
-
Sample Call:
curl -X POST -H "Content-Type: application/json" -d '{"user": {"email": "xyz","password":"xyz"}}' http://localhost:3000/api/users
-
POST /api/users
-
Headers
- Required: Content-Type: application/json
-
Data Params
{ "user": { "email": [string], "password": [string], "password_confirmation": [string] } }
-
Success Response:
- Code: 201 CREATED
Content:{"data":{"id":[integer],"type":"users","attributes":{"email":[string]}}}
- Code: 201 CREATED
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "errors" : ["Email has already been taken"] }
- Code: 400 BAD REQUEST
-
Sample Call:
curl -X POST -H "Content-Type: application/json" -d '{"user": {"email":"xyz","password":"xyz","password_confirmation":"xyz"}}' http://localhost:3000/api/users
-
Notes:
To use API user needs to have access token. To get one, post to /oauth/token (see the endpoint description below)
-
POST /oauth/token
-
Headers
- Required: Content-Type: application/json
-
Data Params
{ "grant_type": "password", "email": [string], "password": [string] }
-
Success Response:
- Code: 200 OK
Content:
{ "access_token": [string], "token_type": "bearer", "expires_in": [integer], "refresh_token": [string], "created_at": [integer] }
- Code: 200 OK
-
Error Response:
- Code: 401 UNAUTHORIZED
Content:
{ "error": "invalid_grant", "error_description": "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client." }
- Code: 401 UNAUTHORIZED
-
Sample Call:
curl -X POST -H "Content-Type: application/json" -d '{"grant_type":"password","email":"xyz","password":"xyz"}' http://localhost:3000/oauth/token
-
Notes: The access token needs to be included in headers in every request other than user registration in order to access API resources.
-
POST /api/events
-
Headers
-
Required:
Content-Type: application/json
Authorization: Bearer [access token]
-
-
Data Params
{ "event": { "time": [datetime], "place": [string], "purpose": [string] } }
-
Success Response:
- Code: 201 CREATED
Content:
{ "data": { "id": [integer], "type": "events", "attributes": { "time": [datetime], "place": [string], "purpose": [string] } } }
- Code: 201 CREATED
-
Error Response:
- Code: 400 BAD REQUEST
Content:{"error": "Time should be in the future"}
- Code: 400 BAD REQUEST
-
Sample Call:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" -d '{"event":{"time":"2018-01-25 06:34:13 UTC","purpose":"wedding"}}' http://localhost:3000/api/events
-
GET /api/events
-
Headers
- Required: none
-
URL Params
-
Required:
due: [datetime in iso8601 format]
-
-
Success Response:
- Code: 200 OK
Content:
{ "data": [ { "id": [integer], "type": "events", "attributes": { "time": [datetime], "place": [string], "purpose": [string] } } ] }
- Code: 200 OK
-
Error Responses:
-
Code: 400 BAD REQUEST
Content:{"error": "Time interval should be in ISO8601 format"}
-
Code: 400 BAD REQUEST
Content:{"error": "No time interval provided"}
-
-
Sample Call:
curl -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events?due=2019-01-01T04:05:06
-
GET /api/events/:id
-
Headers
-
Required:
Authorization: Bearer [access token]
-
-
Success Response:
- Code: 200 OK
Content:
{ "id": [integer], "time": [datetime], "place": [string], "purpose": [string], "created_at": [datetime], "updated_at": [datetime], "owner": [integer] }
- Code: 200 OK
-
Error Responses:
- Code: 404 NOT FOUND
Content:{"error": "The event does not exist"}
- Code: 404 NOT FOUND
-
Sample Call:
curl -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3
-
PUT or PATCH /api/events/:id
-
Headers
-
Required:
Content-Type: application/json
Authorization: Bearer [access token]
-
-
Data Params
{ "event": { "time": [datetime], "place": [string], "purpose": [string] } }
-
Success Response:
- Code: 200 OK
Content:
{ "data": { "id": [integer], "type": "events", "attributes": { "time": [datetime], "place": [string], "purpose": [string] } } }
- Code: 200 OK
-
Error Response:
- Code: 400 BAD REQUEST
Content:{"error": "Time should be in the future"}
- Code: 400 BAD REQUEST
-
Sample Call:
curl -X UPDATE -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" -d '{"event":{"time":"2018-01-25 06:34:13 UTC","purpose":"wedding"}}' http://localhost:3000/api/events/3
-
DELETE /api/events/:id
-
Headers
-
Required:
Authorization: Bearer [access token]
-
-
Success Response:
- Code: 200 OK
Content:
{"message": "The event has been deleted"}
- Code: 200 OK
-
Error Response:
- Code: 404 NOT FOUND
Content:{"error": "The event does not exist"}
- Code: 404 NOT FOUND
-
Sample Call:
curl -X DELETE -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3
-
POST /api/events/:id/invite
-
Headers
-
Required:
Content-Type: application/json
Authorization: Bearer [access token]
-
-
Data Params
{ "users": { "emails": [ [string] ] } }
-
Success Response:
- Code: 200 OK
Content:
{"message": "Users have been successfully invited"}
- Code: 200 OK
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "error": [ "<email> is not among registered users" ] }
- Code: 400 BAD REQUEST
-
Sample Call:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3/invite
-
GET /api/events/:id/feed
-
Headers
-
Required:
Content-Type: application/json
Authorization: Bearer [access token]
-
-
Success Response:
- Code: 200 OK
Content:
[{ "id":[integer], "type":"attachments", "attributes": { "filename":[string], "content_type":[string], "file_contents":[string], "event_id":[integer], "created_at":[datetime], "updated_at":[datetime], "user_id":[integer]} }, { "id":[integer], "type":"comments", "attributes": { "text":[string], "created_at":[datetime], "updated_at":[datetime], "user_id":[integer], "event_id":[integer] } ... }]
- Code: 200 OK
-
Error Response:
- Code: 403 FORBIDDEN
Content:{errors: 'User cannot modify this resource'}
- Code: 403 FORBIDDEN
-
Sample Call:
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3/feed
-
POST /api/events/:event_id/attachments
-
Headers
-
Required:
Content-Type: application/json
Authorization: Bearer [access token]
-
-
Data Params
{ "attachment": { "filename": [string], "content_type": [string], "file_contents": [string] } }
-
Success Response:
- Code: 201 CREATED
Content:
{"message": "File has been saved"}
- Code: 201 CREATED
-
Error Response:
-
Code: 400 BAD REQUEST
Content:{"error": "No files to attach"}
-
Code: 404 NOT FOUND
Content:{"error": "No such event or attachment"}
-
Code: 403 FORBIDDEN
Content:{"message": "User cannot modify this resource"}
-
-
Sample Call:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3/attachments
-
DELETE /api/events/:event_id/attachments/:id
-
Headers
-
Required:
Authorization: Bearer [access token]
-
-
Success Response:
- Code: 200 OK
Content:
{"data": {"message": "File has been deleted"}}
- Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{"errors": "No such event or attachment"}
-
Code: 403 FORBIDDEN
Content:{"data":{"message": "User cannot modify this resource"}}
-
-
Sample Call:
curl -X DELETE -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3/attachments/1
-
GET /api/events/:event_id/comments
-
Headers
-
Required:
Authorization: Bearer [access token]
-
-
Success Response:
- Code: 200 OK
Content:
{ "data": [{ "id": [integer], "type": "comments", "attributes": { "text": [string] } }] }
- Code: 200 OK
-
Error Response:
- Code: 403 FORBIDDEN
- Code: 400 BAD REQUEST
- Code: 403 FORBIDDEN
-
Sample Call:
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3/comments
-
POST /api/events/:event_id/comments
-
Headers
-
Required:
Content-Type: application/json
Authorization: Bearer [access token]
-
-
Data Params
{ "text": [string] }
-
Success Response:
- Code: 201 CREATED
Content:
{ "data": { "id": [integer], "type": "comments", "attributes": { "text": [string] } } }
- Code: 201 CREATED
-
Error Response:
- Code: 403 FORBIDDEN
- Code: 400 BAD REQUEST
- Code: 403 FORBIDDEN
-
Sample Call:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" -d '{"text":"hello world"}' http://localhost:3000/api/events/3/comments
-
PUT or PATCH /api/events/:event_id/comments/:id
-
Headers
-
Required:
Content-Type: application/json
Authorization: Bearer [access token]
-
-
Data Params
{ "text": [string] }
-
Success Response:
- Code: 200 OK
Content:
{ data: { message: 'The comment has been updated' } }
- Code: 200 OK
-
Error Response:
- Code: 403 FORBIDDEN
Code: 400 BAD REQUEST
- Code: 403 FORBIDDEN
-
Sample Call:
curl -X UPDATE -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" -d '{"text":"something new"}' http://localhost:3000/api/events/3/comments/1
-
DELETE /api/events/:event_id/comments/:id
-
Headers
-
Required:
Authorization: Bearer [access token]
-
-
Success Response:
- Code: 200 OK
Content:
{data: {message: 'The comment has been deleted'}}
- Code: 200 OK
-
Error Response:
- Code: 403 FORBIDDEN
- Code: 404 NOT FOUND
Content:
{"errors": "The comment does not exist"}
- Code: 403 FORBIDDEN
-
Sample Call:
curl -X DELETE -H "Content-Type: application/json" -H "Authorization: Bearer ab5847534f519d4fd5caa7424f27a471e9aa50c9c7d6a9ce543c18c87a7032f0" http://localhost:3000/api/events/3/comments/1