Open ear7h opened 4 years ago
For all methods the following responses are also possible
500 Internal Server Error
- the server contains a bug that needs to be fixedFor all authenticated methods, the following responses are possible:
403 Forbidden
- the token is not granted permission to execute this action401 Unauthorized
- the token was not provided or was invalid/outdated (the UI should immediately purge all user data from memory, and redirect to a login page)
POST /api/login
This endpoint is used to issue the bearer tokens which are used for routes that require user authentication.
Two calls to this endpoint are required. The first with the
email
query parameter, which triggers an email message that will contain a secrete code. This secret code will the be used in the second call in thecode
parameter (theemail
parameter is also required for the second call).Query:
create
-true | false
optional. Iftrue
, the call to this endpoint will create an account, the account must not exist. Iffalse
, the call to this endpoint will only succeed if the account already exists. If not present, an account is created if needed. This parameter is ignored whencode
is present.email
-string
see abovecode
-int
see aboveRequest Body: empty Response
204 No Content
- email sent successfully409 Conflict
- ifcreate=true
the account already exists. ifcreate=false
the account does not exist.200 OK
- with the token as a json string"abcd..."
400 Bad Request
- the code was invalidUser routes
GET /api/users/self
Get the user data
Authorization:
Bearer <token>
Response: the user model for the user in the tokenPUT /api/users/self/orgs/:org_id
Adds a favorite org to the user
Authorization:
Bearer <token>
Request: None Response:204 No Content
- the org was favorited404 Not Found
- the org does not existDELETE /api/users/self/orgs/:org_id
Removes a favorite org from the user
Authorization:
Bearer <token>
Request: None Response:204 No Content
- the org was unfavorited404 Not Found
- the org does not existPUT /api/users/self/events/:event_id
Adds a favorite event to the user
Authorization:
Bearer <token>
Request: None Response:204 No Content
- the event was favorited404 Not Found
- the event does not existDELETE /api/users/self/events/:event_id
Removes a favorite event from the user
Authorization:
Bearer <token>
Request: None Response:204 No Content
- the event was unfavorited404 Not Found
- the event does not existevent routes
GET /api/events
Query:
orgs
- comma separated list ofint
, all returned events must be part of one of these orgs.tags
- comma separatedstring
, all returned events must have at least one matched tagbefore
- ISO formatted date (ex. 2020-11-12), all returned events must start before this dateafter
- ISO formatted date (ex. 2020-11-12), all returned events must end after this datelimit
-int
, the number of responsesoffset
-int
, the number of responses to skip.Response
200 OK
- a JSON list of event models400 Bad Request
- incorrect query formattingGET /api/events/trending
Get events sorted by trending Response
200 OK
- a JSON list of event modelsGET /api/events/:id
This endpoint returns the event with the given ID
Response
200 OK
- A single event model404 Not Found
- the event with the id does not existorg routes
GET /api/orgs
Query:
tags
- comma separatedstring
, all returned orgs must have at least one matched taglimit
-int
, the number of responsesoffset
-int
, the number of responses to skip.Response
200 OK
- A list of org models400 Bad Request
- incorrect query formattingGET /api/orgs/:id
This endpoint returns the event with the given ID
Response
200 OK
- A single event model404 Not Found
- the event with the id does not existPOST /api/orgs/:org_id
Update the org profile
Authorization:
Bearer <token>
Request: an org model (IDs and meta fields likecreated
are ignored when stored in the database). Response200 OK
- the org was successfully updated, the new org model is returned400 Bad Request
- the request had improperly formatted jsonPOST /api/orgs/:org_id/events/
Add a new event hosted by the org
Authorization:
Bearer <token>
Request: an event model (IDs and meta fields likecreated
are ignored when stored in the database). Response:200 OK
- the event was successfully created, the event with IDs and meta fields is returned400 Bad Request
- the request had improperly formatted json403 Forbidden
- the token is not granted permission to execute this actionPUT /api/orgs/:org_id/events/:event_id
Update an existing event
Authorization:
Bearer <token>
Request: an event model (IDs and meta fields likecreated
are ignored when stored in the database). Response:200 OK
- the event was successfully updated, the event with IDs and meta fields is returned400 Bad Request
- the request had improperly formatted json404 Not Found
- theevent_id
does not existDELETE /api/orgs/:org_id/events/:event_id
Delete the event
Authorization:
Bearer <token>
Response200 OK
- the event was successfully deleted404 Not Found
- theevent_id
was invalidPOST /api/orgs/:org_id/events/:event_id/announcements
Add an announcement to an event Authorization:
Bearer <token>
Request: an announcement model (IDs and meta fields likecreated
are ignored when stored in the database). Response:200 OK
- the event announcement was successfully created, the announcement with IDs and meta fields is returned400 Bad Request
- the request had improperly formatted json404 Not Found
- theevent_id
does not existPUT /api/orgs/:org_id/events/:event_id/announcements/:announcement_id
Update an existing event announcement
Authorization:
Bearer <token>
Request: an announcement model (IDs and meta fields likecreated
are ignored when stored in the database). Response:200 OK
- the event announcement was successfully updated, the event with IDs and meta fields is returned400 Bad Request
- the request had improperly formatted json404 Not Found
- theevent_id
or theannouncement_id
was invalidDELETE /api/orgs/:org_id/events/:event_id/:announcement_id
Delete the event announcement
Authorization:
Bearer <token>
Response200 OK
- the event annoucement was successfully deleted404 Not Found
- theevent_id
or theannouncement_id
was invalid