|
@@ -6,15 +6,14 @@ import com.wechi.adweb.bridge.common.OpenAPIRequest;
|
|
|
import com.wechi.adweb.bridge.common.OpenAPIResponse;
|
|
|
import com.wechi.adweb.bridge.exception.BadRequestException;
|
|
|
import com.wechi.adweb.bridge.exception.DataException;
|
|
|
+import com.wechi.adweb.bridge.google.analytics.dto.CreatePropertyRequestDTO;
|
|
|
import com.wechi.adweb.bridge.google.analytics.dto.GAAccountDTO;
|
|
|
-import com.wechi.adweb.bridge.google.analytics.dto.GADataStreamDTO;
|
|
|
import com.wechi.adweb.bridge.google.analytics.dto.GAPropertyDTO;
|
|
|
import com.wechi.adweb.bridge.google.analytics.dto.report.GAReportRequestDTO;
|
|
|
import com.wechi.adweb.bridge.google.analytics.dto.report.ReportType;
|
|
|
import com.wechi.adweb.bridge.google.analytics.dto.report.data.GAReportDataDTO;
|
|
|
import com.wechi.adweb.bridge.google.analytics.service.GAAdminService;
|
|
|
import com.wechi.adweb.bridge.google.analytics.service.GADataService;
|
|
|
-import com.wechi.adweb.bridge.google.common.CreateRequestDTO;
|
|
|
import com.wechi.adweb.bridge.util.JsonUtils;
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -83,38 +82,36 @@ public class GAController extends BaseController {
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
- // It's recommended to use hyphens (-) instead of underscores (_) in URLs.
|
|
|
- // See https://developers.google.com/search/docs/crawling-indexing/url-structure
|
|
|
- @PostMapping("/data-streams/create")
|
|
|
+ @PostMapping("/properties/create")
|
|
|
@ResponseBody
|
|
|
- public OpenAPIResponse<GADataStreamDTO> createGAPropertyWithDataStream(
|
|
|
- @RequestBody OpenAPIRequest<CreateRequestDTO> apiRequest)
|
|
|
+ public OpenAPIResponse<GAPropertyDTO> createGAPropertyWithDataStream(
|
|
|
+ @RequestBody OpenAPIRequest<CreatePropertyRequestDTO> apiRequest)
|
|
|
throws BadRequestException, DataException {
|
|
|
long start = System.currentTimeMillis();
|
|
|
log.info(
|
|
|
"****** createGAPropertyWithDataStream() ****** apiRequest = {}",
|
|
|
JsonUtils.toJson(apiRequest));
|
|
|
- CreateRequestDTO createRequest = apiRequest.getData();
|
|
|
+ CreatePropertyRequestDTO createPropertyRequest = apiRequest.getData();
|
|
|
|
|
|
// 1. Validates the request parameters.
|
|
|
- if (StringUtils.isEmpty(createRequest.getAccountResourceName())
|
|
|
- || StringUtils.isEmpty(createRequest.getDisplayName())
|
|
|
- || StringUtils.isEmpty(createRequest.getUrl())) {
|
|
|
+ if (StringUtils.isEmpty(createPropertyRequest.getAccountResourceName())
|
|
|
+ || StringUtils.isEmpty(createPropertyRequest.getDisplayName())
|
|
|
+ || StringUtils.isEmpty(createPropertyRequest.getUrl())) {
|
|
|
throw new BadRequestException(apiRequest);
|
|
|
}
|
|
|
|
|
|
// 2. Executes the API request.
|
|
|
- GADataStreamDTO createdDataStream =
|
|
|
+ GAPropertyDTO gaProperty =
|
|
|
gaAdminService.createGAPropertyWithDataStream(
|
|
|
- createRequest.getAccountResourceName(),
|
|
|
- createRequest.getDisplayName(),
|
|
|
- createRequest.getUrl());
|
|
|
+ createPropertyRequest.getAccountResourceName(),
|
|
|
+ createPropertyRequest.getDisplayName(),
|
|
|
+ createPropertyRequest.getUrl());
|
|
|
log.info(
|
|
|
"****** createGAPropertyWithDataStream() ****** duration = {} seconds",
|
|
|
getElapsedSeconds(start));
|
|
|
- return OpenAPIResponse.<GADataStreamDTO>builder()
|
|
|
+ return OpenAPIResponse.<GAPropertyDTO>builder()
|
|
|
.status(APIStatus.SUCCESS)
|
|
|
- .data(createdDataStream)
|
|
|
+ .data(gaProperty)
|
|
|
.build();
|
|
|
}
|
|
|
|