The Backend Challenge is a project that communicates with our customers via notifications. It allows sending of Promo codes and riders notification to customers via SMS
In search for new opportunites, I am inpired to take on this backend challenge.
Follow instructions to install the latest version of python for your platform in the python docs
Follow instructions to install the latest version of docker for your platform in the docker docs After Installation is complete, run:
docker-compose build
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
DOCKER help developers and development teams build and ship apps with ease. Docker allows you to build and share containerized applications and microservices.
-
Flask-CORS is the extension I used for cross origin request
docker-compose exec api python manage.py db init
docker-compose exec api python manage.py db migrate
docker-compose exec python manage.py db upgrade
docker-compose build
# docker run --env-file=.env -p 5000:5000 swvl
docker-compose up -d
# docker-compose exec db psql --username=postgres --dbname=swvl
# python manage.py test
docker-compose exec api python manage.py test
- fetches a collection of all notifications in the database
curl --location --request GET 'localhost:5000/api/notifications'
Sample Response:
{
"notifications": [
{
"channel": "sms",
"created_at": "Sat, 06 Mar 2021 15:34:38 GMT",
"group_name": null,
"id": 28,
"message": "Dear Customer, Your promo code is xx339kk. Best Regards",
"status": "sent",
"type": "single",
"user": {
"id": 1,
"language": "en",
"mobile": "23480000000523",
"name": "Mark Dean"
}
}
],
"status": true
}
- fetches a collection of all notifications per customer_id in the database
curl --location --request GET 'localhost:5000/api/notifications/customer/1'
Sample Response:
"notifications": [
{
"channel": "sms",
"created_at": "Sat, 06 Mar 2021 15:34:38 GMT",
"group_name": null,
"id": 28,
"message": "Dear Customer, Your promo code is xx339kk. Best Regards",
"status": "sent",
"type": "single",
"user": {
"id": 1,
"language": "en",
"mobile": "23480000000523",
"name": "Mark Dean"
}
}
],
"status": true
- send notification to customers
curl --location --request POST 'localhost:5000/api/notifications/send' \
--header 'Content-Type: application/json' \
--data-raw '{
"message": "Dear Customer, Your promo code is xx339kk. Best Regards",
"should_send_sms": true,
"should_send_push_notification": false,
"should_send_email": false,
"customer_id": 1
}'
Sample Response
{
"message": "sent",
"status": true
}
- send notification to a group of customers
curl --location --request POST 'localhost:5000/api/notifications/group/send' \
--header 'Content-Type: application/json' \
--data-raw '{
"message": "Dear Customer, Your promo code is xx339kk. Best Regards",
"should_send_sms": true,
"should_send_push_notification": false,
"should_send_email": false,
"group_id": 1
}'
Sample Response
{
"message": "sent",
"status": true
}
- send notification to riders
curl --location --request POST 'localhost:5000/api/notifications/riders' \
--header 'Content-Type: application/json' \
--data-raw '{
"message": "Dear Customer, Your promo code is xx339kk. Best Regards",
"should_send_sms": true,
"should_send_push_notification": false,
"should_send_email": false,
"user_id": 1
}'
Sample Response
{
"message": "sent",
"status": true
}