This app is a test for selection process at Luiza Labs.
The purpose was to create a API with default RESTful coming some datas of Facebook from a FACEBOOK ID. With FACEBOOK ID it's possible get some datas as follows:
{
"id": "1",
"first_name": "test",
"gender": "male",
"last_name": "test",
"locale": "pt_BR",
"name": "test",
"username": "test"
}The API get a FACEBOOK ID and from her, we save all elements above and provides:
{
"username": "test",
"name": "test",
"facebook_id": "123",
"gender": "male",
}First, to continue this installation tutorial you need install some dependencies. If you have all installed, ignore it.
In your shell, run:
~$ sudo apt-get install python-setuptools python-dev build-essential
~$ sudo easy_install pip
~$ sudo pip install virtualenvAll right, we are ready! 😏
Make the download of luizalabs-alexsander.tar.gz tarball file.
To run, extract all files of tarball file with:
~$ tar -xzf luizalabs-alexsander.tar.gzOr, right click on the luizalabs-test.tar.gz file and select the extract here option from the drop-down menu, and it will be extracted on the same folder as the compressed file.
Create a new folder to create a virtual machine.
~$ mkdir luizalabs-alexsander && cd luizalabs-alexsander && virtualenv vm && cd vmCopy and paste the project to current folder /vm/:
~/luizalabs/vm$ cp -a ~/alexsander/. ~/luizalabs-alexsander/vm/Activate the virtual machine:
~/luizalabs/vm$ source bin/activateInstall all requirements:
~/luizalabs/vm$ pip install -r requirements.txtSynchronize your database:
~/luizalabs/vm$ python manage.py syncdbAnd run it!
~/luizalabs/vm$ python manage.py runserverYou can see this examples for get the respective responses.
Insert data:
$ curl -X POST -F facebook_id=[Facebook ID] http://localhost:8000/api/person/
/* Status code response: 201 */List data(s):
$ curl http://localhost:8000/api/person/
/* Status code response: 200 */Response data:
{
"count": 16,
"next": "http://localhost:8000/api/person/&page=2",
"previous": null,
"results": [
{
"id": 1,
"username": "username",
"name": "name",
"facebook_id": "number",
"gender": "male"
}
]
}List with limit data:
$ curl http://localhost:8000/api/person/?limit=1
/* Status code response: 200 */Or list for page, so on:
$ curl http://localhost:8000/api/person/?page=1
/* Status code response: 200 */Delete data:
$ curl -X DELETE http://localhost:8000/api/person/[Facebook ID]/
/* Status code response: 204 */See You!
Copyright (C) 2015 Alexsander Falcucci
MIT.