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

import click.kamil.examples.statemachine.extended.service.PaymentService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;

@RestController
public class PaymentController implements BaseController {

    private final PaymentService paymentService;

    public PaymentController(PaymentService paymentService) {
        this.paymentService = paymentService;
    }

    @Override
    public String processBaseEndpoint(@PathVariable String id) {
        paymentService.processPayment(id);
        return "Started Base Payment: " + id;
    }

    @PostMapping("/api/payment/{id}/capture")
    public String capturePaymentEndpoint(@PathVariable String id) {
        paymentService.capturePayment(id);
        return "Captured: " + id;
    }
}
