Skip to content

Instantly share code, notes, and snippets.

@NazarenoL
Last active April 30, 2018 14:18
Show Gist options
  • Save NazarenoL/e7a2a0b0fe86695d0103 to your computer and use it in GitHub Desktop.
Save NazarenoL/e7a2a0b0fe86695d0103 to your computer and use it in GitHub Desktop.

Bunq Test Chat

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.

Getting Started

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:

  1. In app/config/database.php, configure the database access and set it as the default.
  2. 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

Chat API endpoints

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.

The Chat API provides four endpoints:


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.


Using the WEB UI

Web UI Screenshot 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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment