jessicapaz / work-at-olist

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call Records API

Description

A REST API that receives call records and calculates monthly bills for a given telephone number.

Installation

$ git clone https://github.com/jessicapaz/work-at-olist.git

$ cd olist-test

$ pipenv install

$ pipenv shell

$ python manage.py migrate

Run tests

$ python manage.py test

Work environment

  • Computer: Notebook Asus Core i3-4005U 4GB 1TB

  • Operating System: Ubuntu 16.04

  • Code Editor: Visual Studio Code

API Documentation

Authentication

Receives a POST with a user's email and password and returns a JSON Web Token that can be used for authenticated requests.

Base URL:

https://callrecords.herokuapp.com/v1/auth/
  • POST (Create)

    • Exemple:
    $ curl -X POST -d "email=test&password=test" https://callrecords.herokuapp.com/v1/auth/

Subscriber

Receives a subscriber and return a subscriber list.

Base URL:

https://callrecords.herokuapp.com/v1/subscriber/
  • POST (Create)

    • URL
    https://callrecords.herokuapp.com/v1/subscriber/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X POST -d "first_name=Test&last_name=Test&phone_number=99985257541" https://callrecords.herokuapp.com/v1/subscriber/
  • GET (List)

    • URL
    https://callrecords.herokuapp.com/v1/subscriber/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X GET https://callrecords.herokuapp.com/v1/subscriber/
  • GET (Retrieve)

    • URL
    https://callrecords.herokuapp.com/v1/subscriber/{phone_number}/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X GET https://callrecords.herokuapp.com/v1/subscriber/99988526423/
  • DELETE

    • URL
    https://callrecords.herokuapp.com/v1/subscriber/{phone_number}/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X DELETE https://callrecords.herokuapp.com/v1/subscriber/99988526423/

Price

Receives a Price (standard or reduced) and return a price list.

Base URL:

https://callrecords.herokuapp.com/v1/price/
  • POST (Create)

    • URL
    https://callrecords.herokuapp.com/v1/price/
    
    • Exemple: (Standard)
    $ curl -H "Authorization: JWT <your_token>" -X POST -d "tarrif_type=standard&standing_charge=0.38&call_charge=0.08" https://callrecords.herokuapp.com/v1/price/
    • Exemple: (Reduced)
    $ curl -H "Authorization: JWT <your_token>" -X POST -d "tarrif_type=reduced&standing_charge=0.38&call_charge=0.02" https://callrecords.herokuapp.com/v1/price/
  • GET (List)

    • URL
    https://callrecords.herokuapp.com/v1/price/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X GET https://callrecords.herokuapp.com/v1/price/
  • GET (Retrieve)

    • URL
    https://callrecords.herokuapp.com/v1/price/{id}/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X GET https://callrecords.herokuapp.com/v1/price/1/
  • DELETE

    • URL
    https://callrecords.herokuapp.com/v1/price/{id}/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X DELETE https://callrecords.herokuapp.com/v1/price/1/

Call Record

Receives a call record pair (start and end) and return a call records list.

Base URL:

https://callrecords.herokuapp.com/v1/call-record/
  • POST (Create)

    • URL
    https://callrecords.herokuapp.com/v1/call-record/
    
    • Exemple (Call Start Record):
    $ curl -H "Authorization: JWT <your_token>" -X POST -d "id=1&type=start&timestamp=2016-02-29T12:00:00Z&call_id=1&source=99981848345&destination=9993468277" https://callrecords.herokuapp.com/v1/call-record/
    • Exemple (Call End Record):
    $ curl -H "Authorization: JWT <your_token>" -X POST -d "id=1&type=end&timestamp=2016-02-29T13:00:00Z&call_id=1" https://callrecords.herokuapp.com/v1/call-record/
  • GET (List)

    • URL
    https://callrecords.herokuapp.com/v1/call-record/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X GET https://callrecords.herokuapp.com/v1/call-record/

Bill Record

Return a bill records list of one subscriber.

Base URL:

https://callrecords.herokuapp.com/v1/bill-record/{phone_number}/
  • GET (Considering the previous month)
    • URL
    https://callrecords.herokuapp.com/v1/bill-record/{phone_number}/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X GET https://callrecords.herokuapp.com/v1/bill-record/99988526423/
    
  • GET (Considering the given period)
    • URL
    https://callrecords.herokuapp.com/v1/bill-record/{phone_number}/?month={month}&year={year}/
    
    • Exemple:
    $ curl -H "Authorization: JWT <your_token>" -X GET https://callrecords.herokuapp.com/v1/bill-record/99988526423/?month=12&year=2017/

About


Languages

Language:JavaScript 45.1%Language:CSS 44.3%Language:Python 10.6%