messages: refactoring and REST API 

Refactoring of the messages module. An api.py file has been created in order to interact with the database. Also a restful.py file has been created so that messages can have a REST API.
1: D290 White spaces around docstring should be trimmed.
62: D290 White spaces around docstring should be trimmed.
144: D290 White spaces around docstring should be trimmed.
158: D290 White spaces around docstring should be trimmed.
448: D290 White spaces around docstring should be trimmed.