-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #550 from NDLANO/expand-search-traits
Add trait for audio and podcast.
- Loading branch information
Showing
17 changed files
with
103 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
33 changes: 33 additions & 0 deletions
33
search-api/src/main/scala/no/ndla/searchapi/model/search/SearchTrait.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Part of NDLA search-api | ||
* Copyright (C) 2024 NDLA | ||
* | ||
* See LICENSE | ||
*/ | ||
|
||
package no.ndla.searchapi.model.search | ||
|
||
import com.scalatsi.TypescriptType.{TSLiteralString, TSUnion} | ||
import com.scalatsi.{TSNamedType, TSType} | ||
import enumeratum.* | ||
import no.ndla.common.CirceUtil.CirceEnumWithErrors | ||
import sttp.tapir.Schema | ||
import sttp.tapir.codec.enumeratum.* | ||
|
||
sealed abstract class SearchTrait(override val entryName: String) extends EnumEntry { | ||
override def toString: String = entryName | ||
} | ||
object SearchTrait extends Enum[SearchTrait] with CirceEnumWithErrors[SearchTrait] { | ||
case object Video extends SearchTrait("VIDEO") | ||
case object H5p extends SearchTrait("H5P") | ||
case object Audio extends SearchTrait("AUDIO") | ||
case object Podcast extends SearchTrait("PODCAST") | ||
|
||
def all: List[String] = SearchTrait.values.map(_.toString).toList | ||
override def values: IndexedSeq[SearchTrait] = findValues | ||
def valueOf(s: String): Option[SearchTrait] = SearchTrait.values.find(_.entryName == s) | ||
implicit def schema: Schema[SearchTrait] = schemaForEnumEntry[SearchTrait] | ||
|
||
implicit val enumTsType: TSNamedType[SearchTrait] = | ||
TSType.alias[SearchTrait]("SearchTrait", TSUnion(values.map(e => TSLiteralString(e.entryName)))) | ||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.