From 808ac16b8ae4adb0290709c7c6292a1e61ed9cc5 Mon Sep 17 00:00:00 2001 From: ringo Date: Mon, 15 Jul 2024 17:27:40 +0400 Subject: [PATCH 1/4] Add support for report advices endpoints --- .../com/ecwid/apiclient/v3/ApiClient.kt | 3 +++ .../dto/report/request/ReportAdviceRequest.kt | 22 +++++++++++++++++++ .../result/FetchedReportAdviceResponse.kt | 5 +++++ .../apiclient/v3/impl/ReportsApiClientImpl.kt | 5 +++++ .../v3/rule/NullablePropertyRules.kt | 4 ++++ 5 files changed, 39 insertions(+) create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt create mode 100644 src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt index df8896fe6..41689b9e8 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt @@ -32,7 +32,9 @@ import com.ecwid.apiclient.v3.dto.productreview.request.* import com.ecwid.apiclient.v3.dto.productreview.result.* import com.ecwid.apiclient.v3.dto.producttype.request.* import com.ecwid.apiclient.v3.dto.producttype.result.* +import com.ecwid.apiclient.v3.dto.report.request.ReportAdviceRequest import com.ecwid.apiclient.v3.dto.report.request.ReportRequest +import com.ecwid.apiclient.v3.dto.report.result.FetchedReportAdviceResponse import com.ecwid.apiclient.v3.dto.report.result.FetchedReportResponse import com.ecwid.apiclient.v3.dto.saleschannels.request.* import com.ecwid.apiclient.v3.dto.saleschannels.response.* @@ -277,6 +279,7 @@ interface ApplicationStorageApiClient { // Report API interface ReportsApiClient { fun fetchReport(request: ReportRequest): FetchedReportResponse + fun getReportAdvice(request: ReportAdviceRequest): FetchedReportAdviceResponse } // Recurring subscriptions diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt new file mode 100644 index 000000000..10bd7b451 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt @@ -0,0 +1,22 @@ +package com.ecwid.apiclient.v3.dto.report.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.dto.report.enums.ReportType +import com.ecwid.apiclient.v3.impl.RequestInfo +import com.ecwid.apiclient.v3.responsefields.ResponseFields + +data class ReportAdviceRequest( + val reportType: ReportType = ReportType.allTraffic, +): ApiRequest { + + override fun toRequestInfo() = RequestInfo.createGetRequest( + pathSegments = listOf( + "reports", + reportType.toString(), + "tip" + ), + params = emptyMap(), + responseFields = ResponseFields.All + ) + +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt new file mode 100644 index 000000000..c49333554 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt @@ -0,0 +1,5 @@ +package com.ecwid.apiclient.v3.dto.report.result + +data class FetchedReportAdviceResponse( + val tip: String? = null +) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/impl/ReportsApiClientImpl.kt b/src/main/kotlin/com/ecwid/apiclient/v3/impl/ReportsApiClientImpl.kt index 224eb6cb4..d289b1947 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/impl/ReportsApiClientImpl.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/impl/ReportsApiClientImpl.kt @@ -2,7 +2,9 @@ package com.ecwid.apiclient.v3.impl import com.ecwid.apiclient.v3.ApiClientHelper import com.ecwid.apiclient.v3.ReportsApiClient +import com.ecwid.apiclient.v3.dto.report.request.ReportAdviceRequest import com.ecwid.apiclient.v3.dto.report.request.ReportRequest +import com.ecwid.apiclient.v3.dto.report.result.FetchedReportAdviceResponse import com.ecwid.apiclient.v3.dto.report.result.FetchedReportResponse class ReportsApiClientImpl( @@ -12,4 +14,7 @@ class ReportsApiClientImpl( override fun fetchReport(request: ReportRequest) = apiClientHelper.makeObjectResultRequest(request) + override fun getReportAdvice(request: ReportAdviceRequest) = + apiClientHelper.makeObjectResultRequest(request) + } diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt index c42a6de4d..36ab14b36 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt @@ -18,7 +18,9 @@ import com.ecwid.apiclient.v3.dto.product.result.ProductInventoryUpdateResult import com.ecwid.apiclient.v3.dto.productreview.request.UpdatedProductReviewStatus import com.ecwid.apiclient.v3.dto.profile.request.StoreProfileRequest import com.ecwid.apiclient.v3.dto.profile.result.FetchedLatestStats +import com.ecwid.apiclient.v3.dto.report.request.ReportAdviceRequest import com.ecwid.apiclient.v3.dto.report.request.ReportRequest +import com.ecwid.apiclient.v3.dto.report.result.FetchedReportAdviceResponse import com.ecwid.apiclient.v3.dto.report.result.FetchedReportResponse import com.ecwid.apiclient.v3.dto.storage.result.FetchedStorageData import com.ecwid.apiclient.v3.dto.variation.request.ProductVariationsRequest @@ -95,6 +97,8 @@ val otherNullablePropertyRules: List> = listOf( AllowNullable(FetchedReportResponse::comparePeriodDataset), AllowNullable(FetchedReportResponse::additionalData), + AllowNullable(FetchedReportAdviceResponse::tip), + AllowNullable(FetchedReportResponse.FetchedDataset::startTimeStamp), AllowNullable(FetchedReportResponse.FetchedDataset::endTimeStamp), AllowNullable(FetchedReportResponse.FetchedDataset::percentage), From 82f65801dd8d8f89e0eb8d09116d6f6be657d8e3 Mon Sep 17 00:00:00 2001 From: ringo Date: Mon, 15 Jul 2024 19:00:36 +0400 Subject: [PATCH 2/4] Fix detekt warnings --- .../dto/report/request/ReportAdviceRequest.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt index 10bd7b451..b757c135c 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportAdviceRequest.kt @@ -7,16 +7,16 @@ import com.ecwid.apiclient.v3.responsefields.ResponseFields data class ReportAdviceRequest( val reportType: ReportType = ReportType.allTraffic, -): ApiRequest { +) : ApiRequest { override fun toRequestInfo() = RequestInfo.createGetRequest( - pathSegments = listOf( - "reports", - reportType.toString(), - "tip" - ), - params = emptyMap(), - responseFields = ResponseFields.All - ) + pathSegments = listOf( + "reports", + reportType.toString(), + "tip" + ), + params = emptyMap(), + responseFields = ResponseFields.All + ) } From 8aa7d4017b736a1e391a142b00a2ca212fa5ea1b Mon Sep 17 00:00:00 2001 From: ringo Date: Mon, 15 Jul 2024 19:10:09 +0400 Subject: [PATCH 3/4] Fix warnings --- .../kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt index 36ab14b36..b8fd414bd 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt @@ -18,7 +18,6 @@ import com.ecwid.apiclient.v3.dto.product.result.ProductInventoryUpdateResult import com.ecwid.apiclient.v3.dto.productreview.request.UpdatedProductReviewStatus import com.ecwid.apiclient.v3.dto.profile.request.StoreProfileRequest import com.ecwid.apiclient.v3.dto.profile.result.FetchedLatestStats -import com.ecwid.apiclient.v3.dto.report.request.ReportAdviceRequest import com.ecwid.apiclient.v3.dto.report.request.ReportRequest import com.ecwid.apiclient.v3.dto.report.result.FetchedReportAdviceResponse import com.ecwid.apiclient.v3.dto.report.result.FetchedReportResponse From fad3604a1009b016230d0225aa295626e68fb6da Mon Sep 17 00:00:00 2001 From: ringo Date: Tue, 16 Jul 2024 11:17:38 +0400 Subject: [PATCH 4/4] Add implementation of ApiFetchedDTO and fix error message --- .../v3/dto/report/result/FetchedReportAdviceResponse.kt | 8 +++++++- .../kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt index c49333554..1eb74d585 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportAdviceResponse.kt @@ -1,5 +1,11 @@ package com.ecwid.apiclient.v3.dto.report.result +import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO + data class FetchedReportAdviceResponse( val tip: String? = null -) +) : ApiFetchedDTO { + + override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadOnly + +} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt index 81f11545d..0505a327b 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt @@ -151,7 +151,7 @@ class DtoContractUnitTest { .filterNot { dtoClass -> dtoClass.isClassifiedDTOOrEnclosingClass(*dtoMarkerInterfaces) } assertTrue(problemDtoClasses.isEmpty()) { val interfacesStr = dtoMarkerInterfaces.joinToString(separator = ", ") { int -> int.simpleName } - "Some of top level DTO data classes does implement one of marker interfaces [$interfacesStr]:\n" + + "Some of top level DTO data classes do not implement any marker interfaces [$interfacesStr]:\n" + classesToLoggableString(problemDtoClasses) } }