package click.kamil.examples.statemachine.layered.web;

import click.kamil.examples.statemachine.layered.order.PayRichOrderEvent;
import click.kamil.examples.statemachine.layered.order.ShipRichOrderEvent;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/orders/rich")
public class RichOrderController {

    private final CommandGateway commandGateway;

    public RichOrderController(CommandGateway commandGateway) {
        this.commandGateway = commandGateway;
    }

    @PostMapping("/pay")
    public void payViaRichEvent() {
        commandGateway.payOrderViaRichEvent(new PayRichOrderEvent());
    }

    @PostMapping("/ship")
    public void shipViaRichEvent() {
        commandGateway.shipOrderViaRichEvent(new ShipRichOrderEvent());
    }
}
