Skip to content

Commit

Permalink
Merge pull request #487 from hmrc/API-7563
Browse files Browse the repository at this point in the history
API-7563: return grant-length as a Period-style format eg P547D
  • Loading branch information
mi-akram authored Apr 16, 2024
2 parents 58a2feb + e6486bc commit 87d4fa7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package uk.gov.hmrc.thirdpartyapplication.models

import java.time.Period

import play.api.libs.functional.syntax._
import play.api.libs.json._

Expand Down Expand Up @@ -46,8 +48,10 @@ trait JsonFormatters extends UtcMillisDateTimeFormatters {

implicit val formatApplicationState: OFormat[ApplicationState] = Json.format[ApplicationState]

implicit val formatUpdateApplicationRequest: OFormat[UpdateApplicationRequest] = Json.format[UpdateApplicationRequest]
implicit val formatApplicationResponse: OFormat[Application] = Json.format[Application]
implicit val formatUpdateApplicationRequest: OFormat[UpdateApplicationRequest] = Json.format[UpdateApplicationRequest]
implicit val writesGrantLength: Writes[GrantLength] = implicitly[Writes[Period]].contramap(gl => gl.period)
implicit val formatApplicationResponse: OFormat[Application] = Json.format[Application]

implicit val formatExtendedApplicationResponse: OFormat[ExtendedApplicationResponse] = Json.format[ExtendedApplicationResponse]
implicit val formatPaginatedApplicationResponse: OFormat[PaginatedApplicationResponse] = Json.format[PaginatedApplicationResponse]
implicit val formatUpdateIpAllowlistRequest: OFormat[UpdateIpAllowlistRequest] = Json.format[UpdateIpAllowlistRequest]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,42 +487,6 @@ class ApplicationRepository @Inject() (mongo: MongoComponent, val metrics: Metri
}
}

/*
db.application.aggregate( [
{
$match:
{
"collaborators.userId" : "85682eda-5758-4a13-8b97-057c94b3657b"
}
},
{
$lookup:
{
from: "subscription",
localField: "id",
foreignField: "applications",
as: "subs"
}
},
{
$project:
{
_id: 0,
"apiIdentifier": "$subs.apiIdentifier"
}
},
{
$unwind: "$apiIdentifier"
},
{
$project: {
_id: 0,
"context": "$apiIdentifier.context",
"version": "$apiIdentifier.version"
}
}
] )
*/
def getSubscriptionsForDeveloper(userId: UserId): Future[Set[ApiIdentifier]] = {
timeFuture("Get Subscriptions for Developer", "application.repository.getSubscriptionsForDeveloper") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ trait ControllerTestData extends CollaboratorTestData with FixedClock {
appId: ApplicationId = ApplicationId.random,
state: ApplicationState = ApplicationState(State.TESTING, updatedOn = instant)
) = {
val grantLengthInDays = GrantLength.EIGHTEEN_MONTHS
val grantLength = GrantLength.EIGHTEEN_MONTHS
new Application(
appId,
ClientId("clientId"),
Expand All @@ -67,7 +67,7 @@ trait ControllerTestData extends CollaboratorTestData with FixedClock {
collaborators,
instant,
Some(instant),
grantLengthInDays,
grantLength,
None,
standardAccess.redirectUris,
standardAccess.termsAndConditionsUrl,
Expand Down

0 comments on commit 87d4fa7

Please sign in to comment.