From 88040c9577e1cd935247e814a29bcf6be30a29d0 Mon Sep 17 00:00:00 2001 From: Alen Mujezinovic Date: Wed, 28 Jun 2017 16:41:29 +0100 Subject: [PATCH] Updated schema for totals endpoint --- .../hmrc/epayeapi/models/TotalsResponse.scala | 3 +- .../public/api/conf/1.0/application.raml | 26 ++++++ .../conf/1.0/examples/Totals.get.array.json | 40 --------- .../api/conf/1.0/examples/Totals.get.json | 10 +++ .../1.0/schemas/Totals.get.schema.array.json | 90 ------------------- .../conf/1.0/schemas/Totals.get.schema.json | 30 +++++++ 6 files changed, 67 insertions(+), 132 deletions(-) delete mode 100644 resources/public/api/conf/1.0/examples/Totals.get.array.json create mode 100644 resources/public/api/conf/1.0/examples/Totals.get.json delete mode 100644 resources/public/api/conf/1.0/schemas/Totals.get.schema.array.json create mode 100644 resources/public/api/conf/1.0/schemas/Totals.get.schema.json diff --git a/app/uk/gov/hmrc/epayeapi/models/TotalsResponse.scala b/app/uk/gov/hmrc/epayeapi/models/TotalsResponse.scala index a819659..9b7b3cd 100644 --- a/app/uk/gov/hmrc/epayeapi/models/TotalsResponse.scala +++ b/app/uk/gov/hmrc/epayeapi/models/TotalsResponse.scala @@ -20,7 +20,6 @@ import uk.gov.hmrc.domain.EmpRef import uk.gov.hmrc.epayeapi.models.domain.AggregatedTotals case class TotalsResponse( - empRef: EmpRef, credit: BigDecimal, debit: BigDecimal, _links: TotalsLinks @@ -28,7 +27,7 @@ case class TotalsResponse( object TotalsResponse { def apply(empRef: EmpRef, totals: AggregatedTotals): TotalsResponse = - TotalsResponse(empRef, totals.credit, totals.debit, TotalsLinks()) + TotalsResponse(totals.credit, totals.debit, TotalsLinks()) } case class TotalsLinks( diff --git a/resources/public/api/conf/1.0/application.raml b/resources/public/api/conf/1.0/application.raml index 0241d60..02b0c8b 100644 --- a/resources/public/api/conf/1.0/application.raml +++ b/resources/public/api/conf/1.0/application.raml @@ -56,3 +56,29 @@ types: "code" : "INSUFFICIENT_ENROLMENTS", "message" : "You are not currently enrolled for ePAYE" } + +/epaye/:EmpRef/total: + get: + is: [ headers.acceptHeader ] + displayName: Total balance + description: This resource returns the outstanding credits and debits on your account. + (annotations.scope): "read:epaye" + securedBy: [ sec.oauth_2_0: { scopes: [ "read:epaye" ] } ] + responses: + 200: + body: + application/json: + type: !include schemas/Totals.get.schema.json + example: !include examples/Totals.get.json + 401: + body: + application/json: + type: !include schemas/ErrorCodes.schema.json + examples: + notOpenStatus: + description: You don't have currently an ePAYE enrolment on this account. + value: | + { + "code" : "INSUFFICIENT_ENROLMENTS", + "message" : "You are not currently enrolled for ePAYE" + } diff --git a/resources/public/api/conf/1.0/examples/Totals.get.array.json b/resources/public/api/conf/1.0/examples/Totals.get.array.json deleted file mode 100644 index a1b3850..0000000 --- a/resources/public/api/conf/1.0/examples/Totals.get.array.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "results": [ - { - "identifier": "apprenticeshipLevy", - "references": [ - "22d2e724-92d4-4934-ab41-d6c72dfc109f", - "93c7b77e-e373-41a0-9da6-1b91e0a9202b" - ], - "name": "Apprenticeship Levy", - "outstandingAmount": 6670.77, - "accruedInterest": 41.66, - "totalAmount": 6712.43, - "dueDate": "2017-12-31", - "startDate": "2017-06-06", - "endDate": "2017-12-31", - "_links": { - "self": "/epaye/charges/apprenticeshipLevy" - } - }, - { - "identifier": "earlierYearUpdate", - "references": [ - "1636a208-c200-4c5d-9de7-46f3cbed0e2b" - ], - "name": "Earlier Year Updates", - "outstandingAmount": 999.99, - "accruedInterest": 0.0, - "totalAmount": 999.99, - "dueDate": "2017-12-31", - "startDate": "2017-06-06", - "endDate": "2017-12-31", - "_links": { - "self": "/epaye/charges/earlierYearUpdate" - } - } - ], - "_links": { - "self": "/epaye/charges/total" - } -} diff --git a/resources/public/api/conf/1.0/examples/Totals.get.json b/resources/public/api/conf/1.0/examples/Totals.get.json new file mode 100644 index 0000000..a26fd1d --- /dev/null +++ b/resources/public/api/conf/1.0/examples/Totals.get.json @@ -0,0 +1,10 @@ +{ + "empRef" : "840/GZ00064", + "credit" : 100, + "debit" : 0, + "_links" : { + "empRefs" : { + "href" : "/" + } + } +} diff --git a/resources/public/api/conf/1.0/schemas/Totals.get.schema.array.json b/resources/public/api/conf/1.0/schemas/Totals.get.schema.array.json deleted file mode 100644 index 384bb82..0000000 --- a/resources/public/api/conf/1.0/schemas/Totals.get.schema.array.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "definitions": {}, - "id": "http://example.com/example.json", - "properties": { - "page": { - "default": 1, - "description": "An explanation about the purpose of this instance.", - "title": "The Page Schema", - "type": "integer" - }, - "results": { - "items": { - "properties": { - "_links": { - "properties": { - "self": { - "default": "/epaye/charges/apprenticeshipLevy", - "description": "An explanation about the purpose of this instance.", - "title": "The Self Schema", - "type": "string" - } - }, - "type": "object" - }, - "accruedInterest": { - "default": 41.66, - "description": "An explanation about the purpose of this instance.", - "title": "The Accruedinterest Schema", - "type": "number" - }, - "dueDate": { - "default": "2017-12-31", - "description": "An explanation about the purpose of this instance.", - "title": "The Duedate Schema", - "type": "string" - }, - "endDate": { - "default": "2017-12-31", - "description": "An explanation about the purpose of this instance.", - "title": "The Enddate Schema", - "type": "string" - }, - "identifier": { - "default": "apprenticeshipLevy", - "description": "An explanation about the purpose of this instance.", - "title": "The Identifier Schema", - "type": "string" - }, - "name": { - "default": "Apprenticeship Levy", - "description": "An explanation about the purpose of this instance.", - "title": "The Name Schema", - "type": "string" - }, - "outstandingAmount": { - "default": 5458.77, - "description": "An explanation about the purpose of this instance.", - "title": "The Outstandingamount Schema", - "type": "number" - }, - "references": { - "items": { - "default": "22d2e724-92d4-4934-ab41-d6c72dfc109f", - "description": "An explanation about the purpose of this instance.", - "title": "The Empty Schema", - "type": "string" - }, - "type": "array" - }, - "startDate": { - "default": "2017-06-06", - "description": "An explanation about the purpose of this instance.", - "title": "The Startdate Schema", - "type": "string" - }, - "totalAmount": { - "default": 5500.43, - "description": "An explanation about the purpose of this instance.", - "title": "The Totalamount Schema", - "type": "number" - } - }, - "type": "object" - }, - "type": "array" - } - }, - "type": "object" -} diff --git a/resources/public/api/conf/1.0/schemas/Totals.get.schema.json b/resources/public/api/conf/1.0/schemas/Totals.get.schema.json new file mode 100644 index 0000000..790ae95 --- /dev/null +++ b/resources/public/api/conf/1.0/schemas/Totals.get.schema.json @@ -0,0 +1,30 @@ +{ + "type": "object", + "description": "An object containing the outstanding debits and outstanding credits", + "properties": { + "_links": { + "type": "object", + "description": "An object of links to explore further data", + "properties": { + "empRefs": { + "type": "object", + "description": "An object holding the link back to the entry endpoint", + "properties": { + "href": { + "type": "string", + "description": "Link to the entry endpoint" + } + } + } + } + }, + "credit": { + "type": "integer", + "description": "The currently outstanding credits on your account." + }, + "debit": { + "type": "integer", + "description": "The currently outstanding debits on your account." + } + } +}