Skip to content

Commit d0f069e

Browse files
committed
Add swatches support
1 parent 4e32c92 commit d0f069e

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import com.ecwid.apiclient.v3.dto.storage.result.*
4343
import com.ecwid.apiclient.v3.dto.subscriptions.request.SubscriptionsSearchRequest
4444
import com.ecwid.apiclient.v3.dto.subscriptions.result.FetchedSubscription
4545
import com.ecwid.apiclient.v3.dto.subscriptions.result.SubscriptionsSearchResult
46+
import com.ecwid.apiclient.v3.dto.swatches.request.RecentSwatchColorsGetRequest
47+
import com.ecwid.apiclient.v3.dto.swatches.result.FetchedSwatchColor
4648
import com.ecwid.apiclient.v3.dto.variation.request.*
4749
import com.ecwid.apiclient.v3.dto.variation.result.*
4850
import com.ecwid.apiclient.v3.httptransport.HttpTransport
@@ -73,6 +75,7 @@ open class ApiClient private constructor(
7375
slugInfoApiClient: SlugInfoApiClientImpl,
7476
productReviewsApiClient: ProductReviewsApiClientImpl,
7577
storeExtrafieldsApiClient: StoreExtrafieldsApiClientImpl,
78+
swatchesApiClient: SwatchesApiClientImpl,
7679
) :
7780
StoreProfileApiClient by storeProfileApiClient,
7881
BrandsApiClient by brandsApiClient,
@@ -94,7 +97,8 @@ open class ApiClient private constructor(
9497
InstantSiteRedirectsApiClient by instantSiteRedirectsApiClient,
9598
SlugInfoApiClient by slugInfoApiClient,
9699
ProductReviewsApiClient by productReviewsApiClient,
97-
StoreExtrafieldsApiClient by storeExtrafieldsApiClient {
100+
StoreExtrafieldsApiClient by storeExtrafieldsApiClient,
101+
SwatchesApiClient by swatchesApiClient {
98102

99103
constructor(apiClientHelper: ApiClientHelper) : this(
100104
apiClientHelper = apiClientHelper,
@@ -119,6 +123,7 @@ open class ApiClient private constructor(
119123
slugInfoApiClient = SlugInfoApiClientImpl(apiClientHelper),
120124
productReviewsApiClient = ProductReviewsApiClientImpl(apiClientHelper),
121125
storeExtrafieldsApiClient = StoreExtrafieldsApiClientImpl(apiClientHelper),
126+
swatchesApiClient = SwatchesApiClientImpl(apiClientHelper),
122127
)
123128

124129
companion object {
@@ -316,3 +321,8 @@ interface ProductReviewsApiClient {
316321
fun massUpdateProductReview(request: ProductReviewMassUpdateRequest): ProductReviewMassUpdateResult
317322
fun getProductReviewsFiltersData(request: ProductReviewFiltersDataRequest): ProductReviewFiltersDataResult
318323
}
324+
325+
// Swatches
326+
interface SwatchesApiClient {
327+
fun getRecentSwatchColors(request: RecentSwatchColorsGetRequest): Sequence<FetchedSwatchColor>
328+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.ecwid.apiclient.v3.dto.swatches.request
2+
3+
import com.ecwid.apiclient.v3.dto.ApiRequest
4+
import com.ecwid.apiclient.v3.impl.RequestInfo
5+
6+
class RecentSwatchColorsGetRequest : ApiRequest {
7+
override fun toRequestInfo(): RequestInfo {
8+
return RequestInfo.createGetRequest(
9+
pathSegments = listOf(
10+
"swatches",
11+
"recent-colors",
12+
),
13+
)
14+
}
15+
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.ecwid.apiclient.v3.dto.swatches.result
2+
3+
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
4+
import com.ecwid.apiclient.v3.dto.common.ApiResultDTO
5+
6+
data class FetchedSwatchColor(
7+
val name: String = "",
8+
val hexCode: String = "",
9+
) : ApiFetchedDTO, ApiResultDTO {
10+
override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadOnly
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.ecwid.apiclient.v3.impl
2+
3+
import com.ecwid.apiclient.v3.ApiClientHelper
4+
import com.ecwid.apiclient.v3.SwatchesApiClient
5+
import com.ecwid.apiclient.v3.dto.swatches.request.RecentSwatchColorsGetRequest
6+
import com.ecwid.apiclient.v3.dto.swatches.result.FetchedSwatchColor
7+
8+
class SwatchesApiClientImpl(
9+
private val apiClientHelper: ApiClientHelper,
10+
) : SwatchesApiClient {
11+
12+
override fun getRecentSwatchColors(request: RecentSwatchColorsGetRequest) =
13+
apiClientHelper.makeObjectResultRequest<Sequence<FetchedSwatchColor>>(request)
14+
}

0 commit comments

Comments
 (0)