Skip to content
Snippets Groups Projects
Commit 5f322cfc authored by Matias Nordli's avatar Matias Nordli
Browse files

readme transporter update

parent 51b17bb0
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,52 @@ This is the project repo of Group 10's project in IDATG2204, Data Modeling and D
## API request guide
### Customer
| Customer endpoint | Methods | URI | Description |
| :--- | :--- | :--- | :--- |
| get_production_plan | GET | http://localhost:5000/get_production_plan | Retrieve a four week plan summary with *date* filter |
| delete_order | POST | http://localhost:5000/delete_order | Delete an order with a given *order_number* |
| new_order | POST | http://localhost:5000/new_order | Create a new order with given *customer_id*, *product_no* and *quantity* |
| get_order_since | GET | http://localhost:5000/get_order_since | Retrieve orders made since a given *date* |
| get_order | GET | http://localhost:5000/get_order | Retrieve an order with a given *order_number* |
|
#### **Body examples**
* get_production_plan
```
{
"date": "2020-01-01"
}
```
* delete_order
```
{
"order_number": 1
}
```
* new_order
```
{
"customer_id": 1,
"product_no": 2,
"quantity": 3
}
```
* get_order_since
```
{
"date": "2022-01-01"
}
```
* get_order
```
{
"order_number": 7
}
```
**CustomerRep endpoint:**
```
get_orders_new
......@@ -72,49 +118,26 @@ Body example:
“order_number”:”2”
}
```
### Customer
| Customer endpoint | Methods | URI | Description |
### Transporter
| Transporter endpoint | Methods | URI | Description |
| :--- | :--- | :--- | :--- |
| get_production_plan | GET | http://localhost:5000/get_production_plan | Retrieve a four week plan summary with \<date> filter |
| delete_order | POST | http://localhost:5000/delete_order | Delete an order with a given \<order_nr> |
| new_order | POST | http://localhost:5000/new_order | Create a new order with given \<customer_id>, \<product_no> and \<quantity> |
| get_order_since | GET | http://localhost:5000/get_order_since | Retrieve orders made since a given \<date> |
| get_order | GET | http://localhost:5000/get_order | Retrieve an order with a given \<order_nr> |
| get_ready_shipments | GET | http://localhost:5000/get_ready_shipments | Get all shipments with *state*='ready' |
| pick_up_shipment | PUT | http://localhost:5000/pick_up_shipment | Change shipment with given order number to *state*='picked up' |
|
#### **Body examples**
* get_production_plan body example
* get_ready_shipments
```
{
"date": "2020-01-01"
}
No body required
```
* delete_order body example
* pick_up_shipment
```
{
"order_number": 1
}
```
* new_order body example
```
{
"customer_id": 1,
"product_no": 2,
"quantity": 3
}
```
* get_order_since body example
```
{
"date": "2022-01-01"
}
```
* get_order body example
```
{
"order_number": 7
}
```
## Missing parts
......
......@@ -10,15 +10,14 @@ app.config['MYSQL_DB']="ski_equipment_factory"
mysql = MySQL(app)
#Transporter function, work in progress
@app.route('/get_shipment_state',methods=['GET'])
# Get all shipments with state 'ready'
@app.route('/get_ready_shipments',methods=['GET'])
def get_shipment_ready():
if request.method == 'GET':
cur=mysql.connection.cursor()
shipment_ready= cur.execute("SELECT * FROM `shipment` WHERE `state` = 'ready'")
if shipment_ready > 0:
......@@ -38,15 +37,17 @@ def pick_up_shipment():
cur=mysql.connection.cursor()
#Updates the state
pickUp=cur.execute("UPDATE `shipment` SET state='picked up' WHERE shipment_number=%s",(shipment_number,))
mysql.connection.commit()
#Checks if PUT succeeds
if pickUp > 0:
pickUp = cur.fetchall()
else:
return jsonify("No shipments matching requested number or shipment is already picked up."),404
order=cur.execute("SELECT * FROM `shipment` WHERE `shipment_number`=%s",(shipment_number,))
order=cur.execute("SELECT * FROM `shipment` WHERE `shipment_number`=%s",(shipment_number,)) #Output if success
order=cur.fetchall()
cur.close()
return jsonify(order),200
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment