Skip to content

Commit

Permalink
put the newsletter api url in the dcr page model
Browse files Browse the repository at this point in the history
  • Loading branch information
dblatcher committed Nov 26, 2024
1 parent 3ac3628 commit 0aa60c6
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import navigation.{FooterLinks, Nav}
import play.api.libs.json.{JsObject, JsValue, Json, OWrites}
import play.api.mvc.RequestHeader
import views.support.{CamelCase, JavaScriptPage}
import conf.Configuration.newsletterApi

case class DotcomFrontsRenderingDataModel(
pressedPage: PressedPage,
Expand All @@ -36,6 +37,7 @@ case class DotcomFrontsRenderingDataModel(
contributionsServiceUrl: String,
canonicalUrl: String,
newsletters: List[NewsletterData],
newsletterApiUri: Option[String],
)

object DotcomFrontsRenderingDataModel {
Expand Down Expand Up @@ -108,6 +110,7 @@ object DotcomFrontsRenderingDataModel {
contributionsServiceUrl = Configuration.contributionsService.url,
canonicalUrl = CanonicalLink(request, page.metadata.webUrl),
newsletters = newsletterData,
newsletterApiUri = getNewsletterApiUri(),
)
}

Expand All @@ -131,4 +134,12 @@ object DotcomFrontsRenderingDataModel {
response.illustrationCard,
)
}

private def getNewsletterApiUri(): Option[String] = {
for {
host <- newsletterApi.host
} yield {
s"$host/api/newsletters"
}
}
}

0 comments on commit 0aa60c6

Please sign in to comment.