Skip to content
larsverp edited this page May 22, 2020 · 1 revision

The mails endpoind is used to list and create emails. It's also used to send/resend verification emails.

🚨FOR ALL MAIL ENDPOINTS (Except the verify endpoint) A ROCKSTARS AUTHENTICATION SCOPE IS REQUIRED🚨

📄 Checklist

  • Create a get method, so the mails can be shown.
  • Create a create method, so new mails can be created.
  • Create an update method, so mails can be changed.
  • Create a remove method, so mails can be removed.
  • Create a mails/verify endpoint so a verification email can be (re)send.
  • Create a mails/event endpoint for sending new event emails.

📖 Get mails (get method)

The get endpoints do not use any body text.

  • /api/mails returns all emails.
  • /api/mails/[id] returns email with specific id.
❌ Errors:
  • [] - There are no emails to show
  • 404 - The specific email you're looking for doesn't exist.
✔️ On succes:

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


✏️ Create emails(post method)

The post endpoints require all body data as described.

  • /api/mails returns the data added to the DB.
    • title (required, string, max:191, unique) - The title.
    • language (required, string, max:191) - The language the email is written in.
    • subject (required, string, max:191) - The subject of the email.
    • body (required, string, max:16.500.00) - The body of the email (This is probably HTML).
❌ 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."
        ]
    }
}
✔️ On succes:

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


📝 Update email (put method)

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

  • /api/mails/[id] returns the entire (edited) email.
    • title (string, max:191, unique) - The title.
    • language (string, max:191) - The language the email is written in.
    • subject (string, max:191) - The subject of the email.
    • body (string, max:16.500.00) - The body of the email (This is probably HTML).
❌ 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 email data.


🙅 Remove emails (delete method)

The delete endpoint does not require anything in the body.

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

404 Not found - The requested email does not exist

✔️ On succes:

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


👀 Send verification emails(post method)

THIS ENDPOINT WILL BE AUTOMATICALLY CALLED WHEN A NEW USER IS CREATED, ONLY USE THIS IF YOU NEED TO RESEND THE EMAIL

The post endpoints require all body data as described.

  • /api/mails/verify returns the data added to the DB.
    • email (required, email, max:191) - The email of the recipient.
❌ 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": {
        "email": [
            "The email must be a valid email address."
        ]
    }
}
✔️ On succes:

201 Created - does not return a JSON object.

Clone this wiki locally