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 swatches support #448

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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.FetchedSwatchColorsResult
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): FetchedSwatchColorsResult
}
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,7 @@
package com.ecwid.apiclient.v3.dto.swatches.result

import com.ecwid.apiclient.v3.dto.common.ApiResultDTO

data class FetchedSwatchColorsResult(
val colors: List<FetchedSwatchColor> = listOf(),
) : ApiResultDTO
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.FetchedSwatchColorsResult

class SwatchesApiClientImpl(
private val apiClientHelper: ApiClientHelper,
) : SwatchesApiClient {

override fun getRecentSwatchColors(request: RecentSwatchColorsGetRequest) =
apiClientHelper.makeObjectResultRequest<FetchedSwatchColorsResult>(request)
}
Loading