Skip to content

Commit

Permalink
Merge pull request #112 from hmrc/SASS-8612
Browse files Browse the repository at this point in the history
[SASS-8612] Create common task list endpoint
  • Loading branch information
Jake-Raffe authored Jun 26, 2024
2 parents e8b6f34 + 17176a1 commit c5a708e
Show file tree
Hide file tree
Showing 20 changed files with 1,030 additions and 36 deletions.
12 changes: 8 additions & 4 deletions app/controllers/JourneyStatusController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ class JourneyStatusController @Inject() (journeyStatusService: JourneyStatusServ
handleApiResultT(result)
}

def setStatus(businessId: BusinessId, journey: JourneyName, taxYear: TaxYear): Action[AnyContent] = auth.async { implicit request =>
getBody[JourneyStatusData](request) { statusData =>
journeyStatusService.set(JourneyContext(taxYear, businessId, request.getMtditid, journey), statusData.status).map(_ => NoContent)
}
}

def getTaskList(taxYear: TaxYear, nino: Nino): Action[AnyContent] = auth.async { implicit request =>
val result = journeyStatusService.getTaskList(taxYear, request.getMtditid, nino)
handleApiResultT(result)
}

def setStatus(businessId: BusinessId, journey: JourneyName, taxYear: TaxYear): Action[AnyContent] = auth.async { implicit request =>
getBody[JourneyStatusData](request) { statusData =>
journeyStatusService.set(JourneyContext(taxYear, businessId, request.getMtditid, journey), statusData.status).map(_ => NoContent)
}
def getCommonTaskList(taxYear: TaxYear, nino: Nino): Action[AnyContent] = auth.async { implicit user =>
handleApiResultT(journeyStatusService.getCommonTaskList(taxYear, user.getMtditid, nino))
}
}
4 changes: 1 addition & 3 deletions app/models/common/JourneyName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ sealed abstract class JourneyName(override val entryName: String) extends EnumEn
}

object JourneyName extends Enum[JourneyName] with utils.PlayJsonEnum[JourneyName] {

val values: IndexedSeq[JourneyName] = findValues

case object TradeDetails extends JourneyName("trade-details")
case object SelfEmploymentAbroad extends JourneyName("self-employment-abroad")
case object Income extends JourneyName("income")
case object IncomePrepop extends JourneyName("income-prepop")
case object AdjustmentsPrepop extends JourneyName("adjustments-prepop")
case object BusinessDetailsPrepop extends JourneyName("business-details-prepop")
case object ExpensesTailoring extends JourneyName("expenses-categories")
case object GoodsToSellOrUse extends JourneyName("expenses-goods-to-sell-or-use")
case object WorkplaceRunningCosts extends JourneyName("expenses-workplace-running-costs")
Expand Down
24 changes: 20 additions & 4 deletions app/models/common/JourneyStatus.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,40 @@
package models.common

import enumeratum._
import models.commonTaskList.TaskStatus

sealed abstract class JourneyStatus(override val entryName: String) extends EnumEntry {
override def toString: String = entryName

def toCommonTaskListStatus: TaskStatus
}

object JourneyStatus extends Enum[JourneyStatus] with utils.PlayJsonEnum[JourneyStatus] {

val values: IndexedSeq[JourneyStatus] = findValues

/** This status is used if there are no answers persisted */
case object CheckOurRecords extends JourneyStatus("checkOurRecords")
case object CheckOurRecords extends JourneyStatus("checkOurRecords") {
override def toCommonTaskListStatus: TaskStatus = TaskStatus.CheckNow()
}

/** It is used to indicate the answers were submitted, but the 'Have you completed' question has not been answered */
case object NotStarted extends JourneyStatus("notStarted")
case object NotStarted extends JourneyStatus("notStarted") {
override def toCommonTaskListStatus: TaskStatus = TaskStatus.NotStarted()
}

/** The completion page has been passed with answer No */
case object InProgress extends JourneyStatus("inProgress")
case object InProgress extends JourneyStatus("inProgress") {
override def toCommonTaskListStatus: TaskStatus = TaskStatus.InProgress()
}

/** The completion page has been passed with answer Yes */
case object Completed extends JourneyStatus("completed") {
override def toCommonTaskListStatus: TaskStatus = TaskStatus.Completed()
}

/** The completion page has been passed with answer Yes */
case object Completed extends JourneyStatus("completed")
case object CannotStartYet extends JourneyStatus("cannotStartYet") {
override def toCommonTaskListStatus: TaskStatus = TaskStatus.CannotStartYet()
}
}
37 changes: 37 additions & 0 deletions app/models/commonTaskList/SectionTitle.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2024 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.commonTaskList

import models.common.{Enumerable, WithName}
import play.api.libs.json.{Json, OWrites, Reads}

trait SectionTitle extends Enumerable.Implicits

object SectionTitle extends SectionTitle {

case class SelfEmploymentTitle() extends WithName("SelfEmployment") with SectionTitle
object SelfEmploymentTitle {
implicit val nonStrictReads: Reads[SelfEmploymentTitle] = Reads.pure(SelfEmploymentTitle())
implicit val writes: OWrites[SelfEmploymentTitle] = OWrites[SelfEmploymentTitle](_ => Json.obj())
}

val values: Seq[SectionTitle] = Seq(SelfEmploymentTitle())

implicit val enumerable: Enumerable[SectionTitle] =
Enumerable(values.map(v => v.toString -> v): _*)

}
Loading

0 comments on commit c5a708e

Please sign in to comment.