package org.takiguchi.cerberus.cerberusapp.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.takiguchi.cerberus.cerberusapp.model.ReferentialDataDTO;
import org.takiguchi.cerberus.cerberusapp.model.ServiceType;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.takiguchi.cerberus.cerberusapp.model.ReferentialDataDTO.aReferentialData;

@RestController
@RequestMapping("/api/referentialData")
public class ReferentialDataController {
    @GetMapping("/serviceTypes")
    public List<ReferentialDataDTO> getServiceTypes() {
        return Stream.of(ServiceType.values())
                .map(type -> aReferentialData()
                        .withValue(type.name())
                        .withLabel(type.name().toLowerCase())
                        .build()
                )
                .collect(Collectors.toList());
    }
}
