Skip to content

Commit

Permalink
Merge pull request #132 from hmrc/update-nrs-retrievals
Browse files Browse the repository at this point in the history
Updated NRS retrieval to use standard retrievals
  • Loading branch information
MarkAKelly authored Apr 24, 2018
2 parents 45ec6d9 + e27e1fd commit bfd1e90
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/uk/gov/hmrc/vatapi/models/NRSSubmission.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ case class IdentityData(internalId: Option[String] = None,
groupIdentifier: Option[String] = None,
credentialRole: Option[CredentialRole],
mdtpInformation: Option[MdtpInformation] = None,
itmpName: Option[ItmpName],
itmpName: ItmpName,
itmpDateOfBirth: Option[LocalDate] = None,
itmpAddress: Option[ItmpAddress],
itmpAddress: ItmpAddress,
affinityGroup: Option[AffinityGroup],
credentialStrength: Option[String] = None,
loginTimes: LoginTimes)
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/vatapi/resources/VatReturnsResource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object VatReturnsResource extends BaseResource {
private val connector = VatReturnsConnector
private val orchestrator = VatReturnsOrchestrator

def submitVatReturn(vrn: Vrn): Action[JsValue] = APIAction(vrn).async(parse.json) { implicit request =>
def submitVatReturn(vrn: Vrn): Action[JsValue] = APIAction(vrn, nrsRequired = true).async(parse.json) { implicit request =>
val receiptId = "Receipt-ID"
val receiptTimestamp = "Receipt-Timestamp"
val receiptSignature = "Receipt-Signature"
Expand Down
8 changes: 3 additions & 5 deletions app/uk/gov/hmrc/vatapi/services/AuthorisationService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ trait AuthorisationService {
ec: ExecutionContext): Future[AuthResult] = {
import Retrievals._

val individualName = OptionalRetrieval(itmpName.propertyNames.head, itmpName.reads)
val individualAddress = OptionalRetrieval(itmpAddress.propertyNames.head, itmpAddress.reads)

logger.debug(s"[AuthorisationService] [authoriseAsClientWithNrsRequirement] Check user authorisation for MTD VAT based on VRN $vrn.")
apiAuthorisedFunctions.authorised(
RawJsonPredicate(JsArray(Seq(Json.toJson(Enrolment(vatAuthEnrolments.enrolmentToken).withIdentifier(vatAuthEnrolments.identifier, vrn.vrn)
Expand All @@ -98,7 +95,7 @@ trait AuthorisationService {
and internalId and externalId and agentCode and credentials
and confidenceLevel and nino and saUtr and name and dateOfBirth
and email and agentInformation and groupIdentifier and credentialRole
and mdtpInformation and individualName and itmpDateOfBirth and individualAddress
and mdtpInformation and itmpName and itmpDateOfBirth and itmpAddress
and credentialStrength and loginTimes
) {
case affGroup ~ enrolments ~ inId ~ exId ~ agCode ~ creds
Expand Down Expand Up @@ -131,8 +128,9 @@ trait AuthorisationService {
case _: InsufficientConfidenceLevel =>
logger.warn(s"[AuthorisationService] [unauthorisedError] Client authorisation failed due to unsupported insufficient confidenceLevels.")
Future.successful(Left(Forbidden(toJson(Errors.ClientOrAgentNotAuthorized))))
case _: JsResultException =>
case ex: JsResultException =>
logger.warn(s"[AuthorisationService] [unauthorisedError] - Did not receive minimum data from Auth required for NRS Submission")
println(ex)
Future.successful(Left(Forbidden(toJson(Errors.InternalServerError))))
case exception@_ =>
logger.warn(s"[AuthorisationService] [unauthorisedError] Client authorisation failed due to internal server error. auth-client exception was ${exception.getClass.getSimpleName}")
Expand Down
8 changes: 4 additions & 4 deletions test/uk/gov/hmrc/vatapi/assets/TestConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ object TestConstants {
),
groupIdentifier = Some("testGroupId-840cf4e3-c8ad-48f4-80fd-ea267f916be5"),
credentialRole = Some(User),
itmpName = Some(ItmpName(
itmpName = ItmpName(
givenName = Some("a"),
middleName = Some("b"),
familyName = Some("c")
)),
itmpAddress = Some(ItmpAddress(
),
itmpAddress = ItmpAddress(
line1 = Some("1"),
line2 = Some("2"),
line3 = Some("3"),
Expand All @@ -66,7 +66,7 @@ object TestConstants {
postCode = Some("cw93nm"),
countryName = Some("uk"),
countryCode = Some("uk")
)),
),
affinityGroup = Some(AffinityGroup.Organisation),
credentialStrength = Some("strong"),
loginTimes = LoginTimes(
Expand Down

0 comments on commit bfd1e90

Please sign in to comment.