soat-fiap / FIAP.TechChallenge.ByteMeBurger

Repository for FIAP SOAT post degree Tech Challenge
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Implement Update Order Status API #76

Open italopessoa opened 1 month ago

italopessoa commented 1 month ago

Feature Request: Implement API Endpoint for Order Status Updates

Problem:

Currently, there is no API endpoint available to update the status of an order. This makes it difficult for external systems and integrations to manage the lifecycle of orders and keep their records up to date.

Proposed Solution:

Create an API endpoint that accepts an order ID and a new status as parameters and updates the status of that order accordingly. The supported order statuses should be configurable and may include:

Benefits:

Additional Considerations:

Example Usage:

PUT /api/orders/{order_id}
{
  "status": "Shipped"
}

Response:

{
  "order_id": 123,
  "status": "Shipped"
}
italopessoa commented 2 weeks ago
graph LR
    subgraph Presentation Layer
        API_Endpoint["Order Status Endpoint"]
    end
    subgraph Application Layer
        OrderController["Order Controller"]
        OrderStatusUseCase["Order Status Use Case"]
    end
    subgraph Domain Layer
        OrderRepository["Order Repository"]
        Order["Order"]
    end
    subgraph Infrastructure Layer
        Database["Database"]
    end
    API_Endpoint --> OrderController
    OrderController --> OrderStatusUseCase
    OrderStatusUseCase --> OrderRepository
    OrderRepository --> Database
    OrderStatusUseCase --> Order

Explanation:

Flow:

  1. A client sends a request to the API endpoint /order/{orderId}/status.
  2. The API endpoint forwards the request to the Order Controller.
  3. The Order Controller validates the request and calls the Order Status Use Case.
  4. The Order Status Use Case interacts with the Order Repository to retrieve the order with the specified ID from the database.
  5. The Order Repository interacts with the database to fetch the order data.
  6. The Order Status Use Case extracts the order status from the retrieved order.
  7. The Order Status Use Case returns the order status to the Order Controller.
  8. The Order Controller returns the order status to the API endpoint.
  9. The API endpoint returns the order status to the client.

Benefits of Clean Architecture:

Note: This is a basic representation of the architecture. The actual implementation might involve additional components and layers depending on the complexity of the application.