Skip to content

enochblake/Mazingira_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mazingira Backend

STARTING MAZINGIRA

  • Clone the repository
  • Change the directory cd Mazingira_backend and run the following commands
  1. pipenv install && pipenv shell
  2. cd server
  3. export DATABASE_URI=postgresql://mazingira_user:ETf9S7HRc1cYbgOUSZGHfdNAEnGHAo3L@dpg-cp45l90cmk4c73eema9g-a.frankfurt-postgres.render.com/mazingira_db^C
  4. python app.py

ENDPOINTS

POST /register

Creates a new donor and logs them in.

Request

POST /register

JSON format

{
    "first_name":"Enoch",
    "last_name": "Kibet",
    "email": "[email protected]",
    "password": "enoch"
}

POST /register

Creates a new organization and logs them in.

Request

POST /org/register

JSON format

{
    "name":"Mazingira's Organization",
    "email": "[email protected]",
    "password": "organization"
}

POST /login

Authenticates & Authorizes a donor/admin.

Request

POST /login

JSON format

{
    "email":"[email protected]",
    "password":"enoch"
}

POST /org/login

Authenticates & Authorizes an oorganization.

Request

POST /org/login

JSON format

{
    "email":"[email protected]",
    "password":"organization"
}

GET /checksession

Checks for the current session

Request

GET /checksession

response

{
    "message": "Log In To Access Resource or Contact Mazingira"
}

or

{
    "email": "[email protected]",
    "first_name": "Enoch",
    "id": 125,
    "last_name": "Kibet",
    "role": "donor"
}

ADMIN ENDPOINTS

GET /admin

Returns a list of all the approved and unapproved organizations

Request

GET /admin

Response

[
    {
        "approval_status": true,
        "description": null,
        "email": "[email protected]",
        "id": 23,
        "image_url": null,
        "name": "Howell, White and Murphy"
    },
    {
        "approval_status": false,
        "description": null,
        "email": "[email protected]",
        "id": 31,
        "image_url": null,
        "name": "Martin-Day"
    },
    {
        "approval_status": true,
        "description": null,
        "email": "[email protected]",
        "id": 32,
        "image_url": null,
        "name": "White, Wilson and Roberts"
    },
    {
        "approval_status": true,
        "description": null,
        "email": "[email protected]",
        "id": 33,
        "image_url": null,
        "name": "Just An Organization"
    },
    {
        "approval_status": false,
        "description": null,
        "email": "[email protected]",
        "id": 34,
        "image_url": null,
        "name": "Mazingira's Organization"
    }
]

GET /admin/23

Returns one organization whether approved or unapproved

Request

GET /admin/23

Response

{
    "approval_status": true,
    "description": null,
    "email": "[email protected]",
    "id": 23,
    "image_url": null,
    "name": "Howell, White and Murphy"
}

PATCH /admin/23

Approves or rejects an organization application

Request

PATCH /admin/23

Request format

{
    "approval_status": true
}

Response

{
    "message": "Organization Updated Successfully",
    "organization": {
        "id": 23,
        "name": "Howell, White and Murphy",
        "email": "[email protected]",
        "image_url": null,
        "approval_status": true,
        "description": null
    }
}

DELETE /admin/23

Deletes one organization whether approved or unapproved

Request

DELETE /admin/23

Response

{
    "message": "Organization deleted successfully"
}

Or

{
    "message": "Organization not found"
}

GET /admin/notification

Returns a list of notifications when a new organization sign up

Request

GET /admin/notification

Response

[
        {
            "id": 1,
            "message": "New organization "Org1" has signed up and is pending approval.",
            "date_created": "currebt time",
            "is_read": false,
        }
    ]

DONOR ENDPOINTS

GET /donor/organization

Returns a list of all the approved organizations

Request

GET /donor/organization

response

[
    {
        "approval_status": true,
        "description": null,
        "email": "[email protected]",
        "id": 23,
        "image_url": null,
        "name": "Howell, White and Murphy"
    }
]

GET /donor/organization/1

Returns one approved organizations

Request

GET /donor/organization/1

response

{
    "approval_status": true,
    "description": null,
    "email": "[email protected]",
    "id": 23,
    "image_url": null,
    "name": "Howell, White and Murphy"
}

POST /donate

Creates a donation for an organization

Request

POST /donate

Request format

{
    "amount": 400,
    "anonymous": true,
    "organization_id": 23
}

Response

