This repository contains the code for a persistent cache holding customs related data.
This Microservice is a common backend service and used by other CDS teams (Exports and Reimbursement) as well.
From the root directory
sbt run - starts the service locally
sbt runAllChecks - Will run all checks required for a successful build
Default service port on local - 9893
There are a number of dependencies required to run the service.
The easiest way to get started with these is via the service manager CLI - you can find the installation guide here
| Command | Description |
|---|---|
sm2 --start CUSTOMS_FINANCIALS_ALL |
Runs all dependencies |
sm2 -s |
Shows running services |
sm2 --stop CUSTOMS_DATA_STORE |
Stop the micro service |
sbt run or sbt "run 9893" |
(from root dir) to compile the current service with your changes |
If you want to run customs-data-store locally then you also have to run customs-financials-hods-stub so that it can retrieve historic Eoris from there.
To start the service from sbt: sbt "run 9893" or from service manager: sm --start CUSTOMS_DATA_STORE CUSTOMS_FINANCIALS_HODS_STUB -f
In Postman
- Send in any of the below requests to http://localhost:9893/customs-data-store/
- Add and
Authorizationheader and set its value to whatever is inapplication.confunder the keyserver-token
(These are subject to change and may not include every dependency)
AUTHAUTH_LOGIN_STUBAUTH_LOGIN_APIBAS_GATEWAYCA_FRONTENDSSOUSER_DETAILSCUSTOMS_FINANCIALS_SDES_STUB
The service's endpoints (that need Enrolment to access) can be accessed by using below enrolments.
| Enrolment Key | Identifier Name | Identifier Value |
|---|---|---|
HMRC-CUS-ORG |
EORINumber |
GB744638982000 |
HMRC-CUS-ORG |
EORINumber |
GB744638982001 |
The minimum requirement for test coverage is 90%. Builds will fail when the project drops below this threshold.
| Command | Description |
|---|---|
sbt test |
Runs unit tests locally |
sbt "test/testOnly *TEST_FILE_NAME*" |
runs tests for a single file |
| Command | Description |
|---|---|
sbt clean coverage test coverageReport |
Generates a unit test coverage report that you can find here target/scala-3.3.5/scoverage-report/index.html |
| Path | Description | Comments |
|---|---|---|
| GET /customs-data-store/eori/xieori-information | Retrieves the XI EORI information for the requested EORI either from the cache or SUB09 | |
| POST /customs-data-store/eori/verified-email-third-party | Retrieves the verified email address for the EORI specified in request body either from cache or SUB09 | |
| POST /customs-data-store/eori/company-information-third-party | Retrieves the business full name for the EORI specified in request body | |
| POST /customs-data-store/eori/eori-history-third-party | Retrieves the historic EORIs for a given third-party EORI | |
| POST /customs-data-store/update-email | Populates a new verified email address in the cache and removes undeliverable information | |
| POST /customs-data-store/update-eori-history | Updates the eori history for a given EORI in the cache | |
| POST /update-undeliverable-email | Updates undeliverable information for a given enrolmentValue |
Not applicable
An endpoint to retrieve a verified email address for logged-in EORI.
{
"address" : "[email protected]",
"timestamp" : "2020-03-20T01:02:03Z"
}| Status | Description |
|---|---|
| 200 | A verified email has been found for the specified eori |
| 404 | No verified email has been found for the specified eori |
| 500 | An unexpected failure happened in the service |
An endpoint to retrieve the business full name and address for logged-in EORI.
{
"name": "ABC ltd",
"consent": "1",
"address" : {
"streetAndNumber": "12 Example Street",
"city": "Example",
"postalCode": "AA00 0AA",
"countryCode": "GB"
}
}| Field | Required | Description |
|---|---|---|
| name | Mandatory | Company name |
| consent | Optional | consentToDisclosureOfPersonalData |
| address | Mandatory | The address Information for the company |
| address.streetAndNumber | Mandatory | The street and number where the company resides |
| address.city | Mandatory | The city where the company resides |
| address.postalCode | Optional | Mandatory for the country code "GB" |
| address.countryCode | Mandatory | The country code where the company resides |
| Status | Description |
|---|---|
| 200 | Company information found and returned |
| 404 | Company information not found or elements of the payload not found |
An endpoint to update the verified email address for a given EORI and removes undeliverable information.
{
"eori" : "someEori",
"address" : "[email protected]",
"timestamp" : "2020-03-20T01:02:03Z"
}| Field | Required | Description |
|---|---|---|
| eori | Mandatory | The eori used to provide a verified email address to |
| address | Mandatory | The verified email address for the specified eori |
| timestamp | Mandatory | The timestamp when the email was verified |
An endpoint that provides a list of all historic EORI's associated for logged-in EORI.
{
"eoriHistory": [
{
"eori": "historicEori1",
"validFrom": "2001-01-20T00:00:00Z",
"validTo": "2001-01-20T00:00:00Z"
},
{
"eori": "historicEori2",
"validFrom": "2001-01-20T00:00:00Z",
"validTo": "2001-01-20T00:00:00Z"
}
]
}| Status | Description |
|---|---|
| 200 | A sequence of historic eori's returned |
| 500 | An unexpected failure happened in the service |
An endpoint that provides XI EORI information for the requested EORI.
{
"xiEori": "XI744638982004",
"consent": "S",
"address": {
"pbeAddressLine1": "address line 1",
"pbeAddressLine2": "address line 2",
"pbeAddressLine3": "city 1",
"pbePostCode": "AA1 1AA"
}
}| Status | Description |
|---|---|
| 200 | XI EORI information is returned |
| 404 | XI EORI information is retrieved neither from cache nor SUB09 |
An endpoint to retrieve a verified email address for EORI specified in request body.
{
"eori" : "testEori"
}| Field | Required | Description |
|---|---|---|
| eori | Mandatory | The eori used to provide a verified email address to |
{
"address" : "[email protected]",
"timestamp" : "2020-03-20T01:02:03Z"
}| Status | Description |
|---|---|
| 200 | A verified email has been found for the specified eori |
| 400 | Malformed request |
| 404 | No verified email has been found for the specified eori |
| 500 | An unexpected failure happened in the service |
An endpoint to retrieve the business full name and address for EORI specified in request body.
{
"eori" : "testEori"
}| Field | Required | Description |
|---|---|---|
| eori | Mandatory | The eori used to provide a verified email address to |
{
"name": "ABC ltd",
"consent": "1",
"address" : {
"streetAndNumber": "12 Example Street",
"city": "Example",
"postalCode": "AA00 0AA",
"countryCode": "GB"
}
}| Field | Required | Description |
|---|---|---|
| name | Mandatory | Company name |
| consent | Optional | consentToDisclosureOfPersonalData |
| address | Mandatory | The address Information for the company |
| address.streetAndNumber | Mandatory | The street and number where the company resides |
| address.city | Mandatory | The city where the company resides |
| address.postalCode | Optional | Mandatory for the country code "GB" |
| address.countryCode | Mandatory | The country code where the company resides |
| Status | Description |
|---|---|
| 200 | A verified email has been found for the specified eori |
| 400 | Malformed request |
| 404 | No verified email has been found for the specified eori |
| 500 | An unexpected failure happened in the service |
An endpoint to retrieve the historic EORIs of a given third party EORI (not the logged-in user's EORI).
{
"eori" : "testEori"
}| Field | Required | Description |
|---|---|---|
| eori | Mandatory | The eori for which historically associated EORIs are to be retrieved |
{
"eoriHistory": [
{
"eori": "historicEori1",
"validFrom": "2001-01-20T00:00:00Z",
"validTo": "2001-01-20T00:00:00Z"
},
{
"eori": "historicEori2",
"validFrom": "2001-01-20T00:00:00Z",
"validTo": "2001-01-20T00:00:00Z"
}
]
}| Status | Description |
|---|---|
| 200 | A sequence of historic eori's returned |
| 500 | An unexpected failure happened in the service |
An endpoint to populate the historic EORI's for a given EORI.
{
"eori" : "testEori"
}| Status | Description |
|---|---|
| 204 | Successfully updated the historic EORI's in the cache |
| 500 | An unexpected failure happened in the service |
An endpoint to update undeliverable information for an enrolmentValue.
| Param | Type | Optional/Mandatory |
|---|---|---|
| subject | String | Mandatory |
| eventId | String | Mandatory |
| groupId | String | Mandatory |
| timestamp | DateTime | Mandatory |
| event.id | String | Mandatory |
| event.enrolment | String | Mandatory |
| event.emailAddress | String | Mandatory |
| event.event | String | Mandatory |
| event.detected | DateTime | Mandatory |
| event.code | Int | Optional |
| event.reason | String | Optional |
{
"subject": "subject-example",
"eventId": "example-id",
"groupId": "example-group-id",
"timestamp": "2021-05-14T10:59:45.811+01:00",
"event": {
"id": "example-id",
"event": "someEvent",
"emailAddress": "[email protected]",
"detected": "2021-05-14T10:59:45.811+01:00",
"code": 12,
"reason": "Inbox full",
"enrolment": "HMRC-CUS-ORG~EORINumber~testEori"
}
}| Status | Description |
|---|---|
| 204 | Successfully updated undeliverable information for enrolmentValue |
| 404 | No update was performed on a record either due to it not existing or already having the same undeliverable information present |
| 400 | If enrolmentKey is not equal to 'HMRC-CUS-ORG' OR If enrolmentIdentifier is not equal to 'EORINumber' |
| 500 | An unexpected failure happened in the service |
| Command | Description |
|---|---|
sbt runAllChecks |
Runs all standard code checks |
sbt clean |
Cleans code |
sbt compile |
Better to say 'Compiles the code' |
sbt coverage |
Prints code coverage |
sbt test |
Runs unit tests |
sbt it/test |
Runs integration tests |
sbt scalafmtCheckAll |
Runs code formatting checks based on .scalafmt.conf |
sbt scalastyle |
Runs code style checks based on /scalastyle-config.xml |
sbt Test/scalastyle |
Runs code style checks for unit test code /test-scalastyle-config.xml |
sbt coverageReport |
Produces a code coverage report |
sbt "test/testOnly *TEST_FILE_NAME*" |
runs tests for a single file |
sbt clean coverage test coverageReport |
Generates a unit test coverage report that you can find here target/scala-3.3.5/scoverage-report/index.html |
sbt "run -Dfeatures.some-feature-name=true" |
enables a feature locally without risking exposure |