diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt index b5bff611b..99bcb7731 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt @@ -43,6 +43,8 @@ import com.ecwid.apiclient.v3.dto.storage.result.* import com.ecwid.apiclient.v3.dto.subscriptions.request.SubscriptionsSearchRequest import com.ecwid.apiclient.v3.dto.subscriptions.result.FetchedSubscription import com.ecwid.apiclient.v3.dto.subscriptions.result.SubscriptionsSearchResult +import com.ecwid.apiclient.v3.dto.swatches.request.RecentSwatchColorsGetRequest +import com.ecwid.apiclient.v3.dto.swatches.result.FetchedSwatchColor import com.ecwid.apiclient.v3.dto.variation.request.* import com.ecwid.apiclient.v3.dto.variation.result.* import com.ecwid.apiclient.v3.httptransport.HttpTransport @@ -73,6 +75,7 @@ open class ApiClient private constructor( slugInfoApiClient: SlugInfoApiClientImpl, productReviewsApiClient: ProductReviewsApiClientImpl, storeExtrafieldsApiClient: StoreExtrafieldsApiClientImpl, + swatchesApiClient: SwatchesApiClientImpl, ) : StoreProfileApiClient by storeProfileApiClient, BrandsApiClient by brandsApiClient, @@ -94,7 +97,8 @@ open class ApiClient private constructor( InstantSiteRedirectsApiClient by instantSiteRedirectsApiClient, SlugInfoApiClient by slugInfoApiClient, ProductReviewsApiClient by productReviewsApiClient, - StoreExtrafieldsApiClient by storeExtrafieldsApiClient { + StoreExtrafieldsApiClient by storeExtrafieldsApiClient, + SwatchesApiClient by swatchesApiClient { constructor(apiClientHelper: ApiClientHelper) : this( apiClientHelper = apiClientHelper, @@ -119,6 +123,7 @@ open class ApiClient private constructor( slugInfoApiClient = SlugInfoApiClientImpl(apiClientHelper), productReviewsApiClient = ProductReviewsApiClientImpl(apiClientHelper), storeExtrafieldsApiClient = StoreExtrafieldsApiClientImpl(apiClientHelper), + swatchesApiClient = SwatchesApiClientImpl(apiClientHelper), ) companion object { @@ -316,3 +321,8 @@ interface ProductReviewsApiClient { fun massUpdateProductReview(request: ProductReviewMassUpdateRequest): ProductReviewMassUpdateResult fun getProductReviewsFiltersData(request: ProductReviewFiltersDataRequest): ProductReviewFiltersDataResult } + +// Swatches +interface SwatchesApiClient { + fun getRecentSwatchColors(request: RecentSwatchColorsGetRequest): Sequence +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/swatches/request/RecentSwatchColorsGetRequest.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/swatches/request/RecentSwatchColorsGetRequest.kt new file mode 100644 index 000000000..003cc5e61 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/swatches/request/RecentSwatchColorsGetRequest.kt @@ -0,0 +1,16 @@ +package com.ecwid.apiclient.v3.dto.swatches.request + +import com.ecwid.apiclient.v3.dto.ApiRequest +import com.ecwid.apiclient.v3.impl.RequestInfo + +class RecentSwatchColorsGetRequest : ApiRequest { + override fun toRequestInfo(): RequestInfo { + return RequestInfo.createGetRequest( + pathSegments = listOf( + "swatches", + "recent-colors", + ), + ) + } + +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/dto/swatches/result/FetchedSwatchColor.kt b/src/main/kotlin/com/ecwid/apiclient/v3/dto/swatches/result/FetchedSwatchColor.kt new file mode 100644 index 000000000..200a27de6 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/dto/swatches/result/FetchedSwatchColor.kt @@ -0,0 +1,11 @@ +package com.ecwid.apiclient.v3.dto.swatches.result + +import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO +import com.ecwid.apiclient.v3.dto.common.ApiResultDTO + +data class FetchedSwatchColor( + val name: String = "", + val hexCode: String = "", +): ApiFetchedDTO, ApiResultDTO { + override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadOnly +} diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/impl/SwatchesApiClientImpl.kt b/src/main/kotlin/com/ecwid/apiclient/v3/impl/SwatchesApiClientImpl.kt new file mode 100644 index 000000000..c4bfb1b13 --- /dev/null +++ b/src/main/kotlin/com/ecwid/apiclient/v3/impl/SwatchesApiClientImpl.kt @@ -0,0 +1,14 @@ +package com.ecwid.apiclient.v3.impl + +import com.ecwid.apiclient.v3.ApiClientHelper +import com.ecwid.apiclient.v3.SwatchesApiClient +import com.ecwid.apiclient.v3.dto.swatches.request.RecentSwatchColorsGetRequest +import com.ecwid.apiclient.v3.dto.swatches.result.FetchedSwatchColor + +class SwatchesApiClientImpl( + private val apiClientHelper: ApiClientHelper, +) : SwatchesApiClient { + + override fun getRecentSwatchColors(request: RecentSwatchColorsGetRequest) = + apiClientHelper.makeObjectResultRequest>(request) +}