Skip to content

AhmedElsayed101/Casting-agency-API-Udacity-FSWD-Capstone-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Casting agency of Udacity

This project is my last project of full stack web development nano-degree, it was epic as I tried to finish this nano degree in less than 20 days although the estimated time for it is 4 months, it's a demo for a casting agency where you can find actors and movies and directors.

All backend code follows PEP8 style guidelines.


Getting Started

Project hierarchy

Pre-requisites and Local Development

Developers using this project should already have Python3, pip and postgresql installed on their local machines.

From the base directory run

pip install requirements.txt

. All required packages are included in the requirements file.

You have to create a new postgresql database using

createdb capstone

You have to check for the setup.sh file to make sure that DATABASE_URL matches with your system

To run the application run the following commands:

python manage.py db migrate
python manage.py db upgrade

python manage.py runserver

congratulations, server is running on (http://127.0.0.1:5000/)


Tests

In order to run tests navigate to the base dicrectory and run the following commands:

dropdb capstone_test
createdb capstone_test

python test_api.py

API Reference

Getting Started


Error Handling

Errors are returned as JSON objects in the following format:

{
    "success": False, 
    "error": 400,
    "message": "bad request"
}

The API will return three error types when requests fail:

  • 400: Bad Request
  • 404: Resource Not Found
  • 422: Not Processable

Endpoints

GET '/api/actors'

- Retreive all actors

Payload
None
Headers
{
    "Authorization":"Bearer <assistant token at least>"
}
Success Response
{
    "actors": [
        {
            "age": 30,
            "gender": "male",
            "id": 1,
            "name": "mohamed"
        },
        {
            "age": 20,
            "gender": "female",
            "id": 2,
            "name": "noha"
        },
        {
            "age": 11,
            "gender": "male",
            "id": 3,
            "name": "mohamed"
        },
        {
            "age": 6,
            "gender": "male",
            "id": 4,
            "name": "ahmed"
        }
    ],
    "actors_number": 4,
    "success": true
}

POST '/api/actors'

- Create a new actor

Payload
{
	"name": "name example",
	"age" : 30,
    "gender": "male"
}
Headers
{
    "Authorization":"Bearer <director token at least>"
}
Success Response
{
    "created": 5,
    "success": true
}

GET '/api/actors/int:5'

- Retreive an actor

Payload
None
Headers
{
    "Authorization":"Bearer <assistant token at least>"
}
Success Response
{
    "actor": {
        "age": 123132,
        "gender": ";skdafk;sdf",
        "id": 5,
        "name": "mohamed"
    },
    "success": true
}

DELETE '/api/actors/int:5'

- Delete an actor

Payload
None
Headers
{
    "Authorization":"Bearer <director token at least>"
}
Success Response
{
    "deleted": 5,
    "success": true
}

PATCH '/api/actors/int:2'

- Edit an actor

Payload
{
	"name": "name example",
	"age" : 30,
    "gender": "male"
}
Headers
{
    "Authorization":"Bearer <assistant token at least>"
}
Success Response
{
    "success": true,
    "updated": 2
}

GET '/api/movies'

- Retreive all movies

Payload
None
Headers
{
    "Authorization":"Bearer <assistant token at least>"
}
Success Response
{
    "movies": [
        {
            "id": 1,
            "start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
            "title": "new moSFASFDvie"
        },
        {
            "id": 2,
            "start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
            "title": "new moSFASFDvie"
        },
        {
            "id": 3,
            "start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
            "title": "new moSFASFDvie"
        },
        {
            "id": 4,
            "start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
            "title": "new moSFASFDvie"
        }
    ],
    "movies_number": 4,
    "success": true
}

POST '/api/movies'

- Create a new movie

Payload
{
	"title": "new movie",
	"start_time": "2015-11-1"
}
Headers
{
    "Authorization":"Bearer <producer token at least>"
}
Success Response
{
    "created": 10,
    "success": true
}

GET '/api/movies/int:5'

- Retreive a movie

Payload
None
Headers
{
    "Authorization":"Bearer <assistant token at least>"
}
Success Response
{
    "movie": {
        "id": 5,
        "start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
        "title": "new moSFASFDvie"
    },
    "success": true
}

DELETE '/api/actors/int:5'

- Delete an actor

Payload
None
Headers
{
    "Authorization":"Bearer <producer token at least>"
}
Success Response
{
    "deleted": 5,
    "success": true
}

PATCH '/api/movies'

- Edit a movie

Payload
{
	"title": "new movie",
	"start_time": "2015-11-1"
}
Headers
{
    "Authorization":"Bearer <director token at least>"
}
Success Response
{
    "success": true,
    "updated": 6
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published