Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
IDATG2204-Group10-Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Frederik Simonsen
IDATG2204-Group10-Project
Commits
5f322cfc
Commit
5f322cfc
authored
Apr 26, 2022
by
Matias Nordli
Browse files
Options
Downloads
Patches
Plain Diff
readme transporter update
parent
51b17bb0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+56
-33
56 additions, 33 deletions
README.md
endpoint/transporter.py
+7
-6
7 additions, 6 deletions
endpoint/transporter.py
with
63 additions
and
39 deletions
README.md
+
56
−
33
View file @
5f322cfc
...
...
@@ -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”
}
```
###
Custom
er
|
Custom
er endpoint | Methods | URI | Description |
###
Transport
er
|
Transport
er 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
...
...
This diff is collapsed.
Click to expand it.
endpoint/transporter.py
+
7
−
6
View file @
5f322cfc
...
...
@@ -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_
shipment
s
'
,
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment