Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for report advices endpoints #421

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading