Skip to content

Commit

Permalink
Merge pull request #970 from hmrc/DL-8837-3
Browse files Browse the repository at this point in the history
add getFinancialData and financialDetails objects to models
  • Loading branch information
scott-goodwin authored Dec 14, 2022
2 parents 2d0d64e + 86c3488 commit 6c9aed4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ case class FinancialDataResponse(totalisation: Option[Totalisation],
documentDetails: Option[Seq[DocumentDetail]])

object FinancialDataResponse {
implicit val format: OFormat[FinancialDataResponse] = Json.format[FinancialDataResponse]
}
implicit val reads: Reads[FinancialDataResponse] = (
(JsPath \ "getFinancialData" \ "financialDetails" \ "totalisation").readNullable[Totalisation] and
(JsPath \ "getFinancialData" \ "financialDetails" \ "documentDetails").readNullable[Seq[DocumentDetail]]
)(FinancialDataResponse.apply _)

implicit val writes: OWrites[FinancialDataResponse] = Json.writes[FinancialDataResponse]}

case class FinancialDataErrors(
failures: List[FinancialDataError]
Expand Down
13 changes: 9 additions & 4 deletions test/v1/connectors/httpparsers/FinancialDataHttpParserSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ class FinancialDataHttpParserSpec extends UnitSpec {
"return Left(InvalidJson)" in {

val jsonObject =
Json.parse("""
| "totalisations" {
| "test": "test"
| }
Json.parse("""{
| "getFinancialData": {
| "financialDetails": {
| "documentDetails": {
| "test": "test"
| }
| }
| }
|}
|""".stripMargin)

val result = FinancialDataHttpReads.read("", "",
Expand Down
8 changes: 6 additions & 2 deletions test/v1/constants/FinancialDataConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ object FinancialDataConstants {
val testDownstreamFinancialDetailsNoDocumentDetails: JsValue = {
Json.parse(
"""{
|"getFinancialData": {
|"financialDetails": {
| "totalisation": {
| "regimeTotalisation": {
| "totalAccountOverdue": 1000.00,
Expand All @@ -68,14 +70,16 @@ object FinancialDataConstants {
| "totalAccountAccruingInterest": 100
| }
| }
|}
|}}}
|""".stripMargin
)
}

val testDownstreamFinancialDetails: JsValue = {
Json.parse(
"""{
|"getFinancialData": {
|"financialDetails": {
| "totalisation": {
| "regimeTotalisation": {
| "totalAccountOverdue": 1000.00,
Expand Down Expand Up @@ -161,7 +165,7 @@ object FinancialDataConstants {
| ]
| }
| ]
|}
|}}}
|""".stripMargin
)
}
Expand Down

0 comments on commit 6c9aed4

Please sign in to comment.