Git Product home page Git Product logo

bucketlist_andela's Introduction

BUCKETLIST

Codeship Status for SProjects/bucketlist_andela Code Climate Test Coverage

Introduction

Bucketlist is an API powered application that helps its users to create bucketlists and add todo items to them.

Technology Stack

Backend

  • Python 2.7
  • Postgres 9.4
  • Flask 0.12.2
  • Flash Restful 0.3.5

Frontend

  • Angular 2

Pre-requisites

Setup

Automated

  1. Create a virtual environment and activate it.
  2. Clone the project from https://github.com/SProjects/bucketlist_andela.git
  3. cd into the project root
  4. Create database. Run createdb bucketlist_dev in the terminal
  5. Migrate the database using python manage.py db upgrade
  6. Run source go.sh
  7. Run init
  8. After a successful build, run serve

Manual

  1. Create a virtual environment and activate it.
  2. Clone the project from https://github.com/SProjects/bucketlist_andela.git
  3. cd into the project root
  4. Run pip install requirements.txt to install all project dependencies to the virtual environment.
  5. Create database. Run createdb bucketlist_dev in the terminal
  6. Migrate the database using python manage.py db upgrade
  7. cd into the client directory cd bucketlist/client/
  8. Install bower components bower install
  9. Install npm requirements npm install
  10. Build the project ng build
  11. cd back to the root directory
  12. Start the application with; python manage.py runserver

Usage

Tools to call the API

  1. Postman
  2. curl

Authorization

  • Using the authentication endpoint get a token which you send in place of the username in the basic authentication parameters.
  • OR Use the username(email of user) and password as parameters for basic authentication

Registration Endpoint

Url: http://<base_url>/api/v1/auth/register
Action: POST
Post data:

    {
        'first_name': 'FirstName', 
        'last_name': 'LastName', 
        'email': '[email protected]', 
        'password': 'good_password', 
        'password_confirm': 'good_password'
    }

Response:

    {'message': 'You registered successfully.'}

Authorization: False

Authentication Endpoint

Url: http://<base_url>/api/v1/auth/login
Action: POST
Post data:

    {
        'email': '[email protected]', 
        'password': 'good_password'
    }

Response:

    {'token': 'alphanumeric_string'}

Authorization: False

User Endpoints

Get all user

Url: http://<base_url>/api/v1/users
Action: GET
Response:

    {
        'results': [
            {
                'first_name': 'FirstName', 
                'last_name': 'LastName', 
                'email': '[email protected]', 
                'password': 'good_password', 
                'password_confirm': 'good_password'
            }
        ]
    }

Authorization: True

Get a user

Url: http://<base_url>/api/v1/users/<user_id>
Action: GET
Response:

    {
        'first_name': 'FirstName', 
        'last_name': 'LastName', 
        'email': '[email protected]', 
        'password': 'good_password', 
        'password_confirm': 'good_password'
    }

Authorization: True

Edit a user

Url: http://<base_url>/api/v1/users/<user_id>
Action: PUT
Put data:

    {
        'first_name': 'updated_first_name',
        'last_name': 'updated_last_name',
        'email': 'updated_email'
        'old_password': 'current_password',
        'new_password': 'new_password',
        'new_password_confirm': 'new_password'
    }

Response:
Updated user object
Authorization: True

Delete a user

Url: http://<base_url>/api/v1/users/<user_id>
Action: DELETE
Response: {'message': 'User with id#<user_id> successfully deleted.'}
Authorization: True

Bucketlist Endpoints

Add new bucketlist

Url: http://<base_url>/api/v1/bucketlists
Action: POST
Post data:

    {'name': 'Bucketlist Name'}

Response

    {'message': 'Bucketlist created successfully.'}

Authorization: True

Get all bucketlists

Url: http://<base_url>/api/v1/bucketlists
Action: GET

    {
      'results': [
        {
          'created_by': 1,
          'date_created': 'Tue, 23 May 2017 10:59:06 -0000',
          'date_modified': 'Tue, 23 May 2017 12:26:50 -0000',
          'id': 1,
          'items': [
            {
              'date_created': 'Tue, 23 May 2017 14:25:13 -0000',
              'date_modified': 'Tue, 23 May 2017 14:25:13 -0000',
              'done': false,
              'id': 1,
              'name': 'To do item'
            }
          ],
          'name': 'Bucketlist name'
        }
      ]
    }

