This is a Microservice called “Order Service”.
$ docker-compose up -d
$ docker-compose stop
$ docker-compose exec php composer install
$ docker-compose exec php bin/console doctrine:mongodb:schema:create
$ docker-compose exec php ./bin/phpunit
POST /
Payload:
{
"order_id": 460,
"status": "Pending Confirmation",
"amount": 385,
"lines": [
{
"sku": "sku-1",
"price": 1,
"quantity": 1
},
{
"sku": "sku-2",
"price": 10,
"quantity": 5
}
],
"shipping_address": "address",
"billing_address": "address"
}
GET /460
Response:
{
"status": "ok",
"data": {
"order_id": 460,
"status": "Pending Confirmation",
"amount": 850,
"lines": [
{
"sku": "sku-1",
"price": 1,
"quantity": 1
},
{
"sku": "sku-2",
"price": 10,
"quantity": 5
}
],
"shipping_address": "address",
"billing_address": "address"
}
}
PUT /460
Payload:
{
"status": "Shipped",
}
Response:
{
"status": "ok",
"message": ""
}
** Check /var/log/dev.log for see the Order Status Event fired. ( app.INFO: Order status updated [] [] )
- Input validations
- Method PUT only updates the status of the Order. Should allow update other Order data like Lines
- OrderId should be auto-generated? That depends of who has this responsability. I assumed the OrderId comes from the client of this service.
- Create address shipping and billing as Collections and threat with DTOs and VOs (email, street, name...)
- Create Repository for extract this responsability from the OrderService
- Tests over OrderService (unit and functional)