# Generated by smithplates HTTP codegen. Do not edit.
from typing import Annotated

from fastapi import (
    APIRouter,
    Body,
    Depends,
    Path,
)
from pydantic import Field  # noqa: F401

from generated.petstore.api.get_order_output import GetOrderOutput
from generated.petstore.api.petstore.api_response import dispatch_api_response
from generated.petstore.api.petstore.app_services import ApiServices, get_api_services
from generated.petstore.api.petstore.operation_bindings import OPERATION_HTTP_BINDINGS
from generated.petstore.api.place_order_input import PlaceOrderInput
from generated.petstore.api.place_order_output import PlaceOrderOutput

router = APIRouter()


@router.get(
    "/orders/{orderId}",
    responses={
        200: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def get_order(
    services: Annotated[ApiServices, Depends(get_api_services)],
    order_id: str = Path(..., alias="orderId"),
) -> GetOrderOutput:
    return dispatch_api_response(
        await services.orders_api.get_order(order_id=order_id),
        OPERATION_HTTP_BINDINGS["get_order"],
    )


@router.post(
    "/orders",
    responses={
        201: {"description": "Response"},
        400: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def place_order(
    services: Annotated[ApiServices, Depends(get_api_services)],
    place_order_input: PlaceOrderInput = Body(...),
) -> PlaceOrderOutput:
    return dispatch_api_response(
        await services.orders_api.place_order(place_order_input=place_order_input),
        OPERATION_HTTP_BINDINGS["place_order"],
    )