Authorization: True

Get a bucketlist

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>
Action: GET
Response:

    {
      'created_by': 1,
      'date_created': 'Tue, 23 May 2017 10:59:06 -0000',
      'date_modified': 'Tue, 23 May 2017 12:26:50 -0000',
      'id': 1,
      'items': [
        {
          'date_created': 'Tue, 23 May 2017 14:25:13 -0000',
          'date_modified': 'Tue, 23 May 2017 14:25:13 -0000',
          'done': false,
          'id': 1,
          'name': 'To do item'
        }
      ],
      'name': 'Bucketlist name'
    }

Authorization: True

Edit a bucketlist

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>
Action: PUT
Post data:

    {'name': 'Bucketlist Name'}

Response:
Updated bucketlist object
Authorization: True

Delete a bucketlist

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>
Action: DELETE
Response: {'message': 'Bucketlist with ID#<bucketlist_id> successfully deleted.'
Authorization: True

Search bucketlists by name

Url: http://<base_url>/api/v1/bucketlists?q=<search_term>
Action: GET
Response:

    {
      'results': [
        {
          'created_by': 1,
          'date_created': 'Tue, 23 May 2017 10:59:06 -0000',
          'date_modified': 'Tue, 23 May 2017 12:26:50 -0000',
          'id': 1,
          'items': [
            {
              'date_created': 'Tue, 23 May 2017 14:25:13 -0000',
              'date_modified': 'Tue, 23 May 2017 14:25:13 -0000',
              'done': false,
              'id': 1,
              'name': 'To do item'
            }
          ],
          'name': 'Bucketlist name'
        }
      ]
    }

Authorization: True

Paginate bucketlist

Url: http://<base_url>/api/v1/bucketlists?limit=<page_size>
Action: GET
Response:

    {
      'results': [
        {
          'created_by': 1,
          'date_created': 'Tue, 23 May 2017 10:59:06 -0000',
          'date_modified': 'Tue, 23 May 2017 12:26:50 -0000',
          'id': 1,
          'items': [
            {
              'date_created': 'Tue, 23 May 2017 14:25:13 -0000',
              'date_modified': 'Tue, 23 May 2017 14:25:13 -0000',
              'done': false,
              'id': 1,
              'name': 'To do item'
            }
          ],
          'name': 'Bucketlist name'
        }
      ],
      'next': '/api/v1/bucketlists?limit=1&page=1',
      'num_results': 2,
      'page': 1,
      'total_pages': 2
    }

Authorization: True

Bucketlist Item Endpoints

Add new bucketlist item

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>/items
Action: POST
Post data:

{'name': 'Item Name'}

Response:

{'message': 'Item successfully added to Bucketlist ID#<bucketlist_id>'}

Authorization: True

Get all bucketlist items

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>/items
Action: GET
Response:

    {
      'results': [
        {
          'date_created': 'Tue, 23 May 2017 14:25:13 -0000',
          'date_modified': 'Tue, 23 May 2017 14:25:13 -0000',
          'done': false,
          'id': 1,
          'name': 'To do item'
        }
      ]
    }

Authorization: True

Get a bucketlist item

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>/items/<item_id>
Action: GET
Response:

    {
      'date_created': 'Tue, 23 May 2017 14:25:13 -0000',
      'date_modified': 'Tue, 23 May 2017 14:25:13 -0000',
      'done': false,
      'id': 1,
      'name': 'To do item'
    }

Authorization: True

Edit a bucketlist item

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>/items/<item_id>
Action: PUT
Data (done can be True for completed or False for incomplete)

    {'name': 'Bucketlist Name', 'done': True}

Response:
Updated item object
Authorization: True

Delete a bucketlist item

Url: http://<base_url>/api/v1/bucketlists/<bucketlist_id>/items/<item_id>
Action: DELETE
Response: {'message': 'Item with ID#<item_id> deleted successfully.'}
Authorization: True

Automated Tests

Run tests

nosetests --rednose

Run tests with coverage

nosetests --rednose --with-coverage --cover-inclusive --cover-package=bucketlist --cover-erase --cover-html

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.