Skip to content

API to return metadata of reimbursements made by πŸ‡§πŸ‡· Chamber of Deputies

License

Notifications You must be signed in to change notification settings

sergiomario/jarbas

This branch is 780 commits behind okfn-brasil/jarbas:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nov 17, 2016
44ed975 Β· Nov 17, 2016
Nov 17, 2016
Nov 17, 2016
Sep 23, 2016
Nov 5, 2016
Oct 7, 2016
Oct 5, 2016
Nov 6, 2016
Nov 16, 2016
Sep 22, 2016
Nov 6, 2016
Oct 27, 2016
Sep 6, 2016
Oct 27, 2016
Nov 16, 2016
Sep 7, 2016

Repository files navigation

Jarbas β€” a tool for Serenata de Amor

Build Status Code Climate Coverage Status Updates

Jarbas is a tool for Serenata de Amor contributors.

JSON API endpoints

Documents

In Jarbas context a Document refers to a document (a reimbursement claim) from CEAP.

GET /api/document/

This endpoint lists Document objects and it accepts any field (and any combination among them) as a filter. For example:

GET /api/document/?year=2015&state=RS&congressperson_id=42

These are the fields that can be combined for filtering purposes:

  • applicant_id
  • cnpj_cpf
  • congressperson_id
  • document_id
  • document_type
  • month
  • party
  • reimbursement_number
  • state
  • subquota_group_id
  • subquota_number
  • term
  • year

GET /api/receipt/<Document.pk>

This endpoint gets the URL to the digitalized version of the receipt of a Document. It returns { url: null } if the digitalized version is not available. The endpoint expects a Document.pk (i.e. the primary key of the Document object).

Supplier

A supplier is a Brazilian company in which congressperson have made expenses and claimed for reimbursement.

GET /api/supplier/<Supplier.cnpj>

This endpoit gets the info we have for a specific supplier. The endpoint expects a Supplier.cnpj (i.e. the CNPJ of a Supplier object). It returns 404 if the supplier is not found.

Tapioca Jarbas

There is also a tapioca-wrapper for the API. The tapioca-jarbas can be installed with pip install tapioca-jarbas and can be used to access the API in any Python script.

Install

Requirements

The app is based in Python 3.5 and Node.js 6. Once you have pip and npm available, install the dependencies:

npm i
python -m pip install -r requirements-dev.txt

Minor details on requirements:

  • lzma: In some Linux distros lzma is not installed by default. You can check whether you have it or not with $ python -m lzma. In Debian based systems you can fix that with $ apt-get install liblzma-dev but you mihght have to re-compile your Python. Some macOS Users might have the same problem. To check if you have lzma you can use $ python -m lmza. To fix it you need to install lzma using $ brew install xz and after that you need to recompile Python, and an way to do it is through $ brew upgrade --cleanup python.

  • elm-make: If elm-make is not available in your path, or if the elm-make version differs from the one required by this project, set ELM_MAKE_BIN environment variable pointing to where the proper elm-make binary is (probably node_modules/.bin/elm-make)

  • psycopg2: The requirements.txt file is prepared to use PostgresSQL and psycopg2 might fail if you don't have Postgres installed locally.

Settings

Copy contrib/.env.sample as .env in the project's root folder and adjust your settings. These are the main environment settings:

Django settings

Database

Amazon S3 settings

  • AMAZON_S3_BUCKET (str) Name of the Amazon S3 bucket to look for datasets (e.g. serenata-de-amor-data)
  • AMAZON_S3_REGION (str) Region of the Amazon S3 (e.g. s3-sa-east-1)
  • AMAZON_S3_DATASET_DATE (str) Datasets file name prefix of CEAP datasets from Serenata de Amor (e.g. 2016-08-08 for 2016-08-08-current-year.xz)
  • AMAZON_S3_SUPPLIERS_DATE (str) Datasets file name prefix for suppliers dataset (e.g. 2016-08-08 for 2016-08-08-companies.xz)

Google settings

  • GOOGLE_ANALYTICS (str) Google Analytics tracking code (e.g. UA-123456-7)
  • GOOGLE_STREET_VIEW_API_KEY (str) Google Street View Image API key

Migrations

Once you're done with requirements, dependencies and settings, create the basic structure at the database (and if you wish, create a super-user for you, so you can use Django Admin later):

python manage.py migrate
python manage.py createsuperuser

Load data

Now you can load the data from our datasets:

python manage.py loaddatasets
python manage.py loadsuppliers
python manage.py ceapdatasets

Use python manage.py loaddatasets --help and ``python manage.py loadsuppliers --help` to check options on limiting the number of documents to be loaded from the datasets.

Generate static files

We generate assets through webassets thus you might have to run:

python manage.py assets build
python manage.py collectstatic

Ready?

Not sure? Run python manage.py check and python manage.py test just in case.

Ready!

Run the server with python manage.py runserver and load localhost:8000 in your favorite browser.

If you created a super-user account, you can also use Django Admin at /admin/.

License

Licensed under the MIT License.

About

API to return metadata of reimbursements made by πŸ‡§πŸ‡· Chamber of Deputies

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 50.6%
  • Elm 48.0%
  • Other 1.4%