First must be provided .env file, which contains:
- DB_USER - PostgreSQL username
- DB_PASSWORD - PostgreSQL username password
- DB_PORT - PostgreSQL port
- DB_NAME - database name
- TEST_DB_NAME - test database name
- AWS_ACCESS_KEY - AWS access key
- AWS_SECRET - AWS access secret key
- AWS_BUCKET - AWS bucket name
- AWS_REGION - AWS bucket region
- JWT_KEY - JWT key
The application is running from the main.py file. You need to set or export FLASK_APP = "main.py", after that you need to execute flask run. The server is running on default 127.0.0.1:5000.
POST /register
curl -X POST -H "Content-Type: application/json" -d '{"password": "123456", "email": "test@testov.com", "first_name": "<first_name>", "last_name": "<last_name>", "phone": "+359111111111"}' http://127.0.0.1:5000/register
HTTP/1.1" 201 CREATED
{ "token": "<customer_token>" }
POST /login
curl -X POST -H "Content-Type: application/json" -d '{"password": "123456", "email": "test@testov.com"}' http://127.0.0.1:5000/login
HTTP/1.1" 200 OK
{ "token": "<customer_token>" }
POST /customers/orders
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"title": "<title_>", "description": "<description_>", "stl": <stl_file_in_base64>, "address": "<address_>"}' http://127.0.0.1:5000/customers/orders
! (color optional) !
HTTP/1.1" 201 CREATED
{ "color": null, "pk": 9, "address": "<address_>", "description": "<description_>", "title": "buton", "stl_url": "<url_in_aws_s3_bucket>", "create_on": "2022-01-03T11:16:51.478377", "customer_pk": 7 }
GET /customers/orders
curl -H "Authorization: Bearer <token_>" http://127.0.0.1:5000/customers/orders
HTTP/1.1" 200 OK
{ "color": null, "pk": 9, "address": "<address_>", "description": "<description_>", "title": "buton", "stl_url": "<url_in_aws_s3_bucket>", "create_on": "2022-01-03T11:16:51.478377", "customer_pk": 7 }
Update info about order (on update you can't make change of the stl file, you must make new order for new file!)
PUT /customers/orders/<int:pk_>
curl -X PUT "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"title": "<title>", "description": "<description>", "stl_url": "<stl_url_in_s3_bucket>", "address": "<address>"}' http://127.0.0.1:5000/customers/orders/<int:pk_>
HTTP/1.1" 200 OK
{ "color": null, "pk": 9, "address": "<address_>", "description": "<description_>", "title": "buton", "stl_url": "<url_in_aws_s3_bucket>", "create_on": "2022-01-03T11:16:51.478377", "customer_pk": 7 }
'DELETE /customers/orders/int:pk_`
curl -X DELETE -H "Authorization: Bearer <admin_token>" http://127.0.0.1:5000/customers/orders/int:pk_
HTTP/1.1" 204 NO CONTENT
POST /admins/create-admin
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <admin_token>" -d '{"password": "<password_>", "email": "<email_>", "first_name": "<first_name>", "last_name": "<last_name>", "phone": "+359111111111}' http://127.0.0.1:5000/admins/create-admin
HTTP/1.1" 201 CREATED
{ "token": "" }
POST /admins/login
curl -X POST -H "Content-Type: application/json" -d '{"password": "<password_>", "email": "<email_>"}' http://127.0.0.1:5000/admins/login
HTTP/1.1" 200 OK
{ "token": "<token_>" }
POST /workers/create-worker
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <admin_token>" -d '{"password": "<password_>", "email": "<email_>", "first_name": "<first_name>", "last_name": "<last_name>", "phone": "+359111111111}' http://127.0.0.1:5000/workers/create-workers
HTTP/1.1" 201 CREATED
{ "token": "<token_>" }
POST /workers/login
curl -X POST -H "Content-Type: application/json" -d '{"password": "<password_>", "email": "<email_>"}' http://127.0.0.1:5000/workers/login
HTTP/1.1" 200 OK
{ "token": "<token_>" }
POST /workers/offers
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <worker_token>" -d '{ "title": "towa e ofertata za izrabotka na buton", "amount": 20, "order_pk": 5 }' http://127.0.0.1:5000/workers/offers
HTTP/1.1" 201 CREATED
{ "pk": 2, "title": "towa e ofertata za izrabotka na buton", "status": "pending", "amount": 20.0, "order_pk": 5 }
List all offers (for customer you see offers for your orders, if you are admin or worker - you receive response for all offers)
GET /workers/offers
curl -H "Authorization: Bearer <your_token>" http://127.0.0.1:5000/workers/offers
HTTP/1.1" 200 OK
{ "pk": 5, "title": "towa e ofertata za izrabotka na buton", "status": "pending", "amount": 20.0, "order_pk": 16 }
'DELETE /workers/offers/int:pk_`
curl -X DELETE -H "Authorization: Bearer <admin_token>" http://127.0.0.1:5000/workers/offers/int:pk_
HTTP/1.1" 204 NO CONTENT
PUT /workers/offers/<int:pk_>
curl -X PUT "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{
"title": "towa e novata oferta za izrabotka na buton",
"amount": 30,
"order_pk": 5
}' http://127.0.0.1:5000/workers/offers/<int:pk_>
HTTP/1.1" 200 OK
{ "pk": 1, "title": "towa e novata oferta za izrabotka na buton", "status": "pending", "amount": 30.0, "order_pk": 5 }
GET /customers/offers/<int:pk_>/accept
curl -H "Authorization: Bearer <token_>" http://127.0.0.1:5000/customers/offers/int:pk_/accept
HTTP/1.1" 200 OK
{ "pk": 5, "title": "towa e ofertata za izrabotka na buton", "status": "accepted", "amount": 20.0, "order_pk": 16 }
GET /customers/offers/<int:pk_>/refuse
curl -H "Authorization: Bearer <token_>" http://127.0.0.1:5000/customers/offers/int:pk_/refuse
HTTP/1.1" 200 OK
{ "pk": 4, "title": "towa e ofertata za izrabotka na buton", "status": "rejected", "amount": 20.0, "order_pk": 15 }
GET /workers/products
curl -H "Authorization: Bearer " http://127.0.0.1:5000/workers/products
HTTP/1.1" 200 OK
{ "pk": 1, "photo_url": "https://damyans-bucket.s3.eu-central-1.amazonaws.com/6ccbee4a-6212-4d34-bcf7-e19786e5ac0b.jpg", "description": "Some description", "title": "Some nice product", "create_on": "2022-01-01T18:50:51.318235", "amount": 30.0 }
! ! ! LIST OF ALL PRODUCTS ! ! !
POST /workers/products
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <worker_token>" -d '{ "amount": 30, "photo_extension": "jpg", "photo": "title": "Some nice product", "description": "Some description" } ' http://127.0.0.1:5000/workers/offers
HTTP/1.1" 201 CREATED
{ "pk": 11, "photo_url": "https://damyans-bucket.s3.eu-central-1.amazonaws.com/e62ef383-a234-49b6-9c80-fbfed6d5174a.jpg", "description": "Some description", "title": "Some nice product", "create_on": "2022-01-03T21:03:50.863564", "amount": 30.0 }
'DELETE /workers/products/int:pk_`
curl -X DELETE -H "Authorization: Bearer <admin_token>" http://127.0.0.1:5000/workers/products/int:pk_
HTTP/1.1" 204 NO CONTENT
PUT /workers/products/<int:pk_>
curl -X PUT "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{
"amount": 30,
"photo_url": "https://damyans-bucket.s3.eu-central-1.amazonaws.com/239a7e60-9f48-47e3-8a94-e5b87bc96b04.jpg",
"title": "Some nice product",
"description": "Some description"
}' http://127.0.0.1:5000/workers/products/<int:pk_>
HTTP/1.1" 200 OK
{ "create_on": "2022-01-01T18:50:53.080319", "description": "Some description", "amount": 30.0, "title": "Some nice product", "pk": 2, "photo_url": "https://damyans-bucket.s3.eu-central-1.amazonaws.com/239a7e60-9f48-47e3-8a94-e5b87bc96b04.jpg" }
POST /workers/products/<int:pk_>/add-to-cart
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <worker_token>" -d '{ "quantity": 5 }' http://127.0.0.1:5000/workers/products/int:pk_/add-to-cart
HTTP/1.1" 201 CREATED
{ "quantity": 5, "pk": 2, "status": "open", "product_pk": 3, "customer_pk": 10 }
PUT /workers/products/<int:pk_>/add-to-cart
curl -X PUT "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{
"quantity": 6
}'' http://127.0.0.1:5000/workers/products/<int:pk_>/add-to-cart
HTTP/1.1" 200 OK
{ "quantity": 6, "pk": 2, "status": "open", "product_pk": 3, "customer_pk": 10 }
PUT /customers/cart
curl -X PUT "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{
"address": "ulishta Dvadeset i chetwyrta Nomer 9"}'
http://127.0.0.1:5000//customers/cart
HTTP/1.1" 200 OK
{ "quantity": 6, "pk": 2, "status": "closed", "product_pk": 3, "shipped": "no", "address": "ulishta Dvadeset i chetwyrta Nomer 9", "customer_pk": 10 }
GET /customers/cart
curl -H "Authorization: Bearer <token_>" http://127.0.0.1:5000/customers/cart
HTTP/1.1" 200 OK
{ "quantity": 5, "pk": 4, "status": "open", "product_pk": 4, "shipped": "no", "address": null, "customer_pk": 12 }
GET /access/cart
curl -H "Authorization: Bearer <token_>" http://127.0.0.1:5000/access/cart
HTTP/1.1" 200 OK
{ "quantity": 5, "pk": 1, "status": "closed", "product_pk": 3, "shipped": "yes", "address": "ulishta Dvadeset i chetwyrta Nomer 9", "customer_pk": 1 }
GET /access/cart/<int:pk_>
curl -H "Authorization: Bearer <token_>" http://127.0.0.1:5000/access/cart/int:pk_
HTTP/1.1" 200 OK
{ "quantity": 6, "pk": 2, "status": "closed", "product_pk": 3, "shipped": "yes", "address": "ulishta Dvadeset i chetwyrta Nomer 9", "customer_pk": 10 }