Coder Social home page Coder Social logo

work-at-olist's Introduction

Description

Proposed solution to the Olist challenge. The service is published on Heroku: https://billcalls.herokuapp.com Documentation

Instalation

git clone https://github.com/rodriguesraphael/work-at-olist
cd work-at-olist/
virtualenv env -p python3
source env/bin/activate

Environment Variables

Dynaconf was used to manage Django's environment variables and settings. Before starting the application create a .env file with the variables needed to start Django, you can copy the example contained in the repository, see the example below.

cp .env.example .env

Or you can export the variables in the environment.

export BILLCALLS_ENV=development
export BILLCALLS_SECRET_KEY="CHANGE_ME!!!! (P.S. the SECRET_KEY environment variable will be used, if set, instead)."
export BILLCALLS_DEBUG=true
export BILLCALLS_ALLOWED_HOSTS=*

Deploy in Develop Environment

pip install -r requirements-dev.txt
./manage.py migrate

Load Sample Data

./manage.py loaddata calls/fixtures/fixture-calls.json

Run Tests

./manage.py test

Deploy in Docker

docker-compose up

To execute commands in the application do as in the example below

docker-compose run web ./manage.py test
docker-compose run web ./manage.py loaddata calls/fixtures/fixture-calls.json

Usage Examples

POST START CALL

curl -i -X POST https://billcalls.herokuapp.com/call-log/ \
        -H 'Content-Type: application/json' \
        -d '{
            "call_id": 100,
            "source": "41888889999",
            "destination": "41999998888",
            "timestamp": "2018-11-20T15:20:12Z",
            "type": "start"
        }'

POST END CALL

curl -i -X POST https://billcalls.herokuapp.com/call-log \
        -H 'Content-Type: application/json' \
        -d '{
            "call_id": 100,
            "timestamp": "2018-11-20T15:25:42Z",
            "type": "end"
        }'

GET TELEPHONE BILL

Use query argument 'date=mmYYYY' to search by date e.g.

curl -i -X GET https://billcalls.herokuapp.com/call-invoice/41888889999?date=112018

[{"call_id":100,"price":"R$ 0.81","duration":"0h5m30s","call_start_date":"2018-11-20","call_start_time":"15:20:12","destination":"41999998888"}]

If the reference date is not entered, the previous month will be consulted.

curl -i -X GET https://billcalls.herokuapp.com/call-invoice/41888889999

Working Enviroment Used

OS System Debian
Description Debian GNU/Linux 9.11 (stretch)
Release 9.11
Codename stretch

Text Editor/IDE

PyCharm 2018.3.2 (Community Edition)
Build #PC-183.4886.43, built on December 18, 2018
JRE: 1.8.0_152-release-1343-b26 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.9.0-11-amd64

Libraries

Python 3.7
Django 2.2.5
djangorestframework 3.10.3
coreapi 2.3.3
dynaconf

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.