diff --git a/app/uk/gov/hmrc/epayeapi/connectors/ConnectorBase.scala b/app/uk/gov/hmrc/epayeapi/connectors/ConnectorBase.scala index 21c393f..72e0ddb 100644 --- a/app/uk/gov/hmrc/epayeapi/connectors/ConnectorBase.scala +++ b/app/uk/gov/hmrc/epayeapi/connectors/ConnectorBase.scala @@ -19,7 +19,8 @@ package uk.gov.hmrc.epayeapi.connectors import play.api.Logger import play.api.http.Status import play.api.libs.json.{JsError, JsSuccess, Reads} -import uk.gov.hmrc.epayeapi.models.api._ +import uk.gov.hmrc.epayeapi.models.in +import uk.gov.hmrc.epayeapi.models.in._ import uk.gov.hmrc.epayeapi.syntax.json._ import uk.gov.hmrc.play.http.{HeaderCarrier, HttpGet, HttpReads, HttpResponse} @@ -55,7 +56,7 @@ trait ConnectorBase { case Status.NOT_FOUND => ApiNotFound() case _ => - ApiError(response.status, response.body) + in.ApiError(response.status, response.body) } } } diff --git a/app/uk/gov/hmrc/epayeapi/connectors/EpayeConnector.scala b/app/uk/gov/hmrc/epayeapi/connectors/EpayeConnector.scala index 0e62ffb..f9825c6 100644 --- a/app/uk/gov/hmrc/epayeapi/connectors/EpayeConnector.scala +++ b/app/uk/gov/hmrc/epayeapi/connectors/EpayeConnector.scala @@ -20,8 +20,7 @@ import javax.inject.{Inject, Singleton} import uk.gov.hmrc.domain.EmpRef import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models._ -import uk.gov.hmrc.epayeapi.models.api.ApiResponse +import uk.gov.hmrc.epayeapi.models.in.{AnnualSummaryResponse, ApiResponse, EpayeTotalsResponse, TaxYear} import uk.gov.hmrc.play.http.HeaderCarrier import uk.gov.hmrc.play.http.ws.WSHttp @@ -29,7 +28,6 @@ import scala.concurrent.{ExecutionContext, Future} case class EpayeApiConfig(baseUrl: String) - @Singleton case class EpayeConnector @Inject() ( config: EpayeApiConfig, @@ -47,16 +45,6 @@ case class EpayeConnector @Inject() ( get[EpayeTotalsResponse](url, headers) } - def getTotalsByType(empRef: EmpRef, headers: HeaderCarrier): Future[ApiResponse[AggregatedTotalsByType]] = { - val url = - s"${config.baseUrl}" + - s"/epaye" + - s"/${empRef.encodedValue}" + - s"/api/v1/totals/by-type" - - get[AggregatedTotalsByType](url, headers) - } - def getAnnualSummary(empRef: EmpRef, headers: HeaderCarrier, taxYear: Option[String]): Future[ApiResponse[AnnualSummaryResponse]] = { val url = s"${config.baseUrl}" + diff --git a/app/uk/gov/hmrc/epayeapi/controllers/AnnualSummaryController.scala b/app/uk/gov/hmrc/epayeapi/controllers/AnnualSummaryController.scala deleted file mode 100644 index 292e1fd..0000000 --- a/app/uk/gov/hmrc/epayeapi/controllers/AnnualSummaryController.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.controllers - -import javax.inject.{Inject, Singleton} - -import akka.stream.Materializer -import play.api.Logger -import play.api.libs.json.Json -import play.api.mvc.{Action, EssentialAction} -import uk.gov.hmrc.auth.core.AuthConnector -import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.connectors.EpayeConnector -import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models.api.{ApiJsonError, ApiNotFound, ApiSuccess} -import uk.gov.hmrc.epayeapi.models.{AnnualSummaryResponse, ApiError} -import uk.gov.hmrc.epayeapi.services.ChargesSummaryService - -import scala.concurrent.{ExecutionContext, Future} - -@Singleton -case class AnnualSummaryController @Inject()( - authConnector: AuthConnector, - epayeConnector: EpayeConnector, - implicit val ec: ExecutionContext, - implicit val mat: Materializer -) - extends ApiController { - - def getAnnualSummary(empRef: EmpRef, taxYear:Option[String]): EssentialAction = EmpRefAction(empRef) { - Action.async { request => - epayeConnector.getAnnualSummary(empRef, hc(request), taxYear).map { - case ApiSuccess(annualSummary) => - Ok(Json.toJson(ChargesSummaryService.toChargesSummary(annualSummary))) - case ApiJsonError(err) => - Logger.error(s"Upstream returned invalid json: $err") - InternalServerError(Json.toJson(ApiError.InternalServerError)) - case ApiNotFound() => - NotFound(Json.toJson(ApiError.EmpRefNotFound)) - case error => - Logger.error(s"Error while fetching totals: $error") - InternalServerError(Json.toJson(ApiError.InternalServerError)) - } - } - } -} diff --git a/app/uk/gov/hmrc/epayeapi/controllers/ApiController.scala b/app/uk/gov/hmrc/epayeapi/controllers/ApiController.scala index 254ec0e..a6fb5b0 100644 --- a/app/uk/gov/hmrc/epayeapi/controllers/ApiController.scala +++ b/app/uk/gov/hmrc/epayeapi/controllers/ApiController.scala @@ -20,15 +20,14 @@ import akka.stream.Materializer import play.api.libs.json.Json import play.api.libs.streams.Accumulator import play.api.mvc._ -import uk.gov.hmrc.auth.core._ -import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.play.microservice.controller.BaseController import uk.gov.hmrc.auth.core.Retrievals._ +import uk.gov.hmrc.auth.core._ import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.models.ApiError.InvalidEmpRef -import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models.{ApiError, EmpRefsResponse} +import uk.gov.hmrc.epayeapi.models.out.ApiError.{AuthorizationHeaderInvalid, InsufficientEnrolments, InvalidEmpRef} import uk.gov.hmrc.play.binders.SimpleObjectBinder +import uk.gov.hmrc.play.microservice.controller.BaseController +import uk.gov.hmrc.epayeapi.models.out.Formats._ + import scala.concurrent.{ExecutionContext, Future} @@ -44,16 +43,15 @@ trait ApiController extends BaseController with AuthorisedFunctions { Accumulator.done { authorised(enrolment.withDelegatedAuthRule("epaye-auth")) .retrieve(retrieveEnrolments) { enrolments => - action(enrolments)(request).run() - } recoverWith { - case ex: MissingBearerToken => missingBearerToken - case ex: InsufficientEnrolments => insufficientEnrolments - } + action(enrolments)(request).run() + } recoverWith { + case ex: MissingBearerToken => missingBearerToken + case ex: InsufficientEnrolments => insufficientEnrolments + } } } } - def EmpRefsAction(action: Set[EmpRef] => EssentialAction): EssentialAction = EnrolmentsAction(epayeEnrolment, epayeRetrieval) { enrolments => EssentialAction { request => @@ -73,11 +71,11 @@ trait ApiController extends BaseController with AuthorisedFunctions { } def missingBearerToken: Future[Result] = - Future.successful(Unauthorized(Json.toJson(ApiError.AuthorizationHeaderInvalid))) + Future.successful(Unauthorized(Json.toJson(AuthorizationHeaderInvalid))) def insufficientEnrolments: Future[Result] = - Future.successful(Forbidden(Json.toJson(ApiError.InsufficientEnrolments))) + Future.successful(Forbidden(Json.toJson(InsufficientEnrolments))) def invalidEmpRef: Future[Result] = - Future.successful(Forbidden(Json.toJson(ApiError.InvalidEmpRef))) + Future.successful(Forbidden(Json.toJson(InvalidEmpRef))) private def enrolmentToEmpRef(enrolment: Enrolment): Option[EmpRef] = { for { diff --git a/app/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsController.scala b/app/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsController.scala index f637333..2433494 100644 --- a/app/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsController.scala +++ b/app/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsController.scala @@ -23,8 +23,8 @@ import play.api.libs.json.Json import play.api.mvc.{Action, AnyContent, EssentialAction} import uk.gov.hmrc.auth.core.AuthConnector import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.models.EmpRefsResponse import uk.gov.hmrc.epayeapi.models.Formats._ +import uk.gov.hmrc.epayeapi.models.out.EmpRefsResponse import scala.concurrent.{ExecutionContext, Future} diff --git a/app/uk/gov/hmrc/epayeapi/controllers/GetSummaryController.scala b/app/uk/gov/hmrc/epayeapi/controllers/GetSummaryController.scala index 338d8b0..7c59220 100644 --- a/app/uk/gov/hmrc/epayeapi/controllers/GetSummaryController.scala +++ b/app/uk/gov/hmrc/epayeapi/controllers/GetSummaryController.scala @@ -26,8 +26,9 @@ import uk.gov.hmrc.auth.core.AuthConnector import uk.gov.hmrc.domain.EmpRef import uk.gov.hmrc.epayeapi.connectors.EpayeConnector import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models.api.{ApiJsonError, ApiNotFound, ApiResponse, ApiSuccess} -import uk.gov.hmrc.epayeapi.models.{ApiError, SummaryResponse} +import uk.gov.hmrc.epayeapi.models.in.{ApiJsonError, ApiNotFound, ApiResponse, ApiSuccess} +import uk.gov.hmrc.epayeapi.models.out.ApiError.EmpRefNotFound +import uk.gov.hmrc.epayeapi.models.out.{ApiError, SummaryResponse} import scala.concurrent.ExecutionContext @@ -49,7 +50,7 @@ case class GetSummaryController @Inject() ( Logger.error(s"Upstream returned invalid json: $err") InternalServerError(Json.toJson(ApiError.InternalServerError)) case ApiNotFound() => - NotFound(Json.toJson(ApiError.EmpRefNotFound)) + NotFound(Json.toJson(EmpRefNotFound)) case error: ApiResponse[_] => Logger.error(s"Error while fetching totals: $error") InternalServerError(Json.toJson(ApiError.InternalServerError)) diff --git a/app/uk/gov/hmrc/epayeapi/controllers/GetTotalsByTypeController.scala b/app/uk/gov/hmrc/epayeapi/controllers/GetTotalsByTypeController.scala deleted file mode 100644 index 21321ad..0000000 --- a/app/uk/gov/hmrc/epayeapi/controllers/GetTotalsByTypeController.scala +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.controllers - -import javax.inject.{Inject, Singleton} - -import akka.stream.Materializer -import play.api.Logger -import play.api.libs.json.Json -import play.api.mvc.{Action, EssentialAction} -import uk.gov.hmrc.auth.core.AuthConnector -import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.connectors.EpayeConnector -import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models.api.{ApiJsonError, ApiNotFound, ApiSuccess} -import uk.gov.hmrc.epayeapi.models.{ApiError, TotalsByTypeResponse} - -import scala.concurrent.ExecutionContext - -@Singleton -case class GetTotalsByTypeController @Inject()( - authConnector: AuthConnector, - epayeConnector: EpayeConnector, - implicit val ec: ExecutionContext, - implicit val mat: Materializer -) - extends ApiController { - - def getTotalsByType(empRef: EmpRef): EssentialAction = EmpRefAction(empRef) { - Action.async { request => - epayeConnector.getTotalsByType(empRef, hc(request)).map { - case ApiSuccess(totals) => - Ok(Json.toJson(TotalsByTypeResponse(empRef, totals))) - case ApiJsonError(err) => - Logger.error(s"Upstream returned invalid json: $err") - InternalServerError(Json.toJson(ApiError.InternalServerError)) - case ApiNotFound() => - NotFound(Json.toJson(ApiError.EmpRefNotFound)) - case error => - Logger.error(s"Error while fetching totals: $error") - InternalServerError(Json.toJson(ApiError.InternalServerError)) - } - } - } -} diff --git a/app/uk/gov/hmrc/epayeapi/models/AggregatedTotals.scala b/app/uk/gov/hmrc/epayeapi/models/AggregatedTotals.scala deleted file mode 100644 index c7f0b99..0000000 --- a/app/uk/gov/hmrc/epayeapi/models/AggregatedTotals.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.models - -case class AggregatedTotals(credit: BigDecimal, debit: BigDecimal) diff --git a/app/uk/gov/hmrc/epayeapi/models/AggregatedTotalsByType.scala b/app/uk/gov/hmrc/epayeapi/models/AggregatedTotalsByType.scala deleted file mode 100644 index b4cd0a0..0000000 --- a/app/uk/gov/hmrc/epayeapi/models/AggregatedTotalsByType.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.models - -import uk.gov.hmrc.domain.EmpRef - - -case class AggregatedTotalsByType(rti: AggregatedTotals, nonRti: AggregatedTotals) - diff --git a/app/uk/gov/hmrc/epayeapi/models/Example.scala b/app/uk/gov/hmrc/epayeapi/models/Example.scala deleted file mode 100644 index 5e32c86..0000000 --- a/app/uk/gov/hmrc/epayeapi/models/Example.scala +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.models - -object Example extends App { - import scala.concurrent.ExecutionContext.Implicits.global - import scala.concurrent.Future - import scala.concurrent.Await - import scala.concurrent.duration.Duration - import scala.util.{Success, Failure} - - sealed trait Resp - case class Good(i: Int) extends Resp - case class Bad(s: String) extends Resp - - object Foo { - def run: Int = { - val first: Future[Resp] = Future.successful(Good(1)) - val econd: Future[Resp] = Future.successful(Bad("nope")) - - - val res = for { - Good(one) <- first - Good(two) <- econd - } yield Good(one + two) - - // - // res.onComplete { - // case Success(res) => - // println("OK") - // res - // case Failure(res) => - // println(s"Fail: $res") - // res - // } - - val finalREsult: Resp = Await.result(res.recover { - case ex: Exception => - println(ex) - Bad("Exception handler") - }, Duration.Inf) - - println(s"Final: $finalREsult") - - 100 - } - } - - Foo.run - -} diff --git a/app/uk/gov/hmrc/epayeapi/models/Formats.scala b/app/uk/gov/hmrc/epayeapi/models/Formats.scala index 34b5324..5824dec 100644 --- a/app/uk/gov/hmrc/epayeapi/models/Formats.scala +++ b/app/uk/gov/hmrc/epayeapi/models/Formats.scala @@ -16,46 +16,4 @@ package uk.gov.hmrc.epayeapi.models -import play.api.libs.json._ -import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.models.api.{ChargesSummary, DebitCredit, NonRtiCharge, RtiCharge} - -trait Formats { - implicit val empRefFormat: Writes[EmpRef] = new Writes[EmpRef] { - override def writes(o: EmpRef): JsValue = JsString(s"${o.taxOfficeNumber}/${o.taxOfficeReference}") - } - implicit val linkFormat: Format[Link] = Json.format[Link] - implicit val empRefsLinksFormat: Format[EmpRefsLinks] = Json.format[EmpRefsLinks] - implicit val empRefLinksFormat: Format[EmpRefLinks] = Json.format[EmpRefLinks] - implicit val empRefItemFormat: Format[EmpRefItem] = Json.format[EmpRefItem] - implicit val empRefsResponseFormat: Format[EmpRefsResponse] = Json.format[EmpRefsResponse] - implicit val apiErrorFormat: Format[ApiError] = Json.format[ApiError] - implicit val aggregatedTotalsFormat: Format[AggregatedTotals] = Json.format[AggregatedTotals] - implicit val aggregatedTotalsByTypeFormat: Format[AggregatedTotalsByType] = Json.format[AggregatedTotalsByType] - implicit val breakdown: Format[Breakdown] = Json.format[Breakdown] - implicit val outstandingCharges: Format[OutstandingCharges] = Json.format[OutstandingCharges] - implicit val totalsLinksFormat: Format[SummaryLinks] = Json.format[SummaryLinks] - implicit val totalsResponseFormat: Format[SummaryResponse] = Json.format[SummaryResponse] - implicit val totalsByTypeResponseFormat: Format[TotalsByTypeResponse] = Json.format[TotalsByTypeResponse] - implicit val debitAndCreditFormat: Format[DebitAndCredit] = Json.format[DebitAndCredit] - implicit val clearedFormat: Format[Cleared] = Json.format[Cleared] - implicit val annualTotalFormat: Format[AnnualTotal] = Json.format[AnnualTotal] - implicit val taxYearFormat: Format[TaxYear] = Json.format[TaxYear] - implicit val apiTaxYearFormat: Format[api.TaxYear] = Json.format[api.TaxYear] - implicit val taxMonthFormat: Format[TaxMonth] = Json.format[TaxMonth] - implicit val apiTaxMonthFormat: Format[api.TaxMonth] = Json.format[api.TaxMonth] - implicit val lineItemFormat: Format[LineItem] = Json.format[LineItem] - implicit val annualSummaryFormat: Format[AnnualSummary] = Json.format[AnnualSummary] - implicit val annualSummaryResponseFormat: Format[AnnualSummaryResponse] = Json.format[AnnualSummaryResponse] - - implicit val debitCreditFormat: Format[DebitCredit] = Json.format[DebitCredit] - implicit val rtiChargeFormat: Format[RtiCharge] = Json.format[RtiCharge] - implicit val nonRtiChargeFormat: Format[NonRtiCharge] = Json.format[NonRtiCharge] - implicit val chargesSummaryFormat: Format[ChargesSummary] = Json.format[ChargesSummary] - implicit val epayeTotals: Format[EpayeTotals] = Json.format[EpayeTotals] - implicit val epayeTotalsItems: Format[EpayeTotalsItem] = Json.format[EpayeTotalsItem] - implicit val epayeTotalsResponse: Format[EpayeTotalsResponse] = Json.format[EpayeTotalsResponse] - -} - -object Formats extends Formats +object Formats extends in.Formats with out.Formats diff --git a/app/uk/gov/hmrc/epayeapi/models/api/ChargesSummary.scala b/app/uk/gov/hmrc/epayeapi/models/api/ChargesSummary.scala deleted file mode 100644 index 04d44e5..0000000 --- a/app/uk/gov/hmrc/epayeapi/models/api/ChargesSummary.scala +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.models.api - -import org.joda.time.LocalDate -import uk.gov.hmrc.epayeapi.models - - -case class TaxYear( - year: String, - first_day: LocalDate, - last_day: LocalDate -) -object TaxYear { - def fromTaxYear(taxYear: models.TaxYear): TaxYear = { - TaxYear(taxYear.asString, taxYear.firstDay, taxYear.lastDay) - } -} - -case class TaxMonth( - month: Int, - first_day: LocalDate, - last_day: LocalDate -) -object TaxMonth { - def fromTaxMonth(taxMonth: models.TaxMonth, taxYear: models.TaxYear): TaxMonth = { - TaxMonth( - taxMonth.month, - taxMonth.firstDay(taxYear), - taxMonth.lastDay(taxYear) - ) - } -} - -case class DebitCredit( - debit: BigDecimal, - credit: BigDecimal -) - -case class RtiCharge( - tax_year: TaxYear, - tax_month: Option[TaxMonth], - balance: DebitCredit, - due_date: Option[LocalDate], - is_overdue: Boolean -) - -case class NonRtiCharge( - charge_code: String, - tax_year: TaxYear, - balance: DebitCredit, - due_date: Option[LocalDate], - is_overdue: Boolean -) - -case class ChargesSummary( - rti: Seq[RtiCharge], - non_rti: Seq[NonRtiCharge] -) diff --git a/app/uk/gov/hmrc/epayeapi/models/AnnualSummaryResponse.scala b/app/uk/gov/hmrc/epayeapi/models/in/AnnualSummaryResponse.scala similarity index 96% rename from app/uk/gov/hmrc/epayeapi/models/AnnualSummaryResponse.scala rename to app/uk/gov/hmrc/epayeapi/models/in/AnnualSummaryResponse.scala index cc34185..3532222 100644 --- a/app/uk/gov/hmrc/epayeapi/models/AnnualSummaryResponse.scala +++ b/app/uk/gov/hmrc/epayeapi/models/in/AnnualSummaryResponse.scala @@ -14,12 +14,10 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.in import org.joda.time.LocalDate -import scala.util.Try - case class DebitAndCredit( debit: BigDecimal = 0, credit: BigDecimal = 0 diff --git a/app/uk/gov/hmrc/epayeapi/models/api/ApiResponse.scala b/app/uk/gov/hmrc/epayeapi/models/in/ApiResponse.scala similarity index 96% rename from app/uk/gov/hmrc/epayeapi/models/api/ApiResponse.scala rename to app/uk/gov/hmrc/epayeapi/models/in/ApiResponse.scala index 3cc11f0..5583934 100644 --- a/app/uk/gov/hmrc/epayeapi/models/api/ApiResponse.scala +++ b/app/uk/gov/hmrc/epayeapi/models/in/ApiResponse.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models.api +package uk.gov.hmrc.epayeapi.models.in import play.api.libs.json.JsError diff --git a/app/uk/gov/hmrc/epayeapi/models/EpayeTotalsResponse.scala b/app/uk/gov/hmrc/epayeapi/models/in/EpayeTotalsResponse.scala similarity index 95% rename from app/uk/gov/hmrc/epayeapi/models/EpayeTotalsResponse.scala rename to app/uk/gov/hmrc/epayeapi/models/in/EpayeTotalsResponse.scala index 6571433..a1e4db4 100644 --- a/app/uk/gov/hmrc/epayeapi/models/EpayeTotalsResponse.scala +++ b/app/uk/gov/hmrc/epayeapi/models/in/EpayeTotalsResponse.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.in case class EpayeTotals(balance: DebitAndCredit) case class EpayeTotalsItem(totals: EpayeTotals) diff --git a/app/uk/gov/hmrc/epayeapi/models/in/Formats.scala b/app/uk/gov/hmrc/epayeapi/models/in/Formats.scala new file mode 100644 index 0000000..8967722 --- /dev/null +++ b/app/uk/gov/hmrc/epayeapi/models/in/Formats.scala @@ -0,0 +1,37 @@ +/* + * Copyright 2017 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 uk.gov.hmrc.epayeapi.models.in + +import play.api.libs.json.Json.format +import play.api.libs.json._ + +trait Formats { + implicit lazy val taxYearFormat: Format[TaxYear] = format[TaxYear] + implicit lazy val debitAndCreditFormat: Format[DebitAndCredit] = format[DebitAndCredit] + implicit lazy val clearedFormat: Format[Cleared] = format[Cleared] + implicit lazy val annualTotalFormat: Format[AnnualTotal] = format[AnnualTotal] + implicit lazy val taxMonthFormat: Format[TaxMonth] = format[TaxMonth] + implicit lazy val lineItemFormat: Format[LineItem] = format[LineItem] + implicit lazy val annualSummaryFormat: Format[AnnualSummary] = format[AnnualSummary] + implicit lazy val annualSummaryResponseFormat: Format[AnnualSummaryResponse] = format[AnnualSummaryResponse] + + implicit lazy val epayeTotals: Format[EpayeTotals] = format[EpayeTotals] + implicit lazy val epayeTotalsItems: Format[EpayeTotalsItem] = format[EpayeTotalsItem] + implicit lazy val epayeTotalsResponse: Format[EpayeTotalsResponse] = format[EpayeTotalsResponse] +} + +object Formats extends Formats diff --git a/app/uk/gov/hmrc/epayeapi/models/TaxYear.scala b/app/uk/gov/hmrc/epayeapi/models/in/TaxYear.scala similarity index 97% rename from app/uk/gov/hmrc/epayeapi/models/TaxYear.scala rename to app/uk/gov/hmrc/epayeapi/models/in/TaxYear.scala index d989bc2..6c25fc7 100644 --- a/app/uk/gov/hmrc/epayeapi/models/TaxYear.scala +++ b/app/uk/gov/hmrc/epayeapi/models/in/TaxYear.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.in import org.joda.time.LocalDate import uk.gov.hmrc.time.TaxYearResolver diff --git a/app/uk/gov/hmrc/epayeapi/models/ApiError.scala b/app/uk/gov/hmrc/epayeapi/models/out/ApiError.scala similarity index 97% rename from app/uk/gov/hmrc/epayeapi/models/ApiError.scala rename to app/uk/gov/hmrc/epayeapi/models/out/ApiError.scala index 6538a3e..ea73122 100644 --- a/app/uk/gov/hmrc/epayeapi/models/ApiError.scala +++ b/app/uk/gov/hmrc/epayeapi/models/out/ApiError.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.out case class ApiError(code: String, message: String) @@ -39,7 +39,6 @@ object ApiError { "Provided EmpRef wasn't found." ) - object InternalServerError extends ApiError( "INTERNAL_SERVER_ERROR", "We are currently experiencing problems. Please try again later." diff --git a/app/uk/gov/hmrc/epayeapi/models/EmpRefsResponse.scala b/app/uk/gov/hmrc/epayeapi/models/out/EmpRefsResponse.scala similarity index 97% rename from app/uk/gov/hmrc/epayeapi/models/EmpRefsResponse.scala rename to app/uk/gov/hmrc/epayeapi/models/out/EmpRefsResponse.scala index e702748..223a43a 100644 --- a/app/uk/gov/hmrc/epayeapi/models/EmpRefsResponse.scala +++ b/app/uk/gov/hmrc/epayeapi/models/out/EmpRefsResponse.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.out import uk.gov.hmrc.domain.EmpRef diff --git a/app/uk/gov/hmrc/epayeapi/models/out/Formats.scala b/app/uk/gov/hmrc/epayeapi/models/out/Formats.scala new file mode 100644 index 0000000..47148fd --- /dev/null +++ b/app/uk/gov/hmrc/epayeapi/models/out/Formats.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2017 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 uk.gov.hmrc.epayeapi.models.out + +import play.api.libs.json.Json.format +import play.api.libs.json._ +import uk.gov.hmrc.domain.EmpRef + +trait Formats { + implicit lazy val empRefFormat: Writes[EmpRef] = new Writes[EmpRef] { + override def writes(o: EmpRef): JsValue = JsString(s"${o.taxOfficeNumber}/${o.taxOfficeReference}") + } + implicit lazy val linkFormat: Format[Link] = format[Link] + + implicit lazy val empRefsLinksFormat: Format[EmpRefsLinks] = format[EmpRefsLinks] + implicit lazy val empRefLinksFormat: Format[EmpRefLinks] = format[EmpRefLinks] + implicit lazy val empRefItemFormat: Format[EmpRefItem] = format[EmpRefItem] + implicit lazy val empRefsResponseFormat: Format[EmpRefsResponse] = format[EmpRefsResponse] + implicit lazy val breakdown: Format[Breakdown] = format[Breakdown] + implicit lazy val outstandingCharges: Format[OutstandingCharges] = format[OutstandingCharges] + implicit lazy val totalsLinksFormat: Format[SummaryLinks] = format[SummaryLinks] + implicit lazy val totalsResponseFormat: Format[SummaryResponse] = format[SummaryResponse] + implicit lazy val apiErrorFormat: Format[ApiError] = format[ApiError] +} + +object Formats extends Formats diff --git a/app/uk/gov/hmrc/epayeapi/models/Link.scala b/app/uk/gov/hmrc/epayeapi/models/out/Link.scala similarity index 95% rename from app/uk/gov/hmrc/epayeapi/models/Link.scala rename to app/uk/gov/hmrc/epayeapi/models/out/Link.scala index c544970..0770a10 100644 --- a/app/uk/gov/hmrc/epayeapi/models/Link.scala +++ b/app/uk/gov/hmrc/epayeapi/models/out/Link.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.out import uk.gov.hmrc.domain.EmpRef diff --git a/app/uk/gov/hmrc/epayeapi/models/SummaryResponse.scala b/app/uk/gov/hmrc/epayeapi/models/out/SummaryResponse.scala similarity index 75% rename from app/uk/gov/hmrc/epayeapi/models/SummaryResponse.scala rename to app/uk/gov/hmrc/epayeapi/models/out/SummaryResponse.scala index 6df7e17..c6696af 100644 --- a/app/uk/gov/hmrc/epayeapi/models/SummaryResponse.scala +++ b/app/uk/gov/hmrc/epayeapi/models/out/SummaryResponse.scala @@ -14,9 +14,10 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.out import uk.gov.hmrc.domain.EmpRef +import uk.gov.hmrc.epayeapi.models.in.EpayeTotalsResponse case class Breakdown( rti: BigDecimal, @@ -47,21 +48,6 @@ object SummaryResponse { ) } -case class TotalsByTypeResponse( - rti: AggregatedTotals, - non_rti: AggregatedTotals, - _links: SummaryLinks -) - -object TotalsByTypeResponse { - def apply(empRef: EmpRef, totals: AggregatedTotalsByType): TotalsByTypeResponse = - TotalsByTypeResponse( - AggregatedTotals(totals.rti.credit, totals.rti.debit), - AggregatedTotals(totals.nonRti.credit, totals.nonRti.debit), - SummaryLinks(empRef) - ) -} - case class SummaryLinks( empRefs: Link, self: Link diff --git a/app/uk/gov/hmrc/epayeapi/router/ApiRouter.scala b/app/uk/gov/hmrc/epayeapi/router/ApiRouter.scala index cd2eb9f..a10da58 100644 --- a/app/uk/gov/hmrc/epayeapi/router/ApiRouter.scala +++ b/app/uk/gov/hmrc/epayeapi/router/ApiRouter.scala @@ -22,14 +22,12 @@ import play.api.routing.Router.Routes import play.api.routing.{Router, SimpleRouter} import play.api.routing.sird._ import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.controllers.{AnnualSummaryController, GetTotalsByTypeController, GetSummaryController} +import uk.gov.hmrc.epayeapi.controllers.GetSummaryController @Singleton case class ApiRouter @Inject() ( prodRoutes: prod.Routes, - getTotalsController: GetSummaryController, - getTotalsByTypeController: GetTotalsByTypeController, - annualSummaryController: AnnualSummaryController + getTotalsController: GetSummaryController ) extends SimpleRouter { val appRoutes = Router.from { diff --git a/app/uk/gov/hmrc/epayeapi/services/ChargesSummaryService.scala b/app/uk/gov/hmrc/epayeapi/services/ChargesSummaryService.scala deleted file mode 100644 index 0ede8ed..0000000 --- a/app/uk/gov/hmrc/epayeapi/services/ChargesSummaryService.scala +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.services - -import org.joda.time.LocalDate -import uk.gov.hmrc.epayeapi.models.api._ -import uk.gov.hmrc.epayeapi.models.{AnnualSummary, AnnualSummaryResponse} - - -object ChargesSummaryService { - def today: LocalDate = LocalDate.now() - - def toChargesSummary(annualSummaryResponse: AnnualSummaryResponse): ChargesSummary = { - ChargesSummary( - rti = toRtiChargesSummary(annualSummaryResponse.rti), - non_rti = toNonRtiChargesSummary(annualSummaryResponse.nonRti) - ) - } - - def toRtiChargesSummary(annualSummary: AnnualSummary): Seq[RtiCharge] = { - annualSummary.lineItems.map(lineItem => - RtiCharge( - tax_year = TaxYear.fromTaxYear(lineItem.taxYear), - tax_month = lineItem.taxMonth.map(month => TaxMonth.fromTaxMonth(month, lineItem.taxYear)), - balance = DebitCredit(lineItem.charges.debit, lineItem.charges.credit), - due_date = Some(lineItem.dueDate), - is_overdue = lineItem.dueDate.isBefore(today) - )) - } - - def toNonRtiChargesSummary(annualSummary: AnnualSummary): Seq[NonRtiCharge] = { - annualSummary.lineItems.map(lineItem => - NonRtiCharge( - charge_code = lineItem.codeText.getOrElse(""), - tax_year = TaxYear(lineItem.taxYear.asString, lineItem.taxYear.firstDay, lineItem.taxYear.lastDay), - balance = DebitCredit(lineItem.charges.debit, lineItem.charges.credit), - due_date = Some(lineItem.dueDate), - is_overdue = lineItem.dueDate.isBefore(today) - )) - } - -} diff --git a/resources/public/api/conf/1.0/examples/ChargesSummary.get.json b/resources/public/api/conf/1.0/examples/ChargesSummary.get.json deleted file mode 100644 index 46fdb10..0000000 --- a/resources/public/api/conf/1.0/examples/ChargesSummary.get.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "rti": [ - { - "tax_year": { - "year": "2016-17", - "first_day": "2016-04-06", - "last_day": "2017-04-05" - }, - "tax_month": { - "month": 3, - "first_day": "2016-06-06", - "last_day": "2016-07-05" - }, - "balance": { - "debit": 1200.00, - "credit": 0.0 - }, - "due_date": "2016-10-22", - "is_overdue": true - }, - { - "tax_year": { - "year": "2016-17", - "first_day": "2016-04-06", - "last_day": "2017-04-05" - }, - "tax_month": { - "month": 4, - "first_day": "2016-07-06", - "last_day": "2016-08-05" - }, - "balance": { - "debit": 1300.00, - "credit": 0.0 - }, - "due_date": "2016-11-22", - "is_overdue": true - }, - { - "tax_year": { - "year": "2016-17", - "first_day": "2016-04-06", - "last_day": "2017-04-05" - }, - "tax_month": { - "month": 5, - "first_day": "2016-08-06", - "last_day": "2016-09-05" - }, - "balance": { - "debit": 1200.00, - "credit": 0.0 - }, - "due_date": "2016-10-22", - "is_overdue": true - } - ], - "non_rti": [ - { - "charge_code": "NON_RTI_IN_YEAR_PAYE_LATE_FILING_PENALTY", - "tax_year": { - "year": "2016-17", - "first_day": "2016-04-06", - "last_day": "2017-04-05" - }, - "balance": { - "debit": 1200.00, - "credit": 0.0 - }, - "due_date": "2016-10-22", - "is_overdue": true - }, - { - "charge_code": "NON_RTI_EOY_NIC1", - "tax_year": { - "year": "2016-17", - "first_day": "2016-04-06", - "last_day": "2017-04-05" - }, - "balance": { - "debit": 0.0, - "credit": 800.0 - }, - "due_date": "2016-10-22", - "is_overdue": true - } - ] -} diff --git a/resources/public/api/conf/1.0/examples/Statements.get.array.json b/resources/public/api/conf/1.0/examples/Statements.get.array.json deleted file mode 100644 index b6de153..0000000 --- a/resources/public/api/conf/1.0/examples/Statements.get.array.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "results": [ - { - "balance": 700.0, - "charges": 1000.0, - "payments": 300.00, - "startDate": "2017-04-06", - "endDate": "2017-05-05", - "taxMonth": 1 - }, - { - "balance": 700.0, - "charges": 1000.0, - "payments": 300.00, - "startDate": "2017-05-06", - "endDate": "2017-06-05", - "taxMonth": 2 - }, - { - "balance": 700.0, - "charges": 1000.0, - "payments": 300.00, - "startDate": "2017-06-06", - "endDate": "2017-07-05", - "taxMonth": 3 - } - ] -} diff --git a/resources/public/api/conf/1.0/examples/Totals.ByType.get.json b/resources/public/api/conf/1.0/examples/Totals.ByType.get.json deleted file mode 100644 index 2b6c915..0000000 --- a/resources/public/api/conf/1.0/examples/Totals.ByType.get.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "rti": { - "credit": 0.0, - "debit": 100.25 - }, - "non_rti": { - "credit": 0.0, - "debit": 100.35 - }, - "_links": { - "empRefs": { - "href": "/paye-for-employers/" - }, - "total": { - "href": "/paye-for-employers/001/AB00001/total" - } - } -} diff --git a/resources/public/api/conf/1.0/schemas/ChargesSummary.get.schema.json b/resources/public/api/conf/1.0/schemas/ChargesSummary.get.schema.json deleted file mode 100644 index 0d26856..0000000 --- a/resources/public/api/conf/1.0/schemas/ChargesSummary.get.schema.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "type": "object", - "properties": { - "rti": { - "type": "array", - "items": { - "type": "object", - "properties": { - "tax_year": { - "$ref": "Definitions.schema.json#/definitions/tax_year" - }, - "tax_month": { - "$ref": "Definitions.schema.json#/definitions/tax_month" - }, - "balance": { - "$ref": "Definitions.schema.json#/definitions/balance" - }, - "due_date": { - "$ref": "Definitions.schema.json#/definitions/due_date" - }, - "is_overdue": { - "$ref": "Definitions.schema.json#/definitions/is_overdue" - } - } - } - }, - "non_rti": { - "type": "array", - "items": { - "type": "object", - "properties": { - "charge_code": { - "$ref": "Definitions.schema.json#/definitions/charge_code" - }, - "balance": { - "$ref": "Definitions.schema.json#/definitions/balance" - }, - "tax_year": { - "$ref": "Definitions.schema.json#/definitions/tax_year" - }, - "due_date": { - "$ref": "Definitions.schema.json#/definitions/due_date" - }, - "is_overdue": { - "$ref": "Definitions.schema.json#/definitions/is_overdue" - } - } - } - } - } -} diff --git a/resources/public/api/conf/1.0/schemas/Definitions.schema.json b/resources/public/api/conf/1.0/schemas/Definitions.schema.json index 08cf561..7c3b582 100644 --- a/resources/public/api/conf/1.0/schemas/Definitions.schema.json +++ b/resources/public/api/conf/1.0/schemas/Definitions.schema.json @@ -1,73 +1,12 @@ { "definitions": { - "href": { + "date": { + "description": "A date representation with format YYYY-MM-DD", "type": "string", - "description": "URL to endpoint" - }, - "empRef": { - "type": "string", - "description": "A unique identifier made up of tax office number and tax office reference.", - "pattern": "^\\w{3}/\\w{7,10}" - }, - "epayeLinks": { - "type": "object", - "description": "An object of links to explore further data.", - "properties": { - "self": { - "type": "object", - "description": "Link to the entry endpoint.", - "properties": { - "href": { - "type": "string", - "description": "URL to endpoint" - } - } - } - } - }, - "empRefLinks": { - "type": "object", - "description": "An object of links to explore further data.", - "properties": { - "summary": { - "type": "object", - "description": "Link to account summary endpoint.", - "properties": { - "href": { - "type": "string", - "description": "Link to the summary endpoint." - } - } - } - } - }, - "links": { - "type": "object", - "description": "An object of links to explore further data.", - "properties": { - "total": { - "type": "object", - "description": "Link to total balance endpoint.", - "properties": { - "href": { - "type": "string", - "description": "Link to the entry endpoint." - } - } - }, - "empRefs": { - "type": "object", - "description": "Link to the entry endpoint endpoint.", - "properties": { - "href": { - "type": "string", - "description": "Link to the entry endpoint." - } - } - } - } + "pattern": "^(((19|20)([2468][048]|[13579][26]|0[48])|2000)[-]02[-]29|((19|20)[0-9]{2}[-](0[469]|11)[-](0[1-9]|[11][0-9]|30)|(19|20)[0-9]{2}[-](0[13578]|1[02])[-](0[1-9]|[12][0-9]|3[01])|(19|20)[0-9]{2}[-]02[-](0[1-9]|1[0-9]|2[0-8])))$", + "example": "2017-05-05" }, - "tax_year": { + "taxYear": { "type": "object", "description": "Tax year", "title": "The tax year for this data", @@ -77,118 +16,51 @@ "description": "The tax year", "pattern": "^\\d{4}-\\d{2}" }, - "first_day": { - "type": "string", - "description": "The first day of the tax year" + "firstDay": { + "description": "The first day of the tax year", + "$ref": "#/definitions/date" }, - "last_day": { - "type": "string", - "description": "The last day of the tax year" + "lastDay": { + "description": "The last day of the tax year", + "$ref": "#/definitions/date" } } }, - "tax_month": { + "taxMonth": { "type": "object", "description": "Tax month", "title": "The tax month for this data", "properties": { "number": { + "description": "The tax month's number", "type": "integer", - "description": "The tax month's number" + "minimum": 1, + "maximum": 12 }, - "first_day": { - "type": "string", - "description": "The first day of the tax month" + "firstDay": { + "description": "The first day of the tax month", + "$ref": "#/definitions/date" }, - "last_day": { - "type": "string", - "description": "The last day of the tax month" + "lastDay": { + "description": "The last day of the tax month", + "$ref": "#/definitions/date" } } }, - "outstandingCharges": { + "link": { "type": "object", - "description": "The outstanding charges on account.", + "description": "Link to a given endpoint.", "properties": { - "amount": { - "type": "number", - "description": "The outstanding charges on account." - } , - "breakdown": { - "type": "object", - "description": "The breakdown of outstanding charges.", - "properties": { - "rti": { - "type": "number", - "description": "The outstanding RTI charges on account." - }, - "nonRti": { - "type": "number", - "description": "The outstanding Non-RTI charges on account." - } - } - } - } - }, - "balance": { - "type": "object", - "description": "The currently outstanding balance on account.", - - "properties": { - "credit": { - "$ref": "#/definitions/credit" - }, - "debit": { - "$ref": "#/definitions/debit" - } - } - }, - "summaryLinks": { - "type": "object", - "description": "An object of links to explore further data.", - "properties": { - "self": { - "type": "object", - "description": "Link to account summary endpoint.", - "properties": { - "href": { - "type": "string", - "description": "Link account summary endpoint." - } - } - }, - "empRefs": { - "type": "object", - "description": "Link to the entry endpoint endpoint.", - "properties": { - "href": { - "type": "string", - "description": "Link to the entry endpoint." - } - } + "href": { + "description": "Uri of the endpoint.", + "type": "string" } } }, - "credit": { - "type": "number", - "description": "The current credits on your account.", - "default": 0 - }, - "debit": { - "type": "number", - "description": "The current debits on your account including interest.", - "default": 0 - }, - "due_date": { + "empRef": { "type": "string", - "description": "The date this item is due", - "pattern": "^\\d{4}-\\d{2}-\\d{2}$", - "example": "2017-05-05" - }, - "is_overdue": { - "type": "boolean", - "description": "Whether this item is overdue or not", - "default": false + "description": "A unique identifier made up of tax office number and tax office reference.", + "pattern": "^\\w{3}/\\w{7,10}" }, "charge_code": { "type": "string", @@ -276,6 +148,76 @@ "NON_RTI_STUDENT_LOAN_DEDUCTION_INTEREST", "NON_RTI_TAX_INTEREST" ] + }, + + "dueDate": { + "$ref": "#/definitions/date", + "description": "The date this item is due" + }, + "is_overdue": { + "type": "boolean", + "description": "Whether this item is overdue or not", + "default": false + }, + + "outstandingCharges": { + "type": "object", + "description": "The outstanding charges on account.", + "properties": { + "amount": { + "type": "number", + "description": "The outstanding charges on account." + }, + "breakdown": { + "type": "object", + "description": "The breakdown of outstanding charges.", + "properties": { + "rti": { + "type": "number", + "description": "The outstanding RTI charges on account." + }, + "nonRti": { + "type": "number", + "description": "The outstanding Non-RTI charges on account." + } + } + } + } + }, + + "epayeLinks": { + "type": "object", + "description": "An object of links to explore further data.", + "properties": { + "self": { + "description": "Link to the entry endpoint.", + "$ref": "#/definitions/link" + } + } + }, + "empRefLinks": { + "type": "object", + "description": "An object of links to explore further data.", + "properties": { + "summary": { + "description": "Link to account summary endpoint.", + "$ref": "#/definitions/link" + } + } + }, + "summaryLinks": { + "type": "object", + "description": "An object of links to explore further data.", + "properties": { + "self": { + "description": "Link to account summary endpoint.", + "$ref": "#/definitions/link" + }, + "empRefs": { + "description": "Link to the entry endpoint endpoint.", + "$ref": "#/definitions/link" + } + } } } } diff --git a/resources/public/api/conf/1.0/schemas/Totals.ByType.get.schema.json b/resources/public/api/conf/1.0/schemas/Totals.ByType.get.schema.json deleted file mode 100644 index a819ede..0000000 --- a/resources/public/api/conf/1.0/schemas/Totals.ByType.get.schema.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "object", - "description": "An object containing the outstanding debits and credits.", - "properties": { - "_links": { - "$ref": "Definitions.schema.json#/definitions/links" - }, - "non_rti": { - "type": "object", - "description": "The outstanding Non-RTI balance", - "properties": { - "credit": {"$ref": "Definitions.schema.json#/definitions/credit"}, - "debit": {"$ref": "Definitions.schema.json#/definitions/debit"} - } - }, - "rti": { - "type": "object", - "description": "The outstanding RTI balance", - "properties": { - "credit": {"$ref": "Definitions.schema.json#/definitions/credit"}, - "debit": {"$ref": "Definitions.schema.json#/definitions/debit"} - } - } - } -} diff --git a/test/uk/gov/hmrc/epayeapi/Fixtures.scala b/test/uk/gov/hmrc/epayeapi/Fixtures.scala deleted file mode 100644 index 81fd0db..0000000 --- a/test/uk/gov/hmrc/epayeapi/Fixtures.scala +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi - - -import org.joda.time.LocalDate -import uk.gov.hmrc.epayeapi.models.api._ - -object Fixtures { - def rtiCharge( - taxYear: TaxYear, - taxMonth: Option[TaxMonth] = None, - debit: BigDecimal = 0, - credit: BigDecimal = 0, - dueDate: Option[LocalDate] = None, - isOverdue: Boolean = false - ): RtiCharge = { - RtiCharge( - tax_year = taxYear, - tax_month = taxMonth, - balance = DebitCredit(debit = debit, credit = credit), - due_date = dueDate, - is_overdue = isOverdue - ) - } - - def nonRtiCharge( - chargeCode: String = "NON_RTI_SPECIFIED_CHARGE", - taxYear: TaxYear = TaxYear.fromTaxYear(models.TaxYear(2016)), - debit: BigDecimal = 0, - credit: BigDecimal = 0, - dueDate: Option[LocalDate] = None, - isOverdue: Boolean = false - ): NonRtiCharge = { - NonRtiCharge( - charge_code = chargeCode, - tax_year = taxYear, - balance = DebitCredit(debit = debit, credit = credit), - due_date = dueDate, - is_overdue = isOverdue - ) - } -} diff --git a/test/uk/gov/hmrc/epayeapi/connectors/ConnectorSpec.scala b/test/uk/gov/hmrc/epayeapi/connectors/ConnectorSpec.scala index f1ee0ad..6822763 100644 --- a/test/uk/gov/hmrc/epayeapi/connectors/ConnectorSpec.scala +++ b/test/uk/gov/hmrc/epayeapi/connectors/ConnectorSpec.scala @@ -21,15 +21,14 @@ import org.scalatest.concurrent.ScalaFutures import org.scalatest.mock.MockitoSugar import play.api.http.Status import play.api.libs.json.{JsError, JsPath, Json} -import uk.gov.hmrc.epayeapi.models.api._ +import uk.gov.hmrc.epayeapi.models.in._ import uk.gov.hmrc.play.http.{HeaderCarrier, HttpGet, HttpResponse} import uk.gov.hmrc.play.test.UnitSpec import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future.{failed, successful} -import scala.concurrent.duration.FiniteDuration -import scala.concurrent.{ExecutionContext, Future} import scala.concurrent.duration._ +import scala.concurrent.{ExecutionContext, Future} case class TestData(num: Int) object TestData { diff --git a/test/uk/gov/hmrc/epayeapi/connectors/EpayeConnectorSpec.scala b/test/uk/gov/hmrc/epayeapi/connectors/EpayeConnectorSpec.scala index debd672..54cb0ad 100644 --- a/test/uk/gov/hmrc/epayeapi/connectors/EpayeConnectorSpec.scala +++ b/test/uk/gov/hmrc/epayeapi/connectors/EpayeConnectorSpec.scala @@ -23,7 +23,7 @@ import org.scalatest.mock.MockitoSugar import play.api.http.Status import uk.gov.hmrc.domain.EmpRef import uk.gov.hmrc.epayeapi.models._ -import uk.gov.hmrc.epayeapi.models.api.ApiSuccess +import uk.gov.hmrc.epayeapi.models.in._ import uk.gov.hmrc.play.http.ws.WSHttp import uk.gov.hmrc.play.http.{HeaderCarrier, HttpResponse} import uk.gov.hmrc.play.test.UnitSpec @@ -81,19 +81,6 @@ class EpayeConnectorSpec extends UnitSpec with MockitoSugar with ScalaFutures { ) ) } - "retrieve the total by type for a given empRef" in new Setup { - when(connector.http.GET(urlTotalsByType)).thenReturn { - successful { - HttpResponse(Status.OK, responseString = Some(""" { "rti": {"credit": 100, "debit": 0}, "nonRti": {"credit": 100, "debit": 0} } """)) - } - } - - connector.getTotalsByType(empRef, hc).futureValue shouldBe - ApiSuccess(AggregatedTotalsByType( - rti = AggregatedTotals(credit = 100, debit = 0), - nonRti = AggregatedTotals(credit = 100, debit = 0) - )) - } "retrieve summary for a given empRef" in new Setup { when(connector.http.GET(urlAnnualStatement)).thenReturn { successful { diff --git a/test/uk/gov/hmrc/epayeapi/controllers/AnnualSummarySpec.scala b/test/uk/gov/hmrc/epayeapi/controllers/AnnualSummarySpec.scala deleted file mode 100644 index dfa65d3..0000000 --- a/test/uk/gov/hmrc/epayeapi/controllers/AnnualSummarySpec.scala +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.controllers - -import org.joda.time.LocalDate -import org.mockito.Matchers._ -import org.mockito.Mockito.{reset, when} -import org.scalatest.BeforeAndAfterEach -import play.api.Application -import play.api.inject.bind -import play.api.libs.json.JsSuccess -import play.api.mvc.Result -import play.api.test.FakeRequest -import play.api.test.Helpers._ -import uk.gov.hmrc.auth.core.{ConfidenceLevel, Enrolment, EnrolmentIdentifier} -import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models._ -import uk.gov.hmrc.epayeapi.models.api.{ChargesSummary, DebitCredit, NonRtiCharge, RtiCharge} -import uk.gov.hmrc.play.http.ws.WSHttp -import uk.gov.hmrc.play.http.{HeaderCarrier, HttpResponse} -import unit.AppSpec -import unit.auth.AuthComponents.AuthOk - -import scala.concurrent.Future -import scala.concurrent.Future.successful - -class AnnualSummarySpec extends AppSpec with BeforeAndAfterEach { - val ton = EnrolmentIdentifier("TaxOfficeNumber", "840") - val tor = EnrolmentIdentifier("TaxOfficeReference", "GZ00064") - val empRef = EmpRef(ton.value, tor.value) - - implicit val hc = HeaderCarrier() - val http = mock[WSHttp] - - val app = builder - .update(_.overrides(bind(classOf[WSHttp]).toInstance(http))) - - val activeEnrolment = - AuthOk(Enrolment("IR-PAYE", Seq(ton, tor), "activated", ConfidenceLevel.L300)) - - val inactiveEnrolment = - AuthOk(activeEnrolment.data.copy(state = "inactive")) - - val differentEnrolment = - AuthOk(Enrolment("IR-Else", Seq(ton, tor), "activated", ConfidenceLevel.L300)) - - def request(implicit a: Application): Future[Result] = - inject[AnnualSummaryController].getAnnualSummary(empRef, None)(FakeRequest()) - - override protected def beforeEach(): FixtureParam = { - reset(http) - } - - "The AnnualSummary endpoint" should { - "return 200 OK on active enrolments" in new App(app.withAuth(activeEnrolment).build) { - when(http.GET[HttpResponse](anyString)(anyObject(), anyObject())).thenReturn { - successful { - HttpResponse(200, responseString = Some(JsonFixtures.annualStatements.annualStatement)) - } - } - val taxYear = TaxYear(2017) - val taxMonth = TaxMonth(1) - - contentAsJson(request).validate[ChargesSummary] shouldBe JsSuccess { - ChargesSummary( - List(RtiCharge( - tax_year = api.TaxYear.fromTaxYear(taxYear), - tax_month = Some(api.TaxMonth.fromTaxMonth(taxMonth, taxYear)), - balance = DebitCredit(100.2, 0), - due_date = Some(new LocalDate(2017, 5, 22)), - is_overdue = true - )), - List( - NonRtiCharge( - "P11D_CLASS_1A_CHARGE", - tax_year = api.TaxYear.fromTaxYear(taxYear), - balance = DebitCredit(20.0, 0), - due_date = Some(new LocalDate(2018, 2, 22)), - is_overdue = false - ) - ) - ) - } - - status(request) shouldBe OK - } - "return 403 Forbidden on inactive enrolments" in new App(app.withAuth(inactiveEnrolment).build) { - status(request) shouldBe FORBIDDEN - } - "return 403 Forbidden with different enrolments" in new App(app.withAuth(differentEnrolment).build) { - status(request) shouldBe FORBIDDEN - } - } - -} diff --git a/test/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsSpec.scala b/test/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsSpec.scala index 2234f66..a627140 100644 --- a/test/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsSpec.scala +++ b/test/uk/gov/hmrc/epayeapi/controllers/GetEmpRefsSpec.scala @@ -16,18 +16,15 @@ package uk.gov.hmrc.epayeapi.controllers -import akka.stream.Materializer -import akka.util.ByteString import play.api.Application import play.api.libs.json.Json -import play.api.libs.streams.Accumulator import play.api.mvc.Result import play.api.test.FakeRequest import play.api.test.Helpers._ import uk.gov.hmrc.auth.core._ import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.models.{ApiError, EmpRefsResponse} import uk.gov.hmrc.epayeapi.models.Formats._ +import uk.gov.hmrc.epayeapi.models.out.{ApiError, EmpRefsResponse} import unit.AppSpec import unit.auth.AuthComponents.{AuthFail, AuthOk} diff --git a/test/uk/gov/hmrc/epayeapi/controllers/GetTotalsByTypeSpec.scala b/test/uk/gov/hmrc/epayeapi/controllers/GetTotalsByTypeSpec.scala deleted file mode 100644 index 4fe937c..0000000 --- a/test/uk/gov/hmrc/epayeapi/controllers/GetTotalsByTypeSpec.scala +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.controllers - -import org.mockito.Matchers._ -import org.mockito.Mockito.{reset, when} -import org.scalatest.BeforeAndAfterEach -import play.api.Application -import play.api.inject.bind -import play.api.mvc.Result -import play.api.test.FakeRequest -import play.api.test.Helpers._ -import uk.gov.hmrc.auth.core.{ConfidenceLevel, Enrolment, EnrolmentIdentifier} -import uk.gov.hmrc.domain.EmpRef -import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models.TotalsByTypeResponse -import uk.gov.hmrc.play.http.ws.WSHttp -import uk.gov.hmrc.play.http.{HeaderCarrier, HttpResponse} -import unit.AppSpec -import unit.auth.AuthComponents.AuthOk -import play.api.libs.json.Json - -import scala.concurrent.Future -import scala.concurrent.Future.successful - -class GetTotalsByTypeSpec extends AppSpec with BeforeAndAfterEach { - val ton = EnrolmentIdentifier("TaxOfficeNumber", "840") - val tor = EnrolmentIdentifier("TaxOfficeReference", "GZ00064") - val empRef = EmpRef(ton.value, tor.value) - - implicit val hc = HeaderCarrier() - val http = mock[WSHttp] - - val app = builder - .update(_.overrides(bind(classOf[WSHttp]).toInstance(http))) - - val activeEnrolment = - AuthOk(Enrolment("IR-PAYE", Seq(ton, tor), "activated", ConfidenceLevel.L300)) - - val inactiveEnrolment = - AuthOk(activeEnrolment.data.copy(state = "inactive")) - - val differentEnrolment = - AuthOk(Enrolment("IR-Else", Seq(ton, tor), "activated", ConfidenceLevel.L300)) - - def request(implicit a: Application): Future[Result] = - inject[GetTotalsByTypeController].getTotalsByType(empRef)(FakeRequest()) - - override protected def beforeEach(): FixtureParam = { - reset(http) - } - - "The Totals By Type endpoint" should { - "return 200 OK on active enrolments" in new App(app.withAuth(activeEnrolment).build) { - when(http.GET[HttpResponse](anyString)(anyObject(), anyObject())).thenReturn { - successful { - HttpResponse(200, responseString = Some(""" { "rti": {"credit": 100, "debit": 0}, "nonRti": {"credit": 0, "debit": 100} } """)) - } - } - contentAsString(request) shouldBe Json.parse( - s""" - |{"rti":{"credit":100,"debit":0}, - |"non_rti":{"credit":0,"debit":100}, - |"_links":{ - |"empRefs": {"href":"/organisation/paye/"}, - |"self":{"href":"/organisation/paye/${ton.value}/${tor.value}/"}}} - """.stripMargin).toString - status(request) shouldBe OK - } - "return 500 Internal Server Error and error message body when incorrect json format" in new App(app.withAuth(activeEnrolment).build) { - when(http.GET[HttpResponse](anyString)(anyObject(), anyObject())).thenReturn { - successful { - HttpResponse(200, responseString = Some(""" { "rtix": {"credit": 100, "debit": 0} } """)) - } - } - contentAsString(request) shouldBe - """{"code":"INTERNAL_SERVER_ERROR","message":"We are currently experiencing problems. Please try again later."}""" - status(request) shouldBe INTERNAL_SERVER_ERROR - } - "return 403 Forbidden on inactive enrolments" in new App(app.withAuth(inactiveEnrolment).build) { - status(request) shouldBe FORBIDDEN - } - "return 403 Forbidden with different enrolments" in new App(app.withAuth(differentEnrolment).build) { - status(request) shouldBe FORBIDDEN - } - } - -} diff --git a/test/uk/gov/hmrc/epayeapi/models/ChargesSummarySpec.scala b/test/uk/gov/hmrc/epayeapi/models/ChargesSummarySpec.scala deleted file mode 100644 index 5be279e..0000000 --- a/test/uk/gov/hmrc/epayeapi/models/ChargesSummarySpec.scala +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2017 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 uk.gov.hmrc.epayeapi.models - -import org.joda.time.LocalDate -import org.scalatest.{Matchers, WordSpec} -import play.api.libs.json.{JsSuccess, Json} -import uk.gov.hmrc.epayeapi.Fixtures -import uk.gov.hmrc.epayeapi.models.Formats._ -import uk.gov.hmrc.epayeapi.models.api.ChargesSummary - -import scala.io.Source - -class ChargesSummarySpec extends WordSpec with Matchers { - "charges summary object" should { - "convert to json" in { - val taxYear = TaxYear(2016) - val summary = ChargesSummary( - rti = Seq( - Fixtures.rtiCharge( - taxYear = api.TaxYear.fromTaxYear(taxYear), - taxMonth = Some(api.TaxMonth.fromTaxMonth(TaxMonth(3), taxYear)), - debit = 1200, - dueDate = Some(new LocalDate(2016, 10, 22)), - isOverdue = true - ), - Fixtures.rtiCharge( - taxYear = api.TaxYear.fromTaxYear(taxYear), - taxMonth = Some(api.TaxMonth.fromTaxMonth(TaxMonth(4), taxYear)), - debit = 1300.0, - dueDate = Some(new LocalDate(2016, 11, 22)), - isOverdue = true - ), - Fixtures.rtiCharge( - taxYear = api.TaxYear.fromTaxYear(taxYear), - taxMonth = Some(api.TaxMonth.fromTaxMonth(TaxMonth(5), taxYear)), - debit = 1200.0, - dueDate = Some(new LocalDate(2016, 10, 22)), - isOverdue = true - ) - ), - non_rti = Seq( - Fixtures.nonRtiCharge( - chargeCode = "NON_RTI_IN_YEAR_PAYE_LATE_FILING_PENALTY", - taxYear = api.TaxYear.fromTaxYear(taxYear), - debit = 1200, - dueDate = Some(new LocalDate(2016, 10, 22)), - isOverdue = true - ), - Fixtures.nonRtiCharge( - chargeCode = "NON_RTI_EOY_NIC1", - taxYear = api.TaxYear.fromTaxYear(taxYear), - credit = 800, - dueDate = Some(new LocalDate(2016, 10, 22)), - isOverdue = true - ) - ) - ) - val summaryJson = Json.toJson(summary) - val exampleJson = Json.parse { - val resource = getClass.getResource(s"/public/api/conf/1.0/examples/ChargesSummary.get.json") - Source.fromURL(resource, "utf-8").mkString("") - } - - Json.prettyPrint(summaryJson).toString shouldEqual Json.prettyPrint(exampleJson).toString - exampleJson.validate[ChargesSummary] shouldEqual JsSuccess(summary) - } - } -} diff --git a/test/uk/gov/hmrc/epayeapi/models/TaxMonthSpec.scala b/test/uk/gov/hmrc/epayeapi/models/in/TaxMonthSpec.scala similarity index 97% rename from test/uk/gov/hmrc/epayeapi/models/TaxMonthSpec.scala rename to test/uk/gov/hmrc/epayeapi/models/in/TaxMonthSpec.scala index 0f8dbe5..734c519 100644 --- a/test/uk/gov/hmrc/epayeapi/models/TaxMonthSpec.scala +++ b/test/uk/gov/hmrc/epayeapi/models/in/TaxMonthSpec.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.in import org.joda.time.LocalDate import org.scalatest.{Matchers, WordSpec} diff --git a/test/uk/gov/hmrc/epayeapi/models/TaxYearSpec.scala b/test/uk/gov/hmrc/epayeapi/models/in/TaxYearSpec.scala similarity index 97% rename from test/uk/gov/hmrc/epayeapi/models/TaxYearSpec.scala rename to test/uk/gov/hmrc/epayeapi/models/in/TaxYearSpec.scala index 117dba6..a8c0f06 100644 --- a/test/uk/gov/hmrc/epayeapi/models/TaxYearSpec.scala +++ b/test/uk/gov/hmrc/epayeapi/models/in/TaxYearSpec.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.in import org.scalatest.{Matchers, WordSpec} import TaxYear.extractTaxYear diff --git a/test/uk/gov/hmrc/epayeapi/models/LinkSpecs.scala b/test/uk/gov/hmrc/epayeapi/models/out/LinkSpecs.scala similarity index 96% rename from test/uk/gov/hmrc/epayeapi/models/LinkSpecs.scala rename to test/uk/gov/hmrc/epayeapi/models/out/LinkSpecs.scala index 18f7ece..d477aab 100644 --- a/test/uk/gov/hmrc/epayeapi/models/LinkSpecs.scala +++ b/test/uk/gov/hmrc/epayeapi/models/out/LinkSpecs.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package uk.gov.hmrc.epayeapi.models +package uk.gov.hmrc.epayeapi.models.out import uk.gov.hmrc.domain.EmpRef import uk.gov.hmrc.play.test.UnitSpec