- Clone the repository
- Change the directory
cd Mazingira_backend
and run the following commands
pipenv install && pipenv shell
cd server
export DATABASE_URI=postgresql://mazingira_user:ETf9S7HRc1cYbgOUSZGHfdNAEnGHAo3L@dpg-cp45l90cmk4c73eema9g-a.frankfurt-postgres.render.com/mazingira_db^C
python app.py
Creates a new donor and logs them in.
POST /register
{
"first_name":"Enoch",
"last_name": "Kibet",
"email": "[email protected]",
"password": "enoch"
}
Creates a new organization and logs them in.
POST /org/register
{
"name":"Mazingira's Organization",
"email": "[email protected]",
"password": "organization"
}
Authenticates & Authorizes a donor/admin.
POST /login
{
"email":"[email protected]",
"password":"enoch"
}
Authenticates & Authorizes an oorganization.
POST /org/login
{
"email":"[email protected]",
"password":"organization"
}
Checks for the current session
GET /checksession
{
"message": "Log In To Access Resource or Contact Mazingira"
}
{
"email": "[email protected]",
"first_name": "Enoch",
"id": 125,
"last_name": "Kibet",
"role": "donor"
}
Returns a list of all the approved and unapproved organizations
GET /admin
[
{
"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"
}
]
Returns one organization whether approved or unapproved
GET /admin/23
{
"approval_status": true,
"description": null,
"email": "[email protected]",
"id": 23,
"image_url": null,
"name": "Howell, White and Murphy"
}
Approves or rejects an organization application
PATCH /admin/23
{
"approval_status": true
}
{
"message": "Organization Updated Successfully",
"organization": {
"id": 23,
"name": "Howell, White and Murphy",
"email": "[email protected]",
"image_url": null,
"approval_status": true,
"description": null
}
}
Deletes one organization whether approved or unapproved
DELETE /admin/23
{
"message": "Organization deleted successfully"
}
{
"message": "Organization not found"
}
Returns a list of notifications when a new organization sign up
GET /admin/notification
[
{
"id": 1,
"message": "New organization "Org1" has signed up and is pending approval.",
"date_created": "currebt time",
"is_read": false,
}
]
Returns a list of all the approved organizations
GET /donor/organization
[
{
"approval_status": true,
"description": null,
"email": "[email protected]",
"id": 23,
"image_url": null,
"name": "Howell, White and Murphy"
}
]
Returns one approved organizations
GET /donor/organization/1
{
"approval_status": true,
"description": null,
"email": "[email protected]",
"id": 23,
"image_url": null,
"name": "Howell, White and Murphy"
}
Creates a donation for an organization
POST /donate
{
"amount": 400,
"anonymous": true,
"organization_id": 23
}
{
"amount": 400.0,
"anonymous": true,
"donor_id": 125,
"id": 55,
"organization_id": 23
}
Returns stories about beneficiaries of your donations
GET /donor/stories
{
"message": "No Stories Found. Make A Donation First"
}
[
{
"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"
}
]
Returns the details of the organization and approval status
GET /organization
{
"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"
}
Returns donations made to an organization
GET /organization/donations
[
{
"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
}
]
{
"message": "No Donations Found"
}
An organization can edit their details
PATCH /org/edit
{
"image_url":"example image",
"description":"example description"
}
{
"message": "Organization Updated Successfully",
"organization": {
"id": 34,
"name": "Mazingira's Organization",
"email": "[email protected]",
"image_url": "example image",
"approval_status": false,
"description": "example description"
}
}
An organization can create a beneficiary
POST /beneficiary
{
"name": "Beneficiary 2",
"recieved_amount": 600,
"image_url": "https://i.pinimg.com/originals/63/f9/d5/63f9d5fd5f34c8544a31c22c3e909cec.jpg"
}
{
"id": 59,
"image_url": "https://i.pinimg.com/originals/63/f9/d5/63f9d5fd5f34c8544a31c22c3e909cec.jpg",
"name": "Beneficiary 2",
"organization_id": 34,
"recieved_amount": 600.0
}
An organization can create a beneficiary story
POST /createpost
{
"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"
}
{
"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"
}
Returns a list of beneficiaries as well as inventory sent to the beneficiaries
GET /beneficiary
[
{
"id": 59,
"image_url": "https://i.pinimg.com/originals/63/f9/d5/63f9d5fd5f34c8544a31c22c3e909cec.jpg",
"name": "Beneficiary 2",
"organization_id": 34,
"recieved_amount": 600.0
}
]