Skip to content

Commit

Permalink
Capture campaign referrer at signup and remove from assistance details
Browse files Browse the repository at this point in the history
model.
  • Loading branch information
benjstephenson committed Jan 3, 2017
1 parent e3b83ed commit 5fefe38
Show file tree
Hide file tree
Showing 85 changed files with 152 additions and 159 deletions.
2 changes: 1 addition & 1 deletion app/binders/UniqueIdentifierBinder.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/config/frontendAppConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/config/frontendGlobal.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/config/frontendWiring.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/connectors/AllocationExchangeObjects.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
43 changes: 21 additions & 22 deletions app/connectors/ApplicationClient.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down Expand Up @@ -42,55 +42,56 @@ trait ApplicationClient {
import ExchangeObjects.Implicits._
import config.FrontendAppConfig.fasttrackConfig._

def createApplication(userId: UniqueIdentifier, frameworkId: String)(implicit hc: HeaderCarrier) = {
def createApplication(userId: UniqueIdentifier, frameworkId: String)
(implicit hc: HeaderCarrier): Future[ApplicationResponse] = {

http.PUT(s"${url.host}${url.base}/application/create", CreateApplicationRequest(userId, frameworkId)).map { response =>
response.json.as[ApplicationResponse]
}
}

def submitApplication(userId: UniqueIdentifier, applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = {
def submitApplication(userId: UniqueIdentifier, applicationId: UniqueIdentifier)
(implicit hc: HeaderCarrier): Future[Unit] = {
http.PUT(s"${url.host}${url.base}/application/submit/$userId/$applicationId", Json.toJson("")).map {
case x: HttpResponse if x.status == OK => ()
}.recover {
case _: BadRequestException => throw new CannotSubmit()
}
}

def withdrawApplication(applicationId: UniqueIdentifier, reason: WithdrawApplicationRequest)(implicit hc: HeaderCarrier) = {
def withdrawApplication(applicationId: UniqueIdentifier, reason: WithdrawApplicationRequest)
(implicit hc: HeaderCarrier): Future[Unit] = {
http.PUT(s"${url.host}${url.base}/application/withdraw/$applicationId", Json.toJson(reason)).map {
case x: HttpResponse if x.status == OK => ()
}.recover {
case _: NotFoundException => throw new CannotWithdraw()
}
}

def addMedia(userId: UniqueIdentifier, media: String)(implicit hc: HeaderCarrier) = {
def addMedia(userId: UniqueIdentifier, media: String)(implicit hc: HeaderCarrier): Future[Unit] = {
http.PUT(s"${url.host}${url.base}/media/create", AddMedia(userId, media)).map {
case x: HttpResponse if x.status == CREATED => ()
} recover {
case _: BadRequestException => throw new CannotAddMedia()
}
}

def getApplicationProgress(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = {
def getApplicationProgress(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier): Future[ProgressResponse] = {
http.GET(s"${url.host}${url.base}/application/progress/$applicationId").map { response =>
response.json.as[ProgressResponse]
}
}

def findApplication(userId: UniqueIdentifier, frameworkId: String)(implicit hc: HeaderCarrier) = {
def findApplication(userId: UniqueIdentifier, frameworkId: String)(implicit hc: HeaderCarrier): Future[ApplicationResponse] = {
http.GET(s"${url.host}${url.base}/application/find/user/$userId/framework/$frameworkId").map { response =>
response.json.as[ApplicationResponse]
} recover {
case _: NotFoundException => throw new ApplicationNotFound()
}
}

def updateGeneralDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: GeneralDetailsForm.Data, email: String)(
implicit
hc: HeaderCarrier
) = {
def updateGeneralDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: GeneralDetailsForm.Data,
email: String)(implicit hc: HeaderCarrier): Future[Unit] = {

http.POST(
s"${url.host}${url.base}/personal-details/$userId/$applicationId",
Expand All @@ -113,18 +114,17 @@ trait ApplicationClient {
}
}

def findPersonalDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = {
def findPersonalDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier)
(implicit hc: HeaderCarrier): Future[GeneralDetailsExchange] = {
http.GET(s"${url.host}${url.base}/personal-details/$userId/$applicationId").map { response =>
response.json.as[GeneralDetailsExchange]
} recover {
case e: NotFoundException => throw new PersonalDetailsNotFound()
}
}

def updateAssistanceDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: AssistanceForm.Data)(
implicit
hc: HeaderCarrier
) = {
def updateAssistanceDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: AssistanceForm.Data)
(implicit hc: HeaderCarrier): Future[Unit] = {
http.PUT(
s"${url.host}${url.base}/assistance-details/$userId/$applicationId",
data.exchange
Expand All @@ -135,18 +135,17 @@ trait ApplicationClient {
}
}

def findAssistanceDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = {
def findAssistanceDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier)
(implicit hc: HeaderCarrier): Future[AssistanceDetailsExchange] = {
http.GET(s"${url.host}${url.base}/assistance-details/$userId/$applicationId").map { response =>
response.json.as[AssistanceDetailsExchange]
} recover {
case _: NotFoundException => throw new AssistanceDetailsNotFound()
}
}

def updateQuestionnaire(applicationId: UniqueIdentifier, sectionId: String, questionnaire: Questionnaire)(
implicit
hc: HeaderCarrier
) = {
def updateQuestionnaire(applicationId: UniqueIdentifier, sectionId: String, questionnaire: Questionnaire)
(implicit hc: HeaderCarrier): Future[Unit] = {
http.PUT(
s"${url.host}${url.base}/questionnaire/$applicationId/$sectionId",
questionnaire
Expand All @@ -157,7 +156,7 @@ trait ApplicationClient {
}
}

def updateReview(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = {
def updateReview(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier): Future[Unit] = {
http.PUT(
s"${url.host}${url.base}/application/review/$applicationId",
ReviewRequest(true)
Expand Down
10 changes: 3 additions & 7 deletions app/connectors/ExchangeObjects.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down Expand Up @@ -63,9 +63,7 @@ object ExchangeObjects {
guaranteedInterview: Option[String],
needsAdjustment: Option[String],
typeOfAdjustments: Option[List[String]],
otherAdjustments: Option[String],
campaignReferrer: Option[String],
campaignOther: Option[String]
otherAdjustments: Option[String]
)

case class AddMedia(userId: UniqueIdentifier, media: String)
Expand Down Expand Up @@ -219,9 +217,7 @@ object ExchangeObjects {
if (needsAssistance) { None } else data.guaranteedInterview,
Some(data.needsAdjustment),
if (data.needsAdjustment == "No") { None } else data.typeOfAdjustments,
adjustmentValid(data, data.otherAdjustments),
data.campaignReferrer,
data.campaignOther
adjustmentValid(data, data.otherAdjustments)
)
}

Expand Down
2 changes: 1 addition & 1 deletion app/connectors/SchemeClient.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/connectors/UserManagementClient.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/connectors/addresslookup/AddressLookupClient.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/connectors/addresslookup/AddressRecord.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/connectors/exchange/ProgressResponse.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/connectors/package.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ActivationController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Application.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
26 changes: 8 additions & 18 deletions app/controllers/AssistanceController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down Expand Up @@ -42,9 +42,7 @@ trait AssistanceController extends BaseController with ApplicationClient {
ad.guaranteedInterview,
ad.needsAdjustment.getOrElse(""),
ad.typeOfAdjustments,
ad.otherAdjustments,
ad.campaignReferrer,
ad.campaignOther
ad.otherAdjustments
))
Ok(views.html.application.assistance(form))
}.recover {
Expand All @@ -59,24 +57,16 @@ trait AssistanceController extends BaseController with ApplicationClient {
invalidForm =>
Future.successful(Ok(views.html.application.assistance(invalidForm))),
data => {
addMedia(user.user.userID, extractMediaReferrer(data)).flatMap { _ =>
updateAssistanceDetails(user.application.applicationId, user.user.userID, data).flatMap { _ =>
updateProgress()(_ => Redirect(routes.ReviewApplicationController.present()))
}.recover {
case e: AssistanceDetailsNotFound =>
Redirect(routes.HomeController.present()).flashing(danger("account.error"))
}
updateAssistanceDetails(user.application.applicationId, user.user.userID, data).flatMap { _ =>
updateProgress()(_ => Redirect(routes.ReviewApplicationController.present()))
}.recover {
case e: AssistanceDetailsNotFound =>
Redirect(routes.HomeController.present()).flashing(danger("account.error"))
}
}
)
}

private def extractMediaReferrer(data: AssistanceForm.Data): String = {
if (data.campaignReferrer.contains("Other") || data.campaignReferrer.contains("Careers fair")) {
data.campaignOther.getOrElse("")
} else {
data.campaignReferrer.getOrElse("")
}
}


}
2 changes: 1 addition & 1 deletion app/controllers/BaseController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/FastTrackApplication.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/HomeController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/LandingPageController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/LockAccountController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/OnlineTestController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/PasswordResetController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/QuestionnaireController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ReviewApplicationController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/SchemeController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/SignInController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 HM Revenue & Customs
* 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.
Expand Down
Loading

0 comments on commit 5fefe38

Please sign in to comment.