Coder Social home page Coder Social logo

api-feiras-livres's Introduction

API Feiras Livres

This API creates, reads, updates and deletes Feiras Livres - a list of Brazilian Street Markets. A .csv from São Paulo Secretaria is imported into the system and used as datasource to populate our database.

Building and using the application

Run the following commands inside the root directory of the project:

mvn clean install package

docker build -t app-0.1.jar .

docker-compose up -d

After those commands, you should have the application up and running at http://localhost:8080/feira-livre.

In order to import the .csv data, execute the following command at the project root directory. This step should be executed after the commands above in order to allow the project to automatically create the database schema.

docker cp src/main/resources/data/DEINFO_AB_FEIRASLIVRES_2014.csv mysql:/var/lib

docker exec -i mysql mysql -u root -proot < import-data.sql

Done! Your database should be populated by now.

Requests and responses

A request file containing all endpoints to be used with your tool of choice (Postman, Insomnia, CURL) is available here.

Basically, the application has four main endpoints:

  1. Create a Feira Livre

    To create a new Feira Livre, access the following endpoint:

    POST http://localhost:8080/feira-livre

    ... and provide something along the lines of the following application/json body:

    {
       "longitude": "-46444519",
       "latitude": "-23519118",
       "setor_censitario": "355030837000160",
       "area_ponderacao": "3550308005200",
       "codigo_distrito": "36",
       "distrito": "JAGUARE",
       "codigo_subprefeitura": "27",
       "subprefeitura": "JAGUARE",
       "regiao5": "Oeste",
       "regiao8": "Oeste 2",
       "nome_feira": "SUPER FEIRA",
       "registro": "7217-6",
       "logradouro": "RUA CENTRAL DO JAGUARE",
       "numero": "S/N",
       "bairro": "VL VERDE",
       "referencia": "PRACA DA TORRE"
    }
  2. Find Feiras Livres

    To find Feiras Livres by using search filters, access the following endpoint:

    GET http://localhost:8080/feira-livre

    ... and add your search filters as request params variables. There's four filters to choose from: distrito, regiao5, nomeFeira, bairro and you can mix and match those params.

    When added the parameters, your requisition should look something like this:

    GET http://localhost:8080/feira-livre?regiao5=Oeste&distrito=JAGUARE

    If no filter is provided, all Feiras Livres are returned.

  3. Update a existing Feira Livre

    To update a Feira Livre, access the following endpoint with the desired Feira Livre ID as a Path Param:

    PUT http://localhost:8080/feira-livre/1

    ... and provide the following application/json body:

     {
         "longitude": "-46444519",
         "latitude": "-23519118",
         "setor_censitario": "355030837000160",
         "area_ponderacao": "3550308005200",
         "codigo_distrito": "36",
         "distrito": "JAGUARE",
         "codigo_subprefeitura": "27",
         "subprefeitura": "JAGUARE",
         "regiao5": "Oeste",
         "regiao8": "Oeste 2",
         "nome_feira": "SUPER FEIRA",
         "registro": "7217-6",
         "logradouro": "RUA CENTRAL DO JAGUARE",
         "numero": "S/N",
         "bairro": "VL VERDE",
         "referencia": "PRACA DA TORRE"
     }
  4. Delete a Feira Livre

    To delete a Feira Livre, access the following endpoint with the desired Feira Livre ID as a Path Param:

    DELETE http://localhost:8080/feira-livre/1

Log files and Code coverage

  1. Code Coverage: to access the report of code coverage generated by JaCoCo, use the following link after running the following Maven lifecycle:

    mvn clean test

  2. Log Files: After running the application, the log files can be found in the application.log file, located in root directory of the project.

api-feiras-livres's People

Contributors

gracieledamasceno avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.