com.gravity.gdk.reco.RecoArticleInImpression.scala Maven / Gradle / Ivy
The newest version!
package com.gravity.gdk.reco
import com.gravity.gdk.article.ArticleKey
import play.api.libs.functional.syntax._
import play.api.libs.json._
/*
___...---''
___...---'\'___
'' _.-'' _`'.______\\.
/_.) )..- __..--'\\
( __..--''
'-''\@
Ⓐ Ⓐ Ⓐ Ⓐ Ⓐ Ⓐ Ⓐ Ⓐ Ⓐ Ⓐ Ⓐ
*/
/**
* A [[RecoArticle]] that appeared in an impression (namely, has an index in an ordered set of recommended articles).
* This is generally internal use only.
*/
case class RecoArticleInImpression(key: ArticleKey, displayIndex: Int, articleImpressionSlug: String)
object RecoArticleInImpression {
def fromArticleList(articles: List[RecoArticle]): List[RecoArticleInImpression] = for {
(article, i) <- articles.zipWithIndex
} yield RecoArticleInImpression(article.articleId, i, article.articleImpressionSlug)
private[gdk] implicit val jsonFormatter = (
(__ \ "articleId").format[ArticleKey] and
(__ \ "displayIndex").format[Int] and
(__ \ "encodedArticleImpressionSlug").format[String]
)(RecoArticleInImpression.apply, unlift(RecoArticleInImpression.unapply))
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy