File tree Expand file tree Collapse file tree
src/main/kotlin/com/ecwid/apiclient/v3/dto Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,10 +3,14 @@ package com.ecwid.apiclient.v3.dto.common
33import com.ecwid.apiclient.v3.dto.product.enums.AttributeValueLocation
44import com.ecwid.apiclient.v3.dto.producttype.enums.AttributeType
55
6- interface FetchedAttributeValue {
6+ interface FetchedAttributeValue < T : FetchedAttributeValue < T >> {
77 val id: Int?
88 val name: String?
99 val type: AttributeType ?
1010 val value: String?
1111 val show: AttributeValueLocation ?
12+
13+ fun toInheritor (): T
14+
15+ fun Collection<T>.toInheritorList (): List <T > = this .map { it.toInheritor() }
1216}
Original file line number Diff line number Diff line change @@ -2,9 +2,13 @@ package com.ecwid.apiclient.v3.dto.common
22
33import com.ecwid.apiclient.v3.dto.product.enums.AttributeValueAlias
44
5- interface UpdatedAttributeValue {
5+ interface UpdatedAttributeValue < T : UpdatedAttributeValue < T >> {
66 val id: Int?
77 val alias: AttributeValueAlias ?
88 val name: String?
99 val value: String?
10+
11+ fun toInheritor (): T
12+
13+ fun Collection<T>.toInheritorList (): List <T > = this .map { it.toInheritor() }
1014}
Original file line number Diff line number Diff line change @@ -282,21 +282,15 @@ data class CustomAppRequest(
282282 override val type : AttributeType ? = null ,
283283 override val value : String? = null ,
284284 override val show : AttributeValueLocation ? = null
285- ) : FetchedAttributeValue {
286-
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- )
296-
297- fun Collection<FetchedAttributeValue>.toOrderAttributeList () = this .map { it.toOrderAttribute() }
298- }
299-
285+ ) : FetchedAttributeValue<AttributeValue> {
286+
287+ override fun toInheritor () = AttributeValue (
288+ id = id,
289+ name = name,
290+ type = type,
291+ value = value,
292+ show = show
293+ )
300294 }
301295
302296 data class ProductDimensions (
Original file line number Diff line number Diff line change @@ -277,18 +277,16 @@ data class UpdatedProduct(
277277 override val alias : AttributeValueAlias ? = null ,
278278 override val name : String? = null ,
279279 override val value : String? = null
280- ) : UpdatedAttributeValue {
280+ ) : UpdatedAttributeValue<AttributeValue> {
281281
282- companion object {
282+ override fun toInheritor () = AttributeValue (
283+ id = id,
284+ alias = alias,
285+ name = name,
286+ value = value,
287+ )
283288
284- fun UpdatedAttributeValue.toProductAttribute () = AttributeValue (
285- id = id,
286- alias = alias,
287- name = name,
288- value = value,
289- )
290-
291- fun Collection<UpdatedAttributeValue>.toProductAttributeList () = this .map { it.toProductAttribute() }
289+ companion object {
292290
293291 fun createBrandAttributeValue (value : String ) = AttributeValue (
294292 id = null ,
Original file line number Diff line number Diff line change @@ -240,20 +240,15 @@ data class FetchedProduct(
240240 override val type : AttributeType ? = null ,
241241 override val value : String? = null ,
242242 override val show : AttributeValueLocation ? = null
243- ) : FetchedAttributeValue {
244-
245- companion object {
246-
247- fun FetchedAttributeValue.toProductAttribute () = AttributeValue (
248- id = id,
249- name = name,
250- type = type,
251- value = value,
252- show = show
253- )
254-
255- fun Collection<FetchedAttributeValue>.toProductAttributeList () = this .map { it.toProductAttribute() }
256- }
243+ ) : FetchedAttributeValue<AttributeValue> {
244+
245+ override fun toInheritor () = AttributeValue (
246+ id = id,
247+ name = name,
248+ type = type,
249+ value = value,
250+ show = show
251+ )
257252 }
258253
259254 data class RelatedProducts (
Original file line number Diff line number Diff line change @@ -39,20 +39,14 @@ data class UpdatedVariation(
3939 override val alias : AttributeValueAlias ? = null ,
4040 override val name : String? = null ,
4141 override val value : String? = null
42- ) : UpdatedAttributeValue {
43-
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- }
55-
42+ ) : UpdatedAttributeValue<AttributeValue> {
43+
44+ override fun toInheritor () = AttributeValue (
45+ id = id,
46+ alias = alias,
47+ name = name,
48+ value = value,
49+ )
5650 }
5751
5852 data class WholesalePrice (
Original file line number Diff line number Diff line change @@ -55,20 +55,15 @@ data class FetchedVariation(
5555 override val type : AttributeType ? = null ,
5656 override val value : String? = null ,
5757 override val show : AttributeValueLocation ? = null
58- ) : FetchedAttributeValue {
59-
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- }
58+ ) : FetchedAttributeValue<AttributeValue> {
59+
60+ override fun toInheritor () = AttributeValue (
61+ id = id,
62+ name = name,
63+ type = type,
64+ value = value,
65+ show = show
66+ )
7267 }
7368
7469 data class WholesalePrice (
You can’t perform that action at this time.
0 commit comments