@@ -12,6 +12,7 @@ import dev.atedeg.mdm.clientorders.api.*
12
12
import dev .atedeg .mdm .clientorders .api .repositories .*
13
13
import dev .atedeg .mdm .clientorders .api .services .*
14
14
import dev .atedeg .mdm .clientorders .dto .*
15
+ import dev .atedeg .mdm .products .dto .*
15
16
import dev .atedeg .mdm .utils .monads .*
16
17
17
18
object OrdersEndpoints :
@@ -27,6 +28,7 @@ object OrdersEndpoints:
27
28
.in(jsonBody[OrderReceivedDTO ].description(" The order that needs to be placed" ))
28
29
.out(stringBody.description(" The ID assigned to the placed order" ))
29
30
.errorOut(stringBody)
31
+ .description(" Creates a new order." )
30
32
31
33
val newOrderRoute : HttpRoutes [IO ] = Http4sServerInterpreter [IO ]().toRoutes(
32
34
newOrderEndpoint.serverLogic { o =>
@@ -36,29 +38,42 @@ object OrdersEndpoints:
36
38
)
37
39
38
40
@ SuppressWarnings (Array (" org.wartremover.warts.Any" ))
39
- val palletizeProductForOrderEndpoint : PublicEndpoint [ProductPalletizedForOrderDTO , String , Unit , Any ] =
40
- endpoint.post
41
- .in(" order" / " palletize" )
42
- .in(jsonBody[ProductPalletizedForOrderDTO ].description(" The product and quantity palletized for the given order" ))
41
+ val palletizeProductForOrderEndpoint : PublicEndpoint [(String , ProductWithQuantityDTO ), String , Unit , Any ] =
42
+ endpoint.put
43
+ .in(" order" )
44
+ .in(
45
+ path[String ]
46
+ .description(" The ID of the order for which the product needs to be palletized" )
47
+ .name(" order-id" ),
48
+ )
49
+ .in(" palletize" )
50
+ .in(jsonBody[ProductWithQuantityDTO ].description(" The product and quantity palletized for the given order" ))
43
51
.errorOut(stringBody)
52
+ .description(" Palletize a product for the given order." )
44
53
45
54
val palletizeProductForOrderRoute : HttpRoutes [IO ] = Http4sServerInterpreter [IO ]().toRoutes(
46
- palletizeProductForOrderEndpoint.serverLogic { p =>
47
- val action : ServerAction [Configuration , String , Unit ] = productPalletizedForOrderHandler(p)
55
+ palletizeProductForOrderEndpoint.serverLogic { case (orderID, ProductWithQuantityDTO (quantity, product)) =>
56
+ val action : ServerAction [Configuration , String , Unit ] =
57
+ productPalletizedForOrderHandler(ProductPalletizedForOrderDTO (orderID, quantity, product))
48
58
action.value.run(configuration)
49
59
},
50
60
)
51
61
52
62
@ SuppressWarnings (Array (" org.wartremover.warts.Any" ))
53
- val orderCompletedEndpoint : PublicEndpoint [OrderCompletedDTO , String , Unit , Any ] =
54
- endpoint.post
55
- .in(" order" / " complete" )
56
- .in(jsonBody[OrderCompletedDTO ].description(" The ID of the order that has been completed" ))
63
+ val orderCompletedEndpoint : PublicEndpoint [String , String , Unit , Any ] =
64
+ endpoint.put
65
+ .in(" order" )
66
+ .in(
67
+ path[String ]
68
+ .description(" The ID of the order that has been completed" )
69
+ .name(" order-id" ),
70
+ )
71
+ .in(" complete" )
57
72
.errorOut(stringBody)
58
73
59
74
val orderCompletedRoute : HttpRoutes [IO ] = Http4sServerInterpreter [IO ]().toRoutes(
60
75
orderCompletedEndpoint.serverLogic { o =>
61
- val action : ServerAction [Configuration , String , Unit ] = orderCompletedHandler(o )
76
+ val action : ServerAction [Configuration , String , Unit ] = orderCompletedHandler(OrderCompletedDTO (o) )
62
77
action.value.run(configuration)
63
78
},
64
79
)
0 commit comments