Skip to content

Commit 98f1eb0

Browse files
authored
Merge pull request #268 from Ecwid/report_api
Fix deserialization of enums
2 parents 7a4761a + 546f57a commit 98f1eb0

6 files changed

Lines changed: 24 additions & 24 deletions

File tree

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.ecwid.apiclient.v3.dto.report.enums
22

3-
enum class ComparePeriod(val alias: String) {
4-
PREVIOUS_PERIOD("previousPeriod"),
5-
SIMILAR_PERIOD_IN_PREVIOUS_WEEK("similarPeriodInPreviousWeek"),
6-
SIMILAR_PERIOD_IN_PREVIOUS_MONTH("similarPeriodInPreviousMonth"),
7-
SIMILAR_PERIOD_IN_PREVIOUS_YEAR("similarPeriodInPreviousYear"),
8-
NO_COMPARE_PERIOD("noComparePeriod");
3+
enum class ComparePeriod {
4+
previousPeriod,
5+
similarPeriodInPreviousWeek,
6+
similarPeriodInPreviousMonth,
7+
similarPeriodInPreviousYear,
8+
noComparePeriod;
99
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.ecwid.apiclient.v3.dto.report.enums
22

3-
enum class FirstDayOfWeek(val alias: String) {
4-
MONDAY("monday"),
5-
SUNDAY("sunday");
3+
enum class FirstDayOfWeek {
4+
monday,
5+
sunday;
66
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.ecwid.apiclient.v3.dto.report.enums
22

3-
enum class ReportType(val alias: String) {
4-
ALL_TRAFFIC("allTraffic"),
5-
NEW_VS_RETURNING_VISITORS("newVsReturningVisitors"),
3+
enum class ReportType {
4+
allTraffic,
5+
newVsReturningVisitors,
66
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.ecwid.apiclient.v3.dto.report.enums
22

3-
enum class TimeScaleValue(val alias: String) {
4-
HOUR("hour"),
5-
DAY("day"),
6-
WEEK("week"),
7-
MONTH("month"),
8-
YEAR("year");
3+
enum class TimeScaleValue {
4+
hour,
5+
day,
6+
week,
7+
month,
8+
year;
99
}

src/main/kotlin/com/ecwid/apiclient/v3/dto/report/request/ReportRequest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.ecwid.apiclient.v3.dto.report.enums.TimeScaleValue
88
import com.ecwid.apiclient.v3.impl.RequestInfo
99

1010
data class ReportRequest(
11-
val reportType: ReportType = ReportType.ALL_TRAFFIC,
11+
val reportType: ReportType = ReportType.allTraffic,
1212
val startedFrom: Long? = null,
1313
val endedAt: Long? = null,
1414
val timeScaleValue: TimeScaleValue? = null,
@@ -19,7 +19,7 @@ data class ReportRequest(
1919
override fun toRequestInfo() = RequestInfo.createGetRequest(
2020
pathSegments = listOf(
2121
"reports",
22-
reportType.alias,
22+
reportType.toString(),
2323
),
2424
params = toParams()
2525
)
@@ -28,9 +28,9 @@ data class ReportRequest(
2828
return mutableMapOf<String, String>().apply {
2929
startedFrom?.let { put("startedFrom", it.toString()) }
3030
endedAt?.let { put("endedAt", it.toString()) }
31-
timeScaleValue?.let { put("timeScaleValue", it.alias) }
32-
comparePeriod?.let { put("comparePeriod", it.alias) }
33-
firstDayOfWeek?.let { put("firstDayOfWeek", it.alias) }
31+
timeScaleValue?.let { put("timeScaleValue", it.toString()) }
32+
comparePeriod?.let { put("comparePeriod", it.toString()) }
33+
firstDayOfWeek?.let { put("firstDayOfWeek", it.toString()) }
3434
}.toMap()
3535
}
3636

src/main/kotlin/com/ecwid/apiclient/v3/dto/report/result/FetchedReportResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.ecwid.apiclient.v3.dto.report.enums.ReportType
66
import com.ecwid.apiclient.v3.dto.report.enums.TimeScaleValue
77

88
data class FetchedReportResponse(
9-
val reportType: ReportType = ReportType.ALL_TRAFFIC,
9+
val reportType: ReportType = ReportType.allTraffic,
1010
val startedFrom: Long = 0,
1111
val endedAt: Long = 0,
1212
val timeScaleValue: TimeScaleValue? = null,

0 commit comments

Comments
 (0)