Skip to content

Commit

Permalink
Add support for internal-all-channels
Browse files Browse the repository at this point in the history
  • Loading branch information
fredex42 committed Jun 11, 2024
1 parent ef0a2e4 commit 3ea8af4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ case class ItemQuery(id: String, parameterHolder: Map[String, Parameter] = Map.e
with UseDateParameter[ItemQuery]
with FilterParameters[ItemQuery]
with FilterExtendedParameters[ItemQuery]
with FilterSearchParameters[ItemQuery] {
with FilterSearchParameters[ItemQuery]
with InternalParameters[ItemQuery] {

def withParameters(parameterMap: Map[String, Parameter]) = copy(id, parameterMap)

Expand Down Expand Up @@ -349,6 +350,17 @@ trait FilterSearchParameters[Owner <: Parameters[Owner]] extends Parameters[Owne
def queryFields = StringParameter("query-fields")
}

trait InternalParameters[Owner <: Parameters[Owner]] extends Parameters[Owner] { this: Owner =>
/**
* Requests that results for /internal-code/?? paths are returned from Live even if they are
* not published to the website [Open Channel]. No effect on Preview as they are returned even if unpublished then.
* No effect if the active key is not Internal tier, or the request is not an item-retrieval for an internal-code of the
* article.
* @return
*/
def internalAllChannels = BoolParameter("internal-all-channels")
}

trait AtomsParameters[Owner <: Parameters[Owner]] extends Parameters[Owner] { this: Owner =>
def types = StringParameter("types")
def searchFields = StringParameter("searchFields")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class ContentApiQueryTest extends AnyFlatSpec with Matchers {
"/profile/justin-pinner?show-alias-paths=true"
}

"ItemQuery" should "include the internal-all-channels if requested" in {
ItemQuery("profile/justin-pinner").internalAllChannels(true).getUrl("") shouldEqual
"/profile/justin-pinner?internal-all-channels=true"
}

"SearchQuery" should "also be excellent" in {
SearchQuery().tag("profile/robert-berry").showElements("all").contentType("article").queryFields("body").getUrl("") shouldEqual
"/search?tag=profile%2Frobert-berry&show-elements=all&type=article&query-fields=body"
Expand Down

0 comments on commit 3ea8af4

Please sign in to comment.