diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/AbstractReportRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/AbstractReportRequest.kt new file mode 100644 index 00000000..1c557379 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/AbstractReportRequest.kt @@ -0,0 +1,35 @@ +package com.ecwid.apiclient.v3.dto.report.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.dto.report.enums.* +import com.ecwid.apiclient.v3.responsefields.ResponseFields + +abstract class AbstractReportRequest : ApiRequest { + abstract val reportType: ReportType + abstract val startedFrom: Long? + abstract val endedAt: Long? + abstract val timeScaleValue: TimeScaleValue? + abstract val comparePeriod: ComparePeriod? + abstract val firstDayOfWeek: FirstDayOfWeek? + abstract val orderByMetric: String? + abstract val orderDirection: String? + abstract val limit: Int? + abstract val offset: Int? + abstract val responseFields: ResponseFields + abstract val storefrontPlatform: StorefrontPlatform? + + protected fun toParams(): Map { + return mutableMapOf().apply { + startedFrom?.let { put("startedFrom", it.toString()) } + endedAt?.let { put("endedAt", it.toString()) } + timeScaleValue?.let { put("timeScaleValue", it.toString()) } + comparePeriod?.let { put("comparePeriod", it.toString()) } + firstDayOfWeek?.let { put("firstDayOfWeek", it.toString()) } + orderByMetric?.let { put("orderByMetric", it) } + orderDirection?.let { put("orderDirection", it) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + storefrontPlatform?.let { put("storefrontPlatform", it.toString()) } + }.toMap() + } +} 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 b757c135..37cf7b5b 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 @@ -1,13 +1,23 @@ 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.dto.report.enums.* import com.ecwid.apiclient.v3.impl.RequestInfo import com.ecwid.apiclient.v3.responsefields.ResponseFields data class ReportAdviceRequest( - val reportType: ReportType = ReportType.allTraffic, -) : ApiRequest { + override val reportType: ReportType = ReportType.allTraffic, + override val startedFrom: Long? = null, + override val endedAt: Long? = null, + override val timeScaleValue: TimeScaleValue? = null, + override val comparePeriod: ComparePeriod? = null, + override val firstDayOfWeek: FirstDayOfWeek? = null, + override val orderByMetric: String? = null, + override val orderDirection: String? = null, + override val limit: Int? = null, + override val offset: Int? = null, + override val responseFields: ResponseFields = ResponseFields.All, + override val storefrontPlatform: StorefrontPlatform? = null, +) : AbstractReportRequest() { override fun toRequestInfo() = RequestInfo.createGetRequest( pathSegments = listOf( @@ -15,7 +25,7 @@ data class ReportAdviceRequest( reportType.toString(), "tip" ), - params = emptyMap(), + params = toParams(), responseFields = ResponseFields.All ) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportRequest.kt index b5d7c969..a68b76f1 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportRequest.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportRequest.kt @@ -1,25 +1,23 @@ package com.ecwid.apiclient.v3.dto.report.request -import com.ecwid.apiclient.v3.dto.ApiRequest import com.ecwid.apiclient.v3.dto.report.enums.* import com.ecwid.apiclient.v3.impl.RequestInfo import com.ecwid.apiclient.v3.responsefields.ResponseFields data class ReportRequest( - val reportType: ReportType = ReportType.allTraffic, - val startedFrom: Long? = null, - val endedAt: Long? = null, - val timeScaleValue: TimeScaleValue? = null, - val comparePeriod: ComparePeriod? = null, - val firstDayOfWeek: FirstDayOfWeek? = null, - val orderByMetric: String? = null, - val orderDirection: String? = null, - val limit: Int? = null, - val offset: Int? = null, - val responseFields: ResponseFields = ResponseFields.All, - val storefrontPlatform: StorefrontPlatform? = null, -) : ApiRequest { - + override val reportType: ReportType = ReportType.allTraffic, + override val startedFrom: Long? = null, + override val endedAt: Long? = null, + override val timeScaleValue: TimeScaleValue? = null, + override val comparePeriod: ComparePeriod? = null, + override val firstDayOfWeek: FirstDayOfWeek? = null, + override val orderByMetric: String? = null, + override val orderDirection: String? = null, + override val limit: Int? = null, + override val offset: Int? = null, + override val responseFields: ResponseFields = ResponseFields.All, + override val storefrontPlatform: StorefrontPlatform? = null, +) : AbstractReportRequest() { override fun toRequestInfo() = RequestInfo.createGetRequest( pathSegments = listOf( "reports", @@ -28,22 +26,4 @@ data class ReportRequest( params = toParams(), responseFields = responseFields, ) - - private fun toParams(): Map { - return mutableMapOf().apply { - startedFrom?.let { put("startedFrom", it.toString()) } - endedAt?.let { put("endedAt", it.toString()) } - timeScaleValue?.let { put("timeScaleValue", it.toString()) } - comparePeriod?.let { put("comparePeriod", it.toString()) } - firstDayOfWeek?.let { put("firstDayOfWeek", it.toString()) } - orderByMetric?.let { put("orderByMetric", it) } - orderDirection?.let { put("orderDirection", it) } - limit?.let { put("limit", it.toString()) } - offset?.let { put("offset", it.toString()) } - storefrontPlatform?.let { put("storefrontPlatform", it.toString()) } - }.toMap() - } - - - } 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 6d7c9287..e0ed2c84 100644 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt @@ -18,6 +18,7 @@ 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 @@ -84,6 +85,17 @@ val otherNullablePropertyRules: List> = listOf( AllowNullable(ReportRequest::offset), AllowNullable(ReportRequest::storefrontPlatform), + AllowNullable(ReportAdviceRequest::startedFrom), + AllowNullable(ReportAdviceRequest::endedAt), + AllowNullable(ReportAdviceRequest::timeScaleValue), + AllowNullable(ReportAdviceRequest::comparePeriod), + AllowNullable(ReportAdviceRequest::firstDayOfWeek), + AllowNullable(ReportAdviceRequest::orderByMetric), + AllowNullable(ReportAdviceRequest::orderDirection), + AllowNullable(ReportAdviceRequest::limit), + AllowNullable(ReportAdviceRequest::offset), + AllowNullable(ReportAdviceRequest::storefrontPlatform), + AllowNullable(FetchedReportResponse::timeScaleValue), AllowNullable(FetchedReportResponse::comparePeriod), AllowNullable(FetchedReportResponse::firstDayOfWeek),