Skip to content

Commit

Permalink
Merge pull request #421 from Ecwid/report-advice
Browse files Browse the repository at this point in the history
Add support for report advices endpoints
  • Loading branch information
mvgreen authored Jul 16, 2024
2 parents 69bcaae + fad3604 commit 13b770f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -277,6 +279,7 @@ interface ApplicationStorageApiClient {
// Report API
interface ReportsApiClient {
fun fetchReport(request: ReportRequest): FetchedReportResponse
fun getReportAdvice(request: ReportAdviceRequest): FetchedReportAdviceResponse
}

// Recurring subscriptions
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +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

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -12,4 +14,7 @@ class ReportsApiClientImpl(
override fun fetchReport(request: ReportRequest) =
apiClientHelper.makeObjectResultRequest<FetchedReportResponse>(request)

override fun getReportAdvice(request: ReportAdviceRequest) =
apiClientHelper.makeObjectResultRequest<FetchedReportAdviceResponse>(request)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.ecwid.apiclient.v3.dto.productreview.request.UpdatedProductReviewStat
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.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
Expand Down Expand Up @@ -95,6 +96,8 @@ val otherNullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
AllowNullable(FetchedReportResponse::comparePeriodDataset),
AllowNullable(FetchedReportResponse::additionalData),

AllowNullable(FetchedReportAdviceResponse::tip),

AllowNullable(FetchedReportResponse.FetchedDataset::startTimeStamp),
AllowNullable(FetchedReportResponse.FetchedDataset::endTimeStamp),
AllowNullable(FetchedReportResponse.FetchedDataset::percentage),
Expand Down

0 comments on commit 13b770f

Please sign in to comment.