mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-01 08:48:46 +02:00
ef4c5eb65e
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
28 lines
1.1 KiB
Scala
28 lines
1.1 KiB
Scala
package com.twitter.follow_recommendations.common.utils
|
|
|
|
import com.twitter.follow_recommendations.common.models.DisplayLocation
|
|
import com.twitter.follow_recommendations.common.models.Product
|
|
import com.twitter.product_mixer.core.model.marshalling.request.Product
|
|
|
|
object DisplayLocationProductConverterUtil {
|
|
def productToDisplayLocation(product: Product): DisplayLocation = {
|
|
product match {
|
|
case Product.MagicRecs => DisplayLocation.MagicRecs
|
|
case _ =>
|
|
throw UnconvertibleProductMixerProductException(
|
|
s"Cannot convert Product Mixer Product ${product.identifier.name} into a FRS DisplayLocation.")
|
|
}
|
|
}
|
|
|
|
def displayLocationToProduct(displayLocation: DisplayLocation): Product = {
|
|
displayLocation match {
|
|
case DisplayLocation.MagicRecs => Product.MagicRecs
|
|
case _ =>
|
|
throw UnconvertibleProductMixerProductException(
|
|
s"Cannot convert DisplayLocation ${displayLocation.toFsName} into a Product Mixer Product.")
|
|
}
|
|
}
|
|
}
|
|
|
|
case class UnconvertibleProductMixerProductException(message: String) extends Exception(message)
|