package com.zioinfo.mall.gateway;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * Google Maps Places/Directions 어댑터 (mall.address.provider=google).
 * 키는 환경변수 GOOGLE_MAPS_API_KEY만. 키 없으면 비활성. 실연동은 운영 배포 시 구현.
 */
@Component
@ConditionalOnProperty(name = "mall.address.provider", havingValue = "google")
public class GoogleMapsVerifier implements AddressVerifier {

    @Value("${GOOGLE_MAPS_API_KEY:}")
    private String apiKey;

    private void requireKey() {
        if (apiKey == null || apiKey.isBlank()) {
            throw new IllegalStateException("ERR-ADDR-CONFIG: GOOGLE_MAPS_API_KEY 미설정");
        }
    }

    @Override
    public Map<String, Object> verify(String address, String zip) {
        requireKey();
        throw new UnsupportedOperationException("ERR-ADDR-IMPL: Google Maps 실연동은 운영 배포 시 구현");
    }

    @Override
    public Map<String, Object> route(List<String> addresses, String origin) {
        requireKey();
        throw new UnsupportedOperationException("ERR-ADDR-IMPL: Google Maps 라우팅은 운영 배포 시 구현");
    }

    @Override
    public String provider() {
        return "google";
    }
}