{
    "amount": 400.0,
    "anonymous": true,
    "donor_id": 125,
    "id": 55,
    "organization_id": 23
}

GET /donor/stories

Returns stories about beneficiaries of your donations

Request

GET /donor/stories

response

{
    "message": "No Stories Found. Make A Donation First"
}

or

[
    {
      "content": "Street hair first significant skin play go. Tell stand light general treat walk I try. Population it eye necessary establish star. Professional child young certain move. Ball shake choice address another thing figure pull. Growth arm manager.",
      "created_at": "Sat, 11 May 2024 11:04:37 GMT",
      "id": 1,
      "image_url": "https://pbs.twimg.com/media/FpmD9sMXEAA4Mb7.jpg",
      "organization_id": 10,
      "title": "Kristine Peters"
    },
    {
      "content": "Not low agent guess toward control tell. Time include use price kid guy. Feeling instead free indicate recently player bit.",
      "created_at": "Sat, 11 May 2024 11:04:37 GMT",
      "id": 3,
      "image_url": "https://pbs.twimg.com/media/FpmD9sMXEAA4Mb7.jpg",
      "organization_id": 10,
      "title": "Austin Moore"
    }
]

ORGANIZATION ENDPOINTS

GET /organization

Returns the details of the organization and approval status

Request

GET /organization

Response

{
    "application_reviewed_on": null,
    "approval_status": false,
    "description": null,
    "email": "[email protected]",
    "id": 34,
    "image_url": null,
    "name": "Mazingira's Organization",
    "registered_on": "Tue, 14 May 2024 16:42:01 GMT"
}

GET /organization/donations

Returns donations made to an organization

Request

GET /organization/donations

Response

[
    {
      "amount": 400.0,
      "anonymous_status": true,
      "donated_on": "Sat, 11 May 2024 11:51:45 GMT",
      "id": 57,
      "organization_id": 9
    },
    {
      "amount": 400.0,
      "anonymous_status": true,
      "donated_on": "Sat, 11 May 2024 11:51:50 GMT",
      "id": 58,
      "organization_id": 10
    },
    {
      "amount": 400.0,
      "anonymous_status": true,
      "donated_on": "Sat, 11 May 2024 11:51:53 GMT",
      "id": 59,
      "organization_id": 11
    }
]

Or

    {
        "message": "No Donations Found"
    }

PATCH /org/edit

An organization can edit their details

Request

PATCH /org/edit

Request format

{
    "image_url":"example image",
    "description":"example description"
}

response

{
    "message": "Organization Updated Successfully",
    "organization": {
        "id": 34,
        "name": "Mazingira's Organization",
        "email": "[email protected]",
        "image_url": "example image",
        "approval_status": false,
        "description": "example description"
    }
}

POST /beneficiary

An organization can create a beneficiary

Request

POST /beneficiary

Request format

{
    "name": "Beneficiary 2",
    "recieved_amount": 600,
    "image_url": "https://i.pinimg.com/originals/63/f9/d5/63f9d5fd5f34c8544a31c22c3e909cec.jpg"
}

response

{
    "id": 59,
    "image_url": "https://i.pinimg.com/originals/63/f9/d5/63f9d5fd5f34c8544a31c22c3e909cec.jpg",
    "name": "Beneficiary 2",
    "organization_id": 34,
    "recieved_amount": 600.0
}

POST /createpost

An organization can create a beneficiary story

Request

POST /createpost

Request format

{
    "title": "John Kimani",
    "content": "A full stack software engineer. Collaborating with other 4 Engineers to build a donation website.",
    "image_url": "https://something.com/asadsa.jpg"
}

response

{
      "content": "Street hair first significant skin play go. Tell stand light general treat walk I try. Population it eye necessary establish star. Professional child young certain move. Ball shake choice address another thing figure pull. Growth arm manager.",
      "created_at": "Sat, 11 May 2024 11:04:37 GMT",
      "id": 1,
      "image_url": "https://pbs.twimg.com/media/FpmD9sMXEAA4Mb7.jpg",
      "organization_id": 10,
      "title": "Kristine Peters"
    }

GET /beneficiary

Returns a list of beneficiaries as well as inventory sent to the beneficiaries

Request

GET /beneficiary

Response

[
        {
            "id": 59,
            "image_url": "https://i.pinimg.com/originals/63/f9/d5/63f9d5fd5f34c8544a31c22c3e909cec.jpg",
            "name": "Beneficiary 2",
            "organization_id": 34,
            "recieved_amount": 600.0
        }
    ]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •