Skip to content

About

A simple prototype for a basic mailbox API

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Backend Task - Mailbox API

Introduction

A local firm is building a small E-mail client to manage their internal messaging. You have been asked to provide a simple prototype for a basic mailbox API in which the provided messages are listed. Each message can be marked as read and you can archive single messages.

Authorization

HTTP basic authorization was used.

Demonstration user: admin:test

Database

Before using you need to prepare the database.

  • Create tables via symfony console command php bin/console doctrine:schema:update.
  • Seed tables. doctrine-fixtures-bundle was used for seeding. Use symfony console command php bin/console doctrine:fixtures:load. The command will use special class akerbel\MailBoxBundle\DataFixtures\ORM\loadData that will put json data from akerbel\MailBoxBundle\DataFixtures\Seed\messages_sample.json to the database.
    • messages_sample.json file from the task was changed. Now it also contains users. Also messages were attached to owners via usernames instead IDs because user`s IDs can be different.

API

  • /mailbox/list - list all users messages.
    • Supported methods: GET
    • Parameters:
      • offset - integer, the sequence will start at that offset in the array. Defaut = null.
      • length - integer, the sequence will have up to that many elements in it. Default = null.
  • /mailbox/list/archived - list archived users messages.
    • Supported methods: GET
    • Parameters:
      • offset - integer, the sequence will start at that offset in the array. Defaut = null.
      • length - integer, the sequence will have up to that many elements in it. Default = null.
  • /mailbox/show/{id} - show a message with ID = {id}.
    • Supported methods: GET
  • /mailbox/read/{id} - mark a message with ID = {id} as read.
    • Supported methods: PATCH
  • /mailbox/unread/{id} - mark a message with ID = {id} as unread.
    • Supported methods: PATCH
  • /mailbox/archive/{id} - mark a message with ID = {id} as archived.
    • Supported methods: PATCH
  • /mailbox/unarchive/{id} - mark a message with ID = {id} as unarchived.
    • Supported methods: PATCH
  • /mailbox/add - add a message to the database. Authorization is not needed.
    • Supported methods: PUT, POST
    • Parameters:
      • addressee - string, addressee`s username. Required.
      • sender - string, sender`s name. Required.
      • subject - string, a subject of a message. Required.
      • message - string, a text of a message. Required.
  • /mailboc/delete/{id} - delete a message with ID = {id}.
    • Supported methods: DELETE

Tests

All tests are in tests/akerbelMailBoxBundle/Controller . PHPunit was used. Use phpunit tests/akerbelMailBoxBundle/Controller/ for runing tests.

About

A simple prototype for a basic mailbox API

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages