Skip to content

Commit

Permalink
ECWID-144507 new endpoint for store extrafields customers config
Browse files Browse the repository at this point in the history
  • Loading branch information
winrokru committed Jul 25, 2024
1 parent 48207bf commit 5cfedf9
Show file tree
Hide file tree
Showing 27 changed files with 284 additions and 38 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added src/.DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ open class ApiClient private constructor(
instantSiteRedirectsApiClient: InstantSiteRedirectsApiClientImpl,
slugInfoApiClient: SlugInfoApiClientImpl,
productReviewsApiClient: ProductReviewsApiClientImpl,
storeExtrafieldsApiClient: StoreExtrafieldsApiClientImpl,
) :
StoreProfileApiClient by storeProfileApiClient,
ProductsApiClient by productsApiClient,
Expand All @@ -92,7 +93,8 @@ open class ApiClient private constructor(
SubscriptionsApiClient by subscriptionsApiClient,
InstantSiteRedirectsApiClient by instantSiteRedirectsApiClient,
SlugInfoApiClient by slugInfoApiClient,
ProductReviewsApiClient by productReviewsApiClient {
ProductReviewsApiClient by productReviewsApiClient,
StoreExtrafieldsApiClient by storeExtrafieldsApiClient {

constructor(apiClientHelper: ApiClientHelper) : this(
apiClientHelper = apiClientHelper,
Expand All @@ -115,6 +117,7 @@ open class ApiClient private constructor(
instantSiteRedirectsApiClient = InstantSiteRedirectsApiClientImpl(apiClientHelper),
slugInfoApiClient = SlugInfoApiClientImpl(apiClientHelper),
productReviewsApiClient = ProductReviewsApiClientImpl(apiClientHelper),
storeExtrafieldsApiClient = StoreExtrafieldsApiClientImpl(apiClientHelper),
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ecwid.apiclient.v3

import com.ecwid.apiclient.v3.dto.extrafield.request.*
import com.ecwid.apiclient.v3.dto.extrafield.result.*


interface StoreExtrafieldsApiClient {
fun searchCustomersConfigs(request: CustomersConfigsSearchRequest): CustomersConfigsSearchResult
fun getCustomersConfig(request: CustomersConfigDetailsRequest): FetchedCustomersConfig
fun createCustomersConfig(request: CustomersConfigCreateRequest): CustomersConfigCreateResult
fun updateCustomersConfig(request: CustomersConfigUpdateRequest): CustomersConfigUpdateResult
fun deleteCustomersConfig(request: CustomersConfigDeleteRequest): CustomersConfigDeleteResult
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.ecwid.apiclient.v3.converter

import com.ecwid.apiclient.v3.dto.extrafield.request.UpdatedCustomersConfig
import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig


fun FetchedCustomersConfig.toUpdated(): UpdatedCustomersConfig {
return UpdatedCustomersConfig(
key = key,
title = title,
type = type,
shownOnOrderDetails = shownOnOrderDetails,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme
import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName

data class UpdatedCustomer(
Expand Down Expand Up @@ -65,7 +66,7 @@ data class UpdatedCustomer(
val key: String? = null,
val title: String? = null,
val value: String? = null,
val type: String? = null,
val type: ExtrafieldType? = null,
)

override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCustomer::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme
import com.ecwid.apiclient.v3.dto.customer.request.UpdatedCustomer
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldEntityType
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName
import java.util.*
import kotlin.collections.ArrayList

data class FetchedCustomer(
val id: Int = 0,
Expand Down Expand Up @@ -91,12 +92,12 @@ data class FetchedCustomer(
)

data class CustomerExtrafield(
val key: String? = null,
val title: String? = null,
val value: String? = null,
val orderBy: Int = 0,
val type: String? = null,
val entityTypes: List<String> = emptyList(),
val key: String? = null,
val title: String? = null,
val value: String? = null,
val orderBy: Int = 0,
val type: ExtrafieldType? = null,
val entityTypes: List<ExtrafieldEntityType> = emptyList(),
)

override fun getModifyKind() = ModifyKind.ReadWrite(UpdatedCustomer::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.ecwid.apiclient.v3.dto.extrafield.enums

enum class ExtrafieldEntityType {
CHECKOUT,
CUSTOMERS,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecwid.apiclient.v3.dto.profile.enums
package com.ecwid.apiclient.v3.dto.extrafield.enums

enum class ExtrafieldType {
TEXT,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.httptransport.HttpBody
import com.ecwid.apiclient.v3.impl.RequestInfo

data class CustomersConfigCreateRequest(
val newConfig: UpdatedCustomersConfig = UpdatedCustomersConfig()
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createPostRequest(
pathSegments = listOf(
"store_extrafields",
"customers"
),
httpBody = HttpBody.JsonBody(
obj = newConfig
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.impl.RequestInfo

data class CustomersConfigDeleteRequest(
val extrafieldKey: String = ""
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createDeleteRequest(
pathSegments = listOf(
"store_extrafields",
"customers",
extrafieldKey
),
params = mapOf()
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.impl.RequestInfo
import com.ecwid.apiclient.v3.responsefields.ResponseFields

data class CustomersConfigDetailsRequest(
val extrafieldKey: String = "",
val responseFields: ResponseFields = ResponseFields.All,
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createGetRequest(
pathSegments = listOf(
"store_extrafields",
"customers",
extrafieldKey
),
params = mapOf(),
responseFields = responseFields,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.httptransport.HttpBody
import com.ecwid.apiclient.v3.impl.RequestInfo

data class CustomersConfigUpdateRequest(
val extrafieldKey: String = "",
val updatedConfig: UpdatedCustomersConfig = UpdatedCustomersConfig()
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createPutRequest(
pathSegments = listOf(
"store_extrafields",
"customers",
extrafieldKey
),
httpBody = HttpBody.JsonBody(
obj = updatedConfig
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

import com.ecwid.apiclient.v3.dto.ApiRequest
import com.ecwid.apiclient.v3.impl.RequestInfo
import com.ecwid.apiclient.v3.responsefields.ResponseFields


data class CustomersConfigsSearchRequest(
val responseFields: ResponseFields = ResponseFields.All,
) : ApiRequest {
override fun toRequestInfo() = RequestInfo.createGetRequest(
pathSegments = listOf(
"store_extrafields",
"customers"
),
params = mapOf(),
responseFields = responseFields,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig

data class UpdatedCustomersConfig(
val key: String? = null,
val title: String? = null,
val type: ExtrafieldType? = null,
val shownOnOrderDetails: Boolean? = null,
) : ApiUpdatedDTO {

override fun getModifyKind() = ModifyKind.ReadWrite(FetchedCustomersConfig::class)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.ecwid.apiclient.v3.dto.extrafield.result

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

data class CustomersConfigCreateResult(
val createCount: Int = 0,
val key: String = ""
) : ApiResultDTO
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ecwid.apiclient.v3.dto.extrafield.result

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

data class CustomersConfigDeleteResult(
val deleteCount: Int = 0
) : ApiResultDTO
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ecwid.apiclient.v3.dto.extrafield.result

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

data class CustomersConfigUpdateResult(
val updateCount: Int = 0
) : ApiResultDTO
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ecwid.apiclient.v3.dto.extrafield.result

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

data class CustomersConfigsSearchResult(
val items: List<FetchedCustomersConfig> = listOf(),
) : ApiResultDTO
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ecwid.apiclient.v3.dto.extrafield.result

import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldEntityType
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.extrafield.request.UpdatedCustomersConfig
import java.util.*

data class FetchedCustomersConfig(
val key: String? = null,
val title: String? = null,
val entityTypes: ExtrafieldEntityType? = null,
val type: ExtrafieldType? = null,
val shownOnOrderDetails: Boolean? = null,
val createdDate: Date? = null,
val lastModifiedDate: Date? = null,
) : ApiFetchedDTO {

override fun getModifyKind() = ApiFetchedDTO.ModifyKind.ReadWrite(UpdatedCustomersConfig::class)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ExtrafieldConfigUpdateRequest(
pathSegments = listOf(
"profile",
"extrafields",
"$extrafieldKey"
extrafieldKey
),
httpBody = HttpBody.JsonBody(
obj = updatedConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ package com.ecwid.apiclient.v3.dto.profile.request
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.profile.enums.CheckoutDisplaySection
import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.profile.enums.OrderDetailsDisplaySection
import com.ecwid.apiclient.v3.dto.profile.enums.SurchargeType
import com.ecwid.apiclient.v3.dto.profile.result.FetchedExtrafieldConfig

data class UpdatedExtrafieldConfig(
val key: String? = null,
val title: String? = null,
val type: ExtrafieldType? = null,
val textPlaceholder: String? = null,
val tip: String? = null,
val options: List<UpdatedExtrafieldOptionConfig>? = null,
val value: String? = null,
val available: Boolean? = null,
val required: Boolean? = null,
val checkoutDisplaySection: CheckoutDisplaySection? = null,
val orderDetailsDisplaySection: OrderDetailsDisplaySection? = null,
val showForCountry: List<String>? = null,
val showForPaymentMethodIds: List<String>? = null,
val showForShippingMethodIds: List<String>? = null,
val showInInvoice: Boolean? = null,
val showInNotifications: Boolean? = null,
val orderBy: Int? = null,
val surchargeType: SurchargeType? = null,
val surchargeTaxable: Boolean? = null,
val showZeroSurchargeInTotal: Boolean? = null,
val surchargeShortName: UpdatedExtrafieldSurchargeConfig? = null,
val titleTranslated: LocalizedValueMap? = null,
val textPlaceholderTranslated: LocalizedValueMap? = null,
val tipTranslated: LocalizedValueMap? = null,
val valueTranslated: LocalizedValueMap? = null
val key: String? = null,
val title: String? = null,
val type: ExtrafieldType? = null,
val textPlaceholder: String? = null,
val tip: String? = null,
val options: List<UpdatedExtrafieldOptionConfig>? = null,
val value: String? = null,
val available: Boolean? = null,
val required: Boolean? = null,
val checkoutDisplaySection: CheckoutDisplaySection? = null,
val orderDetailsDisplaySection: OrderDetailsDisplaySection? = null,
val showForCountry: List<String>? = null,
val showForPaymentMethodIds: List<String>? = null,
val showForShippingMethodIds: List<String>? = null,
val showInInvoice: Boolean? = null,
val showInNotifications: Boolean? = null,
val orderBy: Int? = null,
val surchargeType: SurchargeType? = null,
val surchargeTaxable: Boolean? = null,
val showZeroSurchargeInTotal: Boolean? = null,
val surchargeShortName: UpdatedExtrafieldSurchargeConfig? = null,
val titleTranslated: LocalizedValueMap? = null,
val textPlaceholderTranslated: LocalizedValueMap? = null,
val tipTranslated: LocalizedValueMap? = null,
val valueTranslated: LocalizedValueMap? = null
) : ApiUpdatedDTO {

data class UpdatedExtrafieldOptionConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.ecwid.apiclient.v3.dto.profile.result
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.profile.enums.CheckoutDisplaySection
import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.profile.enums.OrderDetailsDisplaySection
import com.ecwid.apiclient.v3.dto.profile.enums.SurchargeType
import com.ecwid.apiclient.v3.dto.profile.request.UpdatedExtrafieldConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.ecwid.apiclient.v3.impl

import com.ecwid.apiclient.v3.ApiClientHelper
import com.ecwid.apiclient.v3.StoreExtrafieldsApiClient
import com.ecwid.apiclient.v3.dto.extrafield.request.*
import com.ecwid.apiclient.v3.dto.extrafield.result.*

internal class StoreExtrafieldsApiClientImpl(
private val apiClientHelper: ApiClientHelper
) : StoreExtrafieldsApiClient {

override fun searchCustomersConfigs(request: CustomersConfigsSearchRequest): CustomersConfigsSearchResult =
apiClientHelper.makeObjectResultRequest(request)

override fun getCustomersConfig(request: CustomersConfigDetailsRequest): FetchedCustomersConfig =
apiClientHelper.makeObjectResultRequest(request)

override fun createCustomersConfig(request: CustomersConfigCreateRequest): CustomersConfigCreateResult =
apiClientHelper.makeObjectResultRequest(request)

override fun updateCustomersConfig(request: CustomersConfigUpdateRequest): CustomersConfigUpdateResult =
apiClientHelper.makeObjectResultRequest(request)

override fun deleteCustomersConfig(request: CustomersConfigDeleteRequest): CustomersConfigDeleteResult =
apiClientHelper.makeObjectResultRequest(request)
}
Loading

0 comments on commit 5cfedf9

Please sign in to comment.