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

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")
public class OrderController {

    private final CommandGateway commandGateway;

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

    @PostMapping("/pay")
    public void pay() {
        commandGateway.payOrder();
    }

    @PostMapping("/ship")
    public void ship() {
        commandGateway.shipOrder();
    }

    @PostMapping("/cancel")
    public void cancel() {
        commandGateway.cancelOrder();
    }
}
