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 1 commit
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 {

Check warning

Code scanning / detekt

Reports spaces around colons Warning

Missing spacing before ":"

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,5 @@
package com.ecwid.apiclient.v3.dto.report.result

data class FetchedReportAdviceResponse(
val tip: String? = null
)
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 @@ -18,7 +18,9 @@
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

Check warning

Code scanning / detekt

Detects unused imports Warning test

Unused import
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 +97,8 @@
AllowNullable(FetchedReportResponse::comparePeriodDataset),
AllowNullable(FetchedReportResponse::additionalData),

AllowNullable(FetchedReportAdviceResponse::tip),

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