package com.kapdion.omds.productdefinitions;

import at.vvo.omds.types.omds3.r2025_05.common.ProductsRequest;

import com.kapdion.omds.productdefinitions.apriori.AprioriService;
import com.kapdion.omds.productdefinitions.calculate.CalculateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;

@Slf4j
@RestController

public class EndpointsZentralesBOA {

    @PostMapping("/ProductsRequest")
    public HydraResponse<List<Object>> apriori(@RequestBody ProductsRequest productsRequest){
        AprioriService as = new AprioriService();
        List<Object> s = Collections.singletonList(as.getProductsResponse(productsRequest));
        HydraResponse<List<Object>> r = new HydraResponse<>(s);
        System.out.println("-----------------------");
        System.out.println("Products request: " + r.data.toString());

        return r;
    };

    @PostMapping("/CalculateRequest")
    public String calc(@RequestBody String calculateRequest) throws Exception {
        CalculateService cs = new CalculateService();
        String s = cs.buildResponse(calculateRequest);
        System.out.println("-----------------------");
        System.out.println("Calculate request: " + s);
        return s;
    };

}
