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 48bd32e
Show file tree
Hide file tree
Showing 27 changed files with 292 additions and 37 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,16 @@
package com.ecwid.apiclient.v3

import com.ecwid.apiclient.v3.dto.extrafield.request.*
import com.ecwid.apiclient.v3.dto.extrafield.result.CustomersConfigCreateResult
import com.ecwid.apiclient.v3.dto.extrafield.result.CustomersConfigUpdateResult
import com.ecwid.apiclient.v3.dto.extrafield.result.CustomersConfigsSearchResult
import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig


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): CustomersConfigUpdateResult
}
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,6 +4,8 @@ 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.ExtrafieldType
import com.ecwid.apiclient.v3.dto.extrafield.enums.ExtrafieldEntityType
import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName
import java.util.*
import kotlin.collections.ArrayList
Expand Down Expand Up @@ -91,12 +93,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,20 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

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

data class CustomersConfigCreateRequest(
val newConfig: UpdatedExtrafieldConfig = UpdatedExtrafieldConfig()
) : 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,22 @@
package com.ecwid.apiclient.v3.dto.extrafield.request

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

data class CustomersConfigUpdateRequest(
val extrafieldKey: String = "",
val updatedConfig: UpdatedExtrafieldConfig = UpdatedExtrafieldConfig()
) : 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 @@ -4,37 +4,37 @@ 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.profile.enums.CheckoutDisplaySection
import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.extrafield.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 @@ -4,7 +4,7 @@ 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.profile.enums.CheckoutDisplaySection
import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType
import com.ecwid.apiclient.v3.dto.extrafield.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
Loading

0 comments on commit 48bd32e

Please sign in to comment.