package org.jeecg.modules.adweb.dmp.service.google;

import org.jeecg.common.util.FastJsonUtil;
import org.jeecg.modules.adweb.dmp.dto.google.analytics.report.GAReportRequestDTO;
import org.jeecg.modules.adweb.dmp.dto.google.analytics.report.ReportType;
import org.jeecg.modules.adweb.dmp.dto.google.analytics.report.data.CountryChartData;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("dev")
public class GoogleServiceTest {

    @Autowired GAReportService gaReportService;

    @Test
    public void testGAReport() {
        GAReportRequestDTO gaReportRequest = new GAReportRequestDTO();
        gaReportRequest.setPropertyResourceName("properties/457183952");
        gaReportRequest.setReportType(ReportType.ADWEB_COUNTRY_CHART);
        gaReportRequest.setStartDate("2023-10-01");
        gaReportRequest.setEndDate("2024-10-01");

        List<CountryChartData> countryReport =
                gaReportService.runGAReport(gaReportRequest, CountryChartData.class);

        System.out.println(FastJsonUtil.toJSONString(countryReport));
    }
}
