Skip to content
larsverp edited this page May 25, 2020 · 2 revisions

The events endpoind is used to list and create events.

📄 Checklist

  • Create a get method, so the events can be shown.
  • Create a create method, so new events can be created.
  • Create an update method, so events can be changed.
  • Create a remove method, so events can be removed.

📖 Get events (get method)

The get endpoints do not use any body text.

  • /api/events/preview returns all event. - For not authenticated users.
  • /api/events returns all events. - Authenticated users only!
  • /api/events/[id] returns event with specific id.
❌ Errors:
  • [] - There are no events to show
  • 404 - The specific event you're looking for doesn't exist.
✔️ On succes:

200 OK - returns a JSON object with all/specific event(s).


✏️ Create events (post method)

The post endpoints require all body data as described.

  • /api/events returns the data added to the DB.
    • title (required, string, max:191) - The title.
    • description (required, text) - The description.
    • host_id (uuid, exists in host table) - The event host.
    • begin_date (required, timestamp, after or equal to today) - The start date (and time) of the new event.
    • end_date (required, timestamp, after or equal to begin_date) - The end date (and time) of the new event.
    • thumbnail (required, url, max:1000) - The url of a image used as a thumbnail..
    • seats (required, int, min:0) - Total available seats.
    • postal_code (required, string, NL/BE/DE postal code) - Postal code of the location.
    • hnum (required, string, max:191) - House number of the location.
    • categories (required, array, uuids) - Array containing the UUIDs from the categories you wish to add.
    • notification (required, bool) - True if you want to send a mail about the new event.
    • rockstar (required, bool) - True if you want this event to be rockstars only.
❌ Errors:
  • Error is only trown when body data is incorrect. Errors are in english like the example below.
{
    "message": "The given data was invalid.",
    "errors": {
        "title": [
            "The title has already been taken."
        ],
        "thumbnail": [
            "The thumbnail is not a valid URL."
        ],
        "postal_code": [
            "This postal code is not recognized. Insert something like: 1234 AB, 4000, 26133 "
        ]
    }
}
✔️ On succes:

201 Created - returns a JSON object with the created event data.


📝 Update events (put method)

The put endpoints do not require anything in the body. Only add the fields you want to change to the body.

  • /api/events/[id] returns the entire (edited) event.
    • title (string, max:191) - The title.
    • description (text) - The description.
    • host_id (uuid, exists in host table) - The event host.
    • begin_date (timestamp, after or equal to today) - The start date (and time) of the new event.
    • end_date (timestamp, after or equal to begin_date) - The end date (and time) of the new event.
    • thumbnail (url, max:191) - The url of a image used as a thumbnail..
    • seats (int, min:0) - Total available seats.
    • postal_code (string, NL/BE/DE postal code) - Postal code of the location.
    • hnum (string, max:191) - House number of the location.
    • notification (bool) - True if you want to send a mail about the new event.
❌ Errors:
  • Errors are equal to the create endpoint
  • No error will be trown when the body is empty
✔️ On succes:

200 OK - returns a JSON object with the updated event data.


🙅 Remove events (delete method)

The delete endpoint does not require anything in the body.

  • /api/events/[id] removes the event and returns it.
❌ Errors:

404 Not found - The requested events does not exist

✔️ On succes:

200 OK - returns a JSON object with the removed event.