package com.zioinfo.mall.integration;

import com.zioinfo.mall.common.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * GUARDiA 연계 조회 API — /api/mall/integration.
 *
 * <p>모든 응답은 ItsmSecuritySanitizer 로 정제된 상태로 반환된다(자격증명 제거).
 */
@RestController
@RequestMapping("/api/mall/integration")
@RequiredArgsConstructor
public class IntegrationController {

    private final ItsmClient itsm;
    private final ErpClient erp;
    private final CrmClient crm;

    /** ITSM SR 상태 조회 (CS 연계). */
    @GetMapping("/itsm/sr/{srId}")
    public ApiResponse<Map<String, Object>> sr(@PathVariable String srId) {
        return ApiResponse.ok(itsm.getSr(srId));
    }

    /** ERP 재고 조회 (SKU). */
    @GetMapping("/erp/stock/{sku}")
    public ApiResponse<Map<String, Object>> erpStock(@PathVariable String sku) {
        return ApiResponse.ok(erp.getStock(sku));
    }

    /** CRM 고객 인사이트 조회. */
    @GetMapping("/crm/customer/{key}/insight")
    public ApiResponse<Map<String, Object>> crmInsight(@PathVariable("key") String key) {
        return ApiResponse.ok(crm.getCustomerInsight(key));
    }
}
