Last active
August 16, 2021 14:26
-
-
Save wzieba/b8b951966669fb08a846197d7f4168b2 to your computer and use it in GitHub Desktop.
Product addon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.wordpress.android.fluxc.domain | |
sealed class Addon { | |
abstract val name: String? | |
abstract val titleFormat: TitleFormat? | |
abstract val description: Description | |
abstract val required: Boolean? | |
abstract val position: Int? | |
abstract val options: List<ProductAddonOption> | |
data class MultipleChoice( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption>, | |
val display: Display | |
) : Addon() { | |
enum class Display { | |
Dropdown, | |
RadioButton, | |
Images | |
} | |
} | |
data class CustomText( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption>, | |
val restrictions: Restrictions, | |
val price: Price, | |
val min: Int?, | |
val max: Int? | |
) : Addon() { | |
sealed class Restrictions { | |
object None : Restrictions() | |
data class Exist(val type: Type) : Restrictions() { | |
enum class Type { | |
AnyText, | |
OnlyLetters, | |
OnlyNumbers, | |
OnlyLettersNumbers, | |
} | |
} | |
} | |
} | |
data class Checkbox( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption> | |
) : Addon() | |
data class CustomTextArea( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption>, | |
val price: Price, | |
val min: Int?, | |
val max: Int? | |
) : Addon() | |
data class FileUpload( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption>, | |
val price: Price, | |
) : Addon() | |
data class CustomPrice( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption>, | |
val price: Price, | |
val min: Int?, | |
val max: Int?, | |
) : Addon() | |
data class InputMultiplier( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption>, | |
val priceType: Price, | |
val min: Int?, | |
val max: Int?, | |
) : Addon() | |
data class Heading( | |
override val name: String, | |
override val titleFormat: TitleFormat?, | |
override val description: Description, | |
override val required: Boolean?, | |
override val position: Int?, | |
override val options: List<ProductAddonOption>, | |
) : Addon() | |
enum class TitleFormat { | |
Label, | |
Heading, | |
Hide | |
} | |
enum class PriceType { | |
FlatFee, | |
QuantityBased, | |
PercentageBased | |
} | |
sealed class Price { | |
data class Adjusted(val priceType: PriceType, val price: String) : Price() | |
object NotAdjusted : Price() | |
} | |
sealed class Description { | |
object Disabled : Description() | |
data class Enabled(val value: String) : Description() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment