package click.kamil.multi.core;

import click.kamil.multi.api.OrderApi;
import lombok.RequiredArgsConstructor;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.StateMachineFactory;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class OrderController implements OrderApi {

    private final StateMachineFactory<String, String> factory;

    @Override
    public void submitOrder(String orderId) {
        StateMachine<String, String> sm = factory.getStateMachine(orderId);
        sm.sendEvent("SUBMIT");
    }
}
