Skip to content

Commit

Permalink
use device as en enum and default to mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
fcs-ts committed Aug 9, 2024
1 parent 84a7c0b commit 10e3966
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.topsort.analytics.banners

import com.topsort.analytics.model.auctions.Device

/**
* Class that handles different type of Banner configurations
*/
Expand All @@ -10,13 +12,13 @@ sealed class BannerConfig private constructor() {
*
* @property slotId id of the banner slot
* @property ids ids of the entities that are competing for the banner
* @property device can be "desktop" or "mobile"
* @property device target device for the banner
* @property geoTargeting optional location for geo-targeted banners
*/
data class LandingPage(
val slotId: String,
val ids: List<String>,
val device: String? = null,
val device: Device = Device.MOBILE,
val geoTargeting: String? = null
) : BannerConfig()

Expand All @@ -25,13 +27,13 @@ sealed class BannerConfig private constructor() {
*
* @property slotId id of the banner slot
* @property category category for the banner
* @property device can be "desktop" or "mobile"
* @property device target device for the banner
* @property geoTargeting optional location for geo-targeted banners
*/
data class CategorySingle(
val slotId: String,
val category: String,
val device: String? = null,
val device: Device = Device.MOBILE,
val geoTargeting: String? = null
) : BannerConfig()

Expand All @@ -40,13 +42,13 @@ sealed class BannerConfig private constructor() {
*
* @property slotId id of the banner slot
* @property categories list of categories for the competing banners
* @property device can be "desktop" or "mobile"
* @property device target device for the banner
* @property geoTargeting optional location for geo-targeted banners
*/
data class CategoryMultiple(
val slotId: String,
val categories: List<String>,
val device: String? = null,
val device: Device = Device.MOBILE,
val geoTargeting: String? = null,
) : BannerConfig()

Expand All @@ -55,13 +57,13 @@ sealed class BannerConfig private constructor() {
*
* @property slotId id of the banner slot
* @property disjunctions category disjunctions for the competing banners
* @property device can be "desktop" or "mobile"
* @property device target device for the banner
* @property geoTargeting optional location for geo-targeted banners
*/
data class CategoryDisjunctions(
val slotId: String,
val disjunctions: List<List<String>>,
val device: String? = null,
val device: Device = Device.MOBILE,
val geoTargeting: String? = null,
) : BannerConfig()

Expand All @@ -70,13 +72,13 @@ sealed class BannerConfig private constructor() {
*
* @property slotId id of the banner slot
* @property keyword keyword for the competing banners
* @property device can be "desktop" or "mobile"
* @property device target device for the banner
* @property geoTargeting optional location for geo-targeted banners
*/
data class Keyword(
val slotId: String,
val keyword: String,
val device: String? = null,
val device: Device = Device.MOBILE,
val geoTargeting: String? = null,
) : BannerConfig()
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.topsort.analytics.model.auctions

data class Auction private constructor (
data class Auction private constructor(
val type: String,
val slots: Int,
val products: Products? = null,
val category: Category? = null,
val searchQuery: String? = null,
val geoTargeting: GeoTargeting? = null,
val slotId: String? = null,
val device: String? = null,
val device: Device? = null,
) {

object Factory{
object Factory {

@JvmOverloads
fun buildSponsoredListingAuctionProductIds(
slots : Int,
slots: Int,
ids: List<String>,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "listings",
slots = slots,
Expand All @@ -29,10 +29,10 @@ data class Auction private constructor (

@JvmOverloads
fun buildSponsoredListingAuctionCategorySingle(
slots : Int,
slots: Int,
category: String,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "listings",
slots = slots,
Expand All @@ -43,10 +43,10 @@ data class Auction private constructor (

@JvmOverloads
fun buildSponsoredListingAuctionCategoryMultiple(
slots : Int,
slots: Int,
categories: List<String>,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "listings",
slots = slots,
Expand All @@ -57,10 +57,10 @@ data class Auction private constructor (

@JvmOverloads
fun buildSponsoredListingAuctionCategoryDisjunctions(
slots : Int,
slots: Int,
disjunctions: List<List<String>>,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "listings",
slots = slots,
Expand All @@ -71,10 +71,10 @@ data class Auction private constructor (

@JvmOverloads
fun buildSponsoredListingAuctionKeyword(
slots : Int,
slots: Int,
keyword: String,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "listings",
slots = slots,
Expand All @@ -85,12 +85,12 @@ data class Auction private constructor (

@JvmOverloads
fun buildBannerAuctionLandingPage(
slots : Int,
slotId : String,
slots: Int,
slotId: String,
ids: List<String>,
device: String? = null,
device: Device = Device.MOBILE,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "banners",
slots = slots,
Expand All @@ -103,12 +103,12 @@ data class Auction private constructor (

@JvmOverloads
fun buildBannerAuctionCategorySingle(
slots : Int,
slotId : String,
slots: Int,
slotId: String,
category: String,
device: String? = null,
device: Device = Device.MOBILE,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "banners",
slots = slots,
Expand All @@ -121,12 +121,12 @@ data class Auction private constructor (

@JvmOverloads
fun buildBannerAuctionCategoryMultiple(
slots : Int,
slotId : String,
slots: Int,
slotId: String,
categories: List<String>,
device: String? = null,
device: Device = Device.MOBILE,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "banners",
slots = slots,
Expand All @@ -139,12 +139,12 @@ data class Auction private constructor (

@JvmOverloads
fun buildBannerAuctionCategoryDisjunctions(
slots : Int,
slotId : String,
slots: Int,
slotId: String,
disjunctions: List<List<String>>,
device: String? = null,
device: Device = Device.MOBILE,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "banners",
slots = slots,
Expand All @@ -157,12 +157,12 @@ data class Auction private constructor (

@JvmOverloads
fun buildBannerAuctionKeywords(
slots : Int,
slotId : String,
slots: Int,
slotId: String,
keyword: String,
device: String? = null,
device: Device = Device.MOBILE,
geoTargeting: String? = null,
) : Auction {
): Auction {
return Auction(
type = "banners",
slots = slots,
Expand All @@ -174,7 +174,7 @@ data class Auction private constructor (
}
}

data class Products (
data class Products(
val ids: List<String>,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,3 @@ data class AuctionResponse private constructor(
}
}

enum class EntityType {
PRODUCT,
VENDOR,
BRAND,
URL;

companion object {
fun fromValue(value: String): EntityType = when (value) {
"product" -> PRODUCT
"vendor" -> VENDOR
"brand" -> BRAND
"url" -> URL
else -> throw IllegalArgumentException("not valid entity type: $value")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.topsort.analytics.model.auctions

enum class Device {
DESKTOP,
MOBILE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.topsort.analytics.model.auctions

enum class EntityType {
PRODUCT,
VENDOR,
BRAND,
URL;

companion object {
fun fromValue(value: String): EntityType = when (value) {
"product" -> PRODUCT
"vendor" -> VENDOR
"brand" -> BRAND
"url" -> URL
else -> throw IllegalArgumentException("not valid entity type: $value")
}
}
}

0 comments on commit 10e3966

Please sign in to comment.