Skip to content

Commit 38a5be3

Browse files
author
mvgreen
committed
Move extensions into companion objects to make them available for import
1 parent 4f7c19a commit 38a5be3

5 files changed

Lines changed: 52 additions & 42 deletions

File tree

src/main/kotlin/com/ecwid/apiclient/v3/dto/custom/CustomAppRequest.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,18 @@ data class CustomAppRequest(
284284
override val show: AttributeValueLocation? = null
285285
) : FetchedAttributeValue {
286286

287-
fun FetchedAttributeValue.toOrderAttribute() = AttributeValue(
288-
id = id,
289-
name = name,
290-
type = type,
291-
value = value,
292-
show = show
293-
)
287+
companion object {
288+
289+
fun FetchedAttributeValue.toOrderAttribute() = AttributeValue(
290+
id = id,
291+
name = name,
292+
type = type,
293+
value = value,
294+
show = show
295+
)
294296

295-
fun Collection<FetchedAttributeValue>.toOrderAttributeList() = this.map { it.toOrderAttribute() }
297+
fun Collection<FetchedAttributeValue>.toOrderAttributeList() = this.map { it.toOrderAttribute() }
298+
}
296299

297300
}
298301

src/main/kotlin/com/ecwid/apiclient/v3/dto/product/request/UpdatedProduct.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,16 @@ data class UpdatedProduct(
279279
override val value: String? = null
280280
) : UpdatedAttributeValue {
281281

282-
fun UpdatedAttributeValue.toProductAttribute() = AttributeValue(
283-
id = id,
284-
alias = alias,
285-
name = name,
286-
value = value,
287-
)
282+
companion object {
288283

289-
fun Collection<UpdatedAttributeValue>.toProductAttributeList() = this.map { it.toProductAttribute() }
284+
fun UpdatedAttributeValue.toProductAttribute() = AttributeValue(
285+
id = id,
286+
alias = alias,
287+
name = name,
288+
value = value,
289+
)
290290

291-
companion object {
291+
fun Collection<UpdatedAttributeValue>.toProductAttributeList() = this.map { it.toProductAttribute() }
292292

293293
fun createBrandAttributeValue(value: String) = AttributeValue(
294294
id = null,

src/main/kotlin/com/ecwid/apiclient/v3/dto/product/result/FetchedProduct.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,18 @@ data class FetchedProduct(
242242
override val show: AttributeValueLocation? = null
243243
) : FetchedAttributeValue {
244244

245-
fun FetchedAttributeValue.toProductAttribute() = AttributeValue(
246-
id = id,
247-
name = name,
248-
type = type,
249-
value = value,
250-
show = show
251-
)
245+
companion object {
252246

253-
fun Collection<FetchedAttributeValue>.toProductAttributeList() = this.map { it.toProductAttribute() }
247+
fun FetchedAttributeValue.toProductAttribute() = AttributeValue(
248+
id = id,
249+
name = name,
250+
type = type,
251+
value = value,
252+
show = show
253+
)
254254

255+
fun Collection<FetchedAttributeValue>.toProductAttributeList() = this.map { it.toProductAttribute() }
256+
}
255257
}
256258

257259
data class RelatedProducts(

src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/request/UpdatedVariation.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ data class UpdatedVariation(
4141
override val value: String? = null
4242
) : UpdatedAttributeValue {
4343

44-
fun UpdatedAttributeValue.toVariationAttribute() = AttributeValue(
45-
id = id,
46-
alias = alias,
47-
name = name,
48-
value = value,
49-
)
50-
51-
fun Collection<UpdatedAttributeValue>.toVariationAttributeList() = this.map { it.toVariationAttribute() }
44+
companion object {
45+
46+
fun UpdatedAttributeValue.toVariationAttribute() = AttributeValue(
47+
id = id,
48+
alias = alias,
49+
name = name,
50+
value = value,
51+
)
52+
53+
fun Collection<UpdatedAttributeValue>.toVariationAttributeList() = this.map { it.toVariationAttribute() }
54+
}
5255

5356
}
5457

src/main/kotlin/com/ecwid/apiclient/v3/dto/variation/result/FetchedVariation.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,18 @@ data class FetchedVariation(
5757
override val show: AttributeValueLocation? = null
5858
) : FetchedAttributeValue {
5959

60-
fun FetchedAttributeValue.toVariationAttribute() = AttributeValue(
61-
id = id,
62-
name = name,
63-
type = type,
64-
value = value,
65-
show = show
66-
)
67-
68-
fun Collection<FetchedAttributeValue>.toVariationAttributeList() = this.map { it.toVariationAttribute() }
69-
60+
companion object {
61+
62+
fun FetchedAttributeValue.toVariationAttribute() = AttributeValue(
63+
id = id,
64+
name = name,
65+
type = type,
66+
value = value,
67+
show = show
68+
)
69+
70+
fun Collection<FetchedAttributeValue>.toVariationAttributeList() = this.map { it.toVariationAttribute() }
71+
}
7072
}
7173

7274
data class WholesalePrice(

0 commit comments

Comments
 (0)