Skip to content

Commit 75bd26e

Browse files
authored
Merge pull request #181 from Ecwid/extrafield-config
Added extrafield config endpoints
2 parents ad0c674 + a4fefde commit 75bd26e

19 files changed

Lines changed: 374 additions & 0 deletions

src/main/kotlin/com/ecwid/apiclient/v3/ApiClient.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ interface StoreProfileApiClient {
123123
fun removeInvoiceLogo(request: InvoiceLogoRemoveRequest): InvoiceLogoRemoveResult
124124
fun uploadEmailLogo(request: EmailLogoUploadRequest): EmailLogoUploadResult
125125
fun removeEmailLogo(request: EmailLogoRemoveRequest): EmailLogoRemoveResult
126+
fun searchExtrafieldConfigs(request: ExtrafieldConfigSearchRequest): ExtrafieldConfigSearchResult
127+
fun getExtrafieldConfigDetails(request: ExtrafieldConfigDetailsRequest): FetchedExtrafieldConfig
128+
fun createExtrafieldConfig(request: ExtrafieldConfigCreateRequest): FetchedExtrafieldConfig
129+
fun updateExtrafieldConfig(request: ExtrafieldConfigUpdateRequest): ExtrafieldConfigUpdateResult
130+
fun deleteExtrafieldConfig(request: ExtrafieldConfigDeleteRequest): ExtrafieldConfigDeleteResult
126131
}
127132

128133
// Products
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.ecwid.apiclient.v3.converter
2+
3+
import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap
4+
import com.ecwid.apiclient.v3.dto.profile.request.UpdatedExtrafieldConfig
5+
import com.ecwid.apiclient.v3.dto.profile.result.FetchedExtrafieldConfig
6+
7+
fun FetchedExtrafieldConfig.toUpdated(): UpdatedExtrafieldConfig {
8+
return UpdatedExtrafieldConfig(
9+
key = key,
10+
title = title,
11+
type = type,
12+
textPlaceholder = textPlaceholder,
13+
tip = tip,
14+
options = options?.map(FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig::toUpdated),
15+
value = value,
16+
available = available,
17+
required = required,
18+
checkoutDisplaySection = checkoutDisplaySection,
19+
orderDetailsDisplaySection = orderDetailsDisplaySection,
20+
showForCountry = showForCountry,
21+
showForPaymentMethodIds = showForPaymentMethodIds,
22+
showForShippingMethodIds = showForShippingMethodIds,
23+
showInInvoice = showInInvoice,
24+
showInNotifications = showInNotifications,
25+
orderBy = orderBy,
26+
surchargeType = surchargeType,
27+
surchargeTaxable = surchargeTaxable,
28+
showZeroSurchargeInTotal = showZeroSurchargeInTotal,
29+
surchargeShortName = surchargeShortName?.toUpdated(),
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
34+
)
35+
}
36+
37+
fun FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig.toUpdated(): UpdatedExtrafieldConfig.UpdatedExtrafieldOptionConfig {
38+
return UpdatedExtrafieldConfig.UpdatedExtrafieldOptionConfig(
39+
title = title,
40+
subtitle = subtitle,
41+
surcharge = surcharge,
42+
titleTranslated = if (titleTranslated != null) LocalizedValueMap(titleTranslated) else null,
43+
subtitleTranslated = if (subtitleTranslated != null) LocalizedValueMap(subtitleTranslated) else null
44+
)
45+
}
46+
47+
fun FetchedExtrafieldConfig.FetchedExtrafieldSurchargeConfig.toUpdated(): UpdatedExtrafieldConfig.UpdatedExtrafieldSurchargeConfig {
48+
return UpdatedExtrafieldConfig.UpdatedExtrafieldSurchargeConfig(
49+
name = name,
50+
showSurchargePercentValue = showSurchargePercentValue,
51+
nameTranslated = if (nameTranslated != null) LocalizedValueMap(nameTranslated) else null
52+
)
53+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.ecwid.apiclient.v3.dto.profile.enums
2+
3+
enum class CheckoutDisplaySection {
4+
EMAIL,
5+
SHIPPING_ADDRESS,
6+
PICKUP_DETAILS,
7+
SHIPPING_METHODS,
8+
PICKUP_METHODS,
9+
PAYMENT_DETAILS,
10+
BILLING_ADDRESS,
11+
ORDER_COMMENTS
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.ecwid.apiclient.v3.dto.profile.enums
2+
3+
enum class ExtrafieldType {
4+
TEXT,
5+
SELECT,
6+
DATETIME,
7+
TOGGLE_BUTTON_GROUP,
8+
TEXTAREA,
9+
CHECKBOX,
10+
RADIO_BUTTONS
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.ecwid.apiclient.v3.dto.profile.enums
2+
3+
enum class OrderDetailsDisplaySection {
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
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.ecwid.apiclient.v3.dto.profile.enums
2+
3+
enum class SurchargeType {
4+
PERCENT,
5+
ABSOLUTE
6+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.ecwid.apiclient.v3.dto.profile.request
2+
3+
import com.ecwid.apiclient.v3.dto.ApiRequest
4+
import com.ecwid.apiclient.v3.httptransport.HttpBody
5+
import com.ecwid.apiclient.v3.impl.RequestInfo
6+
7+
data class ExtrafieldConfigCreateRequest(
8+
val newConfig: UpdatedExtrafieldConfig = UpdatedExtrafieldConfig()
9+
) : ApiRequest {
10+
override fun toRequestInfo() = RequestInfo.createPostRequest(
11+
pathSegments = listOf(
12+
"profile",
13+
"extrafields"
14+
),
15+
httpBody = HttpBody.JsonBody(
16+
obj = newConfig
17+
)
18+
)
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.ecwid.apiclient.v3.dto.profile.request
2+
3+
import com.ecwid.apiclient.v3.dto.ApiRequest
4+
import com.ecwid.apiclient.v3.impl.RequestInfo
5+
6+
data class ExtrafieldConfigDeleteRequest(
7+
val extrafieldKey: String = ""
8+
) : ApiRequest {
9+
override fun toRequestInfo() = RequestInfo.createDeleteRequest(
10+
pathSegments = listOf(
11+
"profile",
12+
"extrafields",
13+
extrafieldKey
14+
),
15+
params = mapOf()
16+
)
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.ecwid.apiclient.v3.dto.profile.request
2+
3+
import com.ecwid.apiclient.v3.dto.ApiRequest
4+
import com.ecwid.apiclient.v3.impl.RequestInfo
5+
6+
data class ExtrafieldConfigDetailsRequest(
7+
val extrafieldKey: String = ""
8+
) : ApiRequest {
9+
override fun toRequestInfo() = RequestInfo.createGetRequest(
10+
pathSegments = listOf(
11+
"profile",
12+
"extrafields",
13+
extrafieldKey
14+
),
15+
params = mapOf()
16+
)
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.ecwid.apiclient.v3.dto.profile.request
2+
3+
import com.ecwid.apiclient.v3.dto.ApiRequest
4+
import com.ecwid.apiclient.v3.impl.RequestInfo
5+
6+
class ExtrafieldConfigSearchRequest : ApiRequest {
7+
override fun toRequestInfo() = RequestInfo.createGetRequest(
8+
pathSegments = listOf(
9+
"profile",
10+
"extrafields"
11+
),
12+
params = mapOf()
13+
)
14+
}

0 commit comments

Comments
 (0)