Skip to content

Commit

Permalink
Add swatches support
Browse files Browse the repository at this point in the history
  • Loading branch information
aleskarova committed Dec 25, 2024
1 parent 4e32c92 commit d0f069e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,6 +75,7 @@ open class ApiClient private constructor(
slugInfoApiClient: SlugInfoApiClientImpl,
productReviewsApiClient: ProductReviewsApiClientImpl,
storeExtrafieldsApiClient: StoreExtrafieldsApiClientImpl,
swatchesApiClient: SwatchesApiClientImpl,
) :
StoreProfileApiClient by storeProfileApiClient,
BrandsApiClient by brandsApiClient,
Expand All @@ -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,
Expand All @@ -119,6 +123,7 @@ open class ApiClient private constructor(
slugInfoApiClient = SlugInfoApiClientImpl(apiClientHelper),
productReviewsApiClient = ProductReviewsApiClientImpl(apiClientHelper),
storeExtrafieldsApiClient = StoreExtrafieldsApiClientImpl(apiClientHelper),
swatchesApiClient = SwatchesApiClientImpl(apiClientHelper),
)

companion object {
Expand Down Expand Up @@ -316,3 +321,8 @@ interface ProductReviewsApiClient {
fun massUpdateProductReview(request: ProductReviewMassUpdateRequest): ProductReviewMassUpdateResult
fun getProductReviewsFiltersData(request: ProductReviewFiltersDataRequest): ProductReviewFiltersDataResult
}

// Swatches
interface SwatchesApiClient {
fun getRecentSwatchColors(request: RecentSwatchColorsGetRequest): Sequence<FetchedSwatchColor>
}
Original file line number Diff line number Diff line change
@@ -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",
),
)
}

}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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<Sequence<FetchedSwatchColor>>(request)
}

0 comments on commit d0f069e

Please sign in to comment.