Skip to content

Commit a4fefde

Browse files
author
yolo
committed
Added extrafield config endpoints
1 parent a4844c8 commit a4fefde

8 files changed

Lines changed: 53 additions & 28 deletions

File tree

src/main/kotlin/com/ecwid/apiclient/v3/converter/FetchedExtrafieldConfig.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ecwid.apiclient.v3.converter
22

3+
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
34
import com.ecwid.apiclient.v3.dto.profile.request.UpdatedExtrafieldConfig
45
import com.ecwid.apiclient.v3.dto.profile.result.FetchedExtrafieldConfig
56

@@ -26,10 +27,10 @@ fun FetchedExtrafieldConfig.toUpdated(): UpdatedExtrafieldConfig {
2627
surchargeTaxable = surchargeTaxable,
2728
showZeroSurchargeInTotal = showZeroSurchargeInTotal,
2829
surchargeShortName = surchargeShortName?.toUpdated(),
29-
titleTranslated = titleTranslated,
30-
textPlaceholderTranslated = textPlaceholderTranslated,
31-
tipTranslated = tipTranslated,
32-
valueTranslated = valueTranslated
30+
titleTranslated = if (titleTranslated != null) LocalizedValueMap(titleTranslated) else null,
31+
textPlaceholderTranslated = if (textPlaceholderTranslated != null) LocalizedValueMap(textPlaceholderTranslated) else null,
32+
tipTranslated = if (tipTranslated != null) LocalizedValueMap(tipTranslated) else null,
33+
valueTranslated = if (valueTranslated != null) LocalizedValueMap(valueTranslated) else null
3334
)
3435
}
3536

@@ -38,15 +39,15 @@ fun FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig.toUpdated(): UpdatedEx
3839
title = title,
3940
subtitle = subtitle,
4041
surcharge = surcharge,
41-
titleTranslated = titleTranslated,
42-
subtitleTranslated = subtitleTranslated
42+
titleTranslated = if (titleTranslated != null) LocalizedValueMap(titleTranslated) else null,
43+
subtitleTranslated = if (subtitleTranslated != null) LocalizedValueMap(subtitleTranslated) else null
4344
)
4445
}
4546

4647
fun FetchedExtrafieldConfig.FetchedExtrafieldSurchargeConfig.toUpdated(): UpdatedExtrafieldConfig.UpdatedExtrafieldSurchargeConfig {
4748
return UpdatedExtrafieldConfig.UpdatedExtrafieldSurchargeConfig(
4849
name = name,
4950
showSurchargePercentValue = showSurchargePercentValue,
50-
nameTranslated = nameTranslated
51+
nameTranslated = if (nameTranslated != null) LocalizedValueMap(nameTranslated) else null
5152
)
5253
}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package com.ecwid.apiclient.v3.dto.profile.enums
22

