Made by Nazareno Lorenzo for Bunq.com code test.
Made using Laravel 4 latest stable release: Laravel
Includes both a RESTful JSON API that handles all the required transactions and business model, and an almost independent web UI, implementing all the available methods in the API.
According to the requirements, user registration/authentication wasn't implemented.
As by default it uses SQLite, and a sample db is provided, there shouldn't be required any extra step. Extracting the package inside of the server root should be enough. All the required packages are included, although they can be updated using composer.
It's also possible to run the application using MySQL, Postgres or SQLServer following the next steps:
- In
app/config/database.php
, configure the database access and set it as the default. - From a terminal/shell, browse to the application root and run the following commands, which would create the database structure and insert some sample data.
$ php artisan migrate
$ php artisan db:seed
All endpoints receive a GET/POST parameter called user_id
. From the sample app/db, there are 4 valid ids (1,2,3,4). All endpoints are being used in the UI developed and can be tested through it.
GET /conversation/{contact_id}
Returns an entire conversation in JSON format
GET /conversation/{contact_id}/{last_message_time}
Returns all the messages for a conversation, that where sent after last_message_time
. This parameter should be in the format: YYYY-MM-DD HH:MM:SS.
Useful for retrieving updates on an already retrieved conversation.
POST /message/{contact_id}
Saves a new message, after validating the data sent. Receives an additional post parameter, called message
with a (MAX 1000 characters) string.
GET /unseen
Gets a list of all the contacts which have any message unread by the current user and the count of unseen messages.
In order to use the Web UI, you should visit the following url (with the base path depending on your server setup):
{base_path}/public/chat/{user_id}
For example, a valid url may be:
http://localhost/bunq_test/public/chat/1/