-
Notifications
You must be signed in to change notification settings - Fork 3
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 #10 from hmrc/DC-2845
DC-2845: creating conversation inbox partial
- Loading branch information
Showing
56 changed files
with
964 additions
and
355 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2021 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package connectors | ||
|
||
import javax.inject.Inject | ||
import models.ConversationHeader | ||
import uk.gov.hmrc.http.HttpReads.Implicits._ | ||
import uk.gov.hmrc.http.{ HeaderCarrier, HttpClient } | ||
import uk.gov.hmrc.play.bootstrap.config.ServicesConfig | ||
|
||
import scala.concurrent.{ ExecutionContext, Future } | ||
|
||
class SecureMessageConnector @Inject()(httpClient: HttpClient, servicesConfig: ServicesConfig) { | ||
|
||
private val secureMessageBaseUrl = servicesConfig.baseUrl("secure-message") | ||
|
||
def getConversationList()(implicit ec: ExecutionContext, hc: HeaderCarrier): Future[List[ConversationHeader]] = | ||
httpClient.GET[List[ConversationHeader]]( | ||
s"$secureMessageBaseUrl/secure-messaging/conversations/HMRC-CUS-ORG/EORINumber") | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2021 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package controllers | ||
|
||
import play.api.i18n.I18nSupport | ||
import play.api.mvc.{ MessagesControllerComponents, _ } | ||
import uk.gov.hmrc.auth.core.{ AuthConnector, AuthorisedFunctions } | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController | ||
import config.AppConfig | ||
|
||
import scala.concurrent.{ ExecutionContext, Future } | ||
import views.html.partials.conversationInbox | ||
import javax.inject.{ Inject, Singleton } | ||
import play.api.Logger | ||
import uk.gov.hmrc.http.HeaderCarrier | ||
import uk.gov.hmrc.play.http.HeaderCarrierConverter | ||
import connectors.SecureMessageConnector | ||
import views.viewmodels.ConversationInbox | ||
|
||
@Singleton | ||
class ConversationInboxController @Inject()( | ||
appConfig: AppConfig, | ||
controllerComponents: MessagesControllerComponents, | ||
inbox: conversationInbox, | ||
secureMessageConnector: SecureMessageConnector, | ||
val authConnector: AuthConnector)(implicit ec: ExecutionContext) | ||
extends FrontendController(controllerComponents) with I18nSupport with AuthorisedFunctions { | ||
|
||
private val logger = Logger(getClass) | ||
|
||
implicit val config: AppConfig = appConfig | ||
|
||
def display(clientService: String, apiFilters: Option[List[String]]): Action[AnyContent] = Action.async { | ||
implicit request => | ||
implicit val hc: HeaderCarrier = HeaderCarrierConverter.fromRequest(request) | ||
val apiFilterValues = apiFilters.getOrElse(List("NONE")).mkString("&apiFilter=") | ||
// FIXME the logging is just to keep the compiler happy until the filters are implemented | ||
logger.info(s"apiFilter=$apiFilterValues") | ||
authorised() { | ||
secureMessageConnector.getConversationList().flatMap { conversations => | ||
val messages = this.messagesApi.preferred(request) | ||
Future.successful( | ||
Ok(inbox.apply(ConversationInbox(clientService, messages("conversation.inbox.title"), conversations)))) | ||
} | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2021 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package models | ||
|
||
import org.joda.time.DateTime | ||
import play.api.libs.json.JodaReads.jodaDateReads | ||
import play.api.libs.json.JodaWrites.jodaDateWrites | ||
import play.api.libs.json.{ Format, Json, OFormat } | ||
|
||
final case class ConversationHeader( | ||
client: String, | ||
conversationId: String, | ||
subject: String, | ||
issueDate: DateTime, | ||
senderName: Option[String], | ||
unreadMessages: Boolean, | ||
count: Int) | ||
|
||
object ConversationHeader { | ||
|
||
private val dateFormatString = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" | ||
|
||
implicit val dateFormat: Format[DateTime] = Format(jodaDateReads(dateFormatString), jodaDateWrites(dateFormatString)) | ||
|
||
implicit val conversationHeaderReads: OFormat[ConversationHeader] = Json.format[ConversationHeader] | ||
|
||
} |
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
42 changes: 0 additions & 42 deletions
42
app/uk/gov/hmrc/securemessagefrontend/controllers/ConversationsController.scala
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
app/uk/gov/hmrc/securemessagefrontend/controllers/HelloWorldController.scala
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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.