33
enum class CheckoutDisplaySection {
4-
email, shipping_address, pickup_details, shipping_methods, pickup_methods, payment_details, billing_address, order_comments;
4+
EMAIL,
5+
SHIPPING_ADDRESS,
6+
PICKUP_DETAILS,
7+
SHIPPING_METHODS,
8+
PICKUP_METHODS,
9+
PAYMENT_DETAILS,
10+
BILLING_ADDRESS,
11+
ORDER_COMMENTS
512
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package com.ecwid.apiclient.v3.dto.profile.enums
22

33
enum class ExtrafieldType {
4-
text, select, datetime, toggle_button_group, textarea, checkbox, radio_buttons
4+
TEXT,
5+
SELECT,
6+
DATETIME,
7+
TOGGLE_BUTTON_GROUP,
8+
TEXTAREA,
9+
CHECKBOX,
10+
RADIO_BUTTONS
511
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package com.ecwid.apiclient.v3.dto.profile.enums
22

33
enum class OrderDetailsDisplaySection {
4-
shipping_info, billing_info, customer_info, order_comments, shipping_address, shipping_methods, pickup_details, pickup_methods, payment_details
4+
SHIPPING_INFO,
5+
BILLING_INFO,
6+
CUSTOMER_INFO,
7+
ORDER_COMMENTS,
8+
SHIPPING_ADDRESS,
9+
SHIPPING_METHODS,
10+
PICKUP_DETAILS,
11+
PICKUP_METHODS,
12+
PAYMENT_DETAILS
513
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ecwid.apiclient.v3.dto.profile.enums
22

33
enum class SurchargeType {
4-
percent, absolute
4+
PERCENT,
5+
ABSOLUTE
56
}

src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/request/UpdatedExtrafieldConfig.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.ecwid.apiclient.v3.dto.profile.request
22

33
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO
44
import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO.ModifyKind
5+
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
56
import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType
67
import com.ecwid.apiclient.v3.dto.profile.enums.SurchargeType
78
import com.ecwid.apiclient.v3.dto.profile.enums.OrderDetailsDisplaySection
@@ -30,24 +31,24 @@ data class UpdatedExtrafieldConfig(
3031
val surchargeTaxable: Boolean? = null,
3132
val showZeroSurchargeInTotal: Boolean? = null,
3233
val surchargeShortName: UpdatedExtrafieldSurchargeConfig? = null,
33-
val titleTranslated: Map<String, String>? = null,
34-
val textPlaceholderTranslated: Map<String, String>? = null,
35-
val tipTranslated: Map<String, String>? = null,
36-
val valueTranslated: Map<String, String>? = null
34+
val titleTranslated: LocalizedValueMap? = null,
35+
val textPlaceholderTranslated: LocalizedValueMap? = null,
36+
val tipTranslated: LocalizedValueMap? = null,
37+
val valueTranslated: LocalizedValueMap? = null
3738
) : ApiUpdatedDTO {
3839

3940
data class UpdatedExtrafieldOptionConfig(
4041
val title: String? = null,
4142
val subtitle: String? = null,
4243
val surcharge: Int? = null,
43-
val titleTranslated: Map<String, String>? = null,
44-
val subtitleTranslated: Map<String, String>? = null
44+
val titleTranslated: LocalizedValueMap? = null,
45+
val subtitleTranslated: LocalizedValueMap? = null
4546
)
4647

4748
data class UpdatedExtrafieldSurchargeConfig(
4849
val name: String? = null,
4950
val showSurchargePercentValue: Boolean? = null,
50-
val nameTranslated: Map<String, String>? = null
51+
val nameTranslated: LocalizedValueMap? = null
5152
)
5253

5354
override fun getModifyKind() = ModifyKind.ReadWrite(FetchedExtrafieldConfig::class)

src/main/kotlin/com/ecwid/apiclient/v3/dto/profile/result/FetchedExtrafieldConfig.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.ecwid.apiclient.v3.dto.profile.result
22

33
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO
44
import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO.ModifyKind
5+
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
56
import com.ecwid.apiclient.v3.dto.profile.enums.ExtrafieldType
67
import com.ecwid.apiclient.v3.dto.profile.enums.SurchargeType
78
import com.ecwid.apiclient.v3.dto.profile.enums.OrderDetailsDisplaySection
@@ -18,7 +19,7 @@ data class FetchedExtrafieldConfig(
1819
val value: String? = null,
1920
val available: Boolean? = null,
2021
val required: Boolean? = null,
21-
val checkoutDisplaySection: CheckoutDisplaySection = CheckoutDisplaySection.email,
22+
val checkoutDisplaySection: CheckoutDisplaySection = CheckoutDisplaySection.EMAIL,
2223
val orderDetailsDisplaySection: OrderDetailsDisplaySection? = null,
2324
val showForCountry: List<String>? = null,
2425
val showForPaymentMethodIds: List<String>? = null,
@@ -30,24 +31,24 @@ data class FetchedExtrafieldConfig(
3031
val surchargeTaxable: Boolean? = null,
3132
val showZeroSurchargeInTotal: Boolean? = null,
3233
val surchargeShortName: FetchedExtrafieldSurchargeConfig? = null,
33-
val titleTranslated: Map<String, String>? = null,
34-
val textPlaceholderTranslated: Map<String, String>? = null,
35-
val tipTranslated: Map<String, String>? = null,
36-
val valueTranslated: Map<String, String>? = null
34+
val titleTranslated: LocalizedValueMap? = null,
35+
val textPlaceholderTranslated: LocalizedValueMap? = null,
36+
val tipTranslated: LocalizedValueMap? = null,
37+
val valueTranslated: LocalizedValueMap? = null
3738
) : ApiFetchedDTO {
3839

3940
data class FetchedExtrafieldOptionConfig(
4041
val title: String? = null,
4142
val subtitle: String? = null,
4243
val surcharge: Int? = null,
43-
val titleTranslated: Map<String, String>? = null,
44-
val subtitleTranslated: Map<String, String>? = null
44+
val titleTranslated: LocalizedValueMap? = null,
45+
val subtitleTranslated: LocalizedValueMap? = null
4546
)
4647

4748
data class FetchedExtrafieldSurchargeConfig(
4849
val name: String? = null,
4950
val showSurchargePercentValue: Boolean? = null,
50-
val nameTranslated: Map<String, String>? = null
51+
val nameTranslated: LocalizedValueMap? = null
5152
)
5253

5354
override fun getModifyKind() = ModifyKind.ReadWrite(UpdatedExtrafieldConfig::class)

src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ val nullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
7373
fetchedCategoryNullablePropertyRules,
7474
fetchedCouponNullablePropertyRules,
7575
fetchedCustomerNullablePropertyRules,
76+
fetchedExtrafieldConfigNullablePropertyRules,
7677
fetchedOrderNullablePropertyRules,
7778
fetchedProductNullablePropertyRules,
7879
fetchedProductTypeNullablePropertyRules,
@@ -83,8 +84,7 @@ val nullablePropertyRules: List<NullablePropertyRule<*, *>> = listOf(
8384
ordersSearchRequestRequestNullablePropertyRules,
8485
productDetailsRequestNullablePropertyRules,
8586
productsSearchRequestNullablePropertyRules,
86-
otherNullablePropertyRules,
87-
fetchedExtrafieldConfigNullablePropertyRules
87+
otherNullablePropertyRules
8888
).flatten()
8989

9090
sealed class NullablePropertyRule<T, R>(

0 commit comments

Comments
 (0)