ucsdeventhub / EventHub

4 stars 0 forks source link

api: http api routes #35

Open ear7h opened 4 years ago

ear7h commented 4 years ago

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 the code parameter (the email parameter is also required for the second call).

Query:

Request Body: empty Response

User routes

GET /api/users/self

Get the user data

Authorization: Bearer <token> Response: the user model for the user in the token

PUT /api/users/self/orgs/:org_id

Adds a favorite org to the user

Authorization: Bearer <token> Request: None Response:

DELETE /api/users/self/orgs/:org_id

Removes a favorite org from the user

Authorization: Bearer <token> Request: None Response:

PUT /api/users/self/events/:event_id

Adds a favorite event to the user

Authorization: Bearer <token> Request: None Response:

DELETE /api/users/self/events/:event_id

Removes a favorite event from the user

Authorization: Bearer <token> Request: None Response:

event routes

GET /api/events

Query:

Response

GET /api/events/trending

Get events sorted by trending Response

GET /api/events/:id

This endpoint returns the event with the given ID

Response

org routes

GET /api/orgs

Query:

Response

GET /api/orgs/:id

This endpoint returns the event with the given ID

Response

POST /api/orgs/:org_id

Update the org profile

Authorization: Bearer <token> Request: an org model (IDs and meta fields like created are ignored when stored in the database). Response

POST /api/orgs/:org_id/events/

Add a new event hosted by the org

Authorization: Bearer <token> Request: an event model (IDs and meta fields like created are ignored when stored in the database). Response:

PUT /api/orgs/:org_id/events/:event_id

Update an existing event

Authorization: Bearer <token> Request: an event model (IDs and meta fields like created are ignored when stored in the database). Response:

DELETE /api/orgs/:org_id/events/:event_id

Delete the event

Authorization: Bearer <token> Response

POST /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 like created are ignored when stored in the database). Response:

PUT /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 like created are ignored when stored in the database). Response:

DELETE /api/orgs/:org_id/events/:event_id/:announcement_id

Delete the event announcement

Authorization: Bearer <token> Response

ear7h commented 4 years ago

For all methods the following responses are also possible

For all authenticated methods, the following responses are possible: