Skip to content

Commit d655b5e

Browse files
committed
CCM-11580: Update letter responses in Sandbox to match spec changes
1 parent 1f0cfe7 commit d655b5e

File tree

13 files changed

+30
-214
lines changed

13 files changed

+30
-214
lines changed

sandbox/data/examples/getLetter/responses/getLetter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"attributes": {
44
"reasonCode": 100,
55
"reasonText": "failed validation",
6-
"requestedProductionStatus": "ACTIVE",
76
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
87
"status": "REJECTED"
98
},

sandbox/data/examples/getLetters/responses/getLetters_accepted.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

sandbox/data/examples/getLetters/responses/getLetters_pending-10.json

Lines changed: 0 additions & 72 deletions
This file was deleted.

sandbox/data/examples/getLetters/responses/getLetters_pending-5.json

Lines changed: 0 additions & 73 deletions
This file was deleted.

sandbox/data/examples/getLetters/responses/getLetters_pending.json

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"data": [
33
{
44
"attributes": {
5-
"requestedProductionStatus": "ACTIVE",
65
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
76
"status": "PENDING"
87
},
@@ -11,7 +10,6 @@
1110
},
1211
{
1312
"attributes": {
14-
"requestedProductionStatus": "ACTIVE",
1513
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
1614
"status": "PENDING"
1715
},
@@ -20,7 +18,6 @@
2018
},
2119
{
2220
"attributes": {
23-
"requestedProductionStatus": "ACTIVE",
2421
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
2522
"status": "PENDING"
2623
},
@@ -29,7 +26,6 @@
2926
},
3027
{
3128
"attributes": {
32-
"requestedProductionStatus": "ACTIVE",
3329
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
3430
"status": "PENDING"
3531
},
@@ -38,7 +34,6 @@
3834
},
3935
{
4036
"attributes": {
41-
"requestedProductionStatus": "ACTIVE",
4237
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
4338
"status": "PENDING"
4439
},
@@ -47,7 +42,6 @@
4742
},
4843
{
4944
"attributes": {
50-
"requestedProductionStatus": "ACTIVE",
5145
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
5246
"status": "PENDING"
5347
},
@@ -56,17 +50,11 @@
5650
},
5751
{
5852
"attributes": {
59-
"requestedProductionStatus": "ACTIVE",
6053
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
6154
"status": "PENDING"
6255
},
6356
"id": "31B68ctCLllXxrmkrrcent290Jv",
6457
"type": "Letter"
6558
}
66-
],
67-
"links": {
68-
"last": "https://api.service.nhs.uk/nhs-notify-supplier/letters?status=PENDING&page=10",
69-
"next": "https://api.service.nhs.uk/nhs-notify-supplier/letters?status=PENDING&page=2",
70-
"self": "https://api.service.nhs.uk/nhs-notify-supplier/letters?status=PENDING&page=1"
71-
}
59+
]
7260
}

sandbox/data/examples/patchLetter/requests/patchLetter.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
"attributes": {
44
"reasonCode": 100,
55
"reasonText": "failed validation",
6-
"requestedProductionStatus": "ACTIVE",
7-
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
86
"status": "REJECTED"
97
},
108
"id": "2WL5eYSWGzCHlGmzNxuqVusPxDg",

sandbox/data/examples/patchLetter/responses/patchLetter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"attributes": {
44
"reasonCode": 100,
55
"reasonText": "failed validation",
6-
"requestedProductionStatus": "ACTIVE",
76
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
87
"status": "REJECTED"
98
},

sandbox/data/examples/postLetter/requests/postLetter.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"attributes": {
55
"reasonCode": 100,
66
"reasonText": "failed validation",
7-
"requestedProductionStatus": "ACTIVE",
8-
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
97
"status": "REJECTED"
108
},
119
"id": "2WL5eYSWGzCHlGmzNxuqVusPxDg",

sandbox/data/examples/postLetter/responses/postLetter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"attributes": {
55
"reasonCode": 100,
66
"reasonText": "failed validation",
7-
"requestedProductionStatus": "ACTIVE",
87
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
98
"status": "REJECTED"
109
},

sandbox/utils/ResponseProvider.js

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-throw-literal */
2-
const { Console } = require('console');
2+
const {Console} = require('console');
33
const fs = require('fs/promises');
44
// eslint-disable-next-line import/no-extraneous-dependencies
55
const lodash = require('lodash');
@@ -21,7 +21,7 @@ function mapExampleResponse(requestBody, exampleResponseMap) {
2121

2222
function mapExampleGetResponse(parameterValue, exampleResponseMap) {
2323
const match = Object.entries(exampleResponseMap).find(([requestParameter, response]) => {
24-
try{
24+
try {
2525
return parameterValue === requestParameter;
2626
} catch (err) {
2727
console.error(`Failed to process ${parameterValue}:`, err);
@@ -31,38 +31,36 @@ function mapExampleGetResponse(parameterValue, exampleResponseMap) {
3131
return match ? match[1] : null;
3232
}
3333

34+
async function getLettersResponse(status, limit) {
35+
const getLettersfileMap = {
36+
PENDING: 'data/examples/getLetters/responses/getLetters_pending.json',
37+
};
3438

35-
module.exports = {
36-
async getLettersResponse(status, page) {
37-
const getLettersfileMap = {
38-
PENDING: 'data/examples/getLetters/responses/getLetters_pending.json',
39-
PENDING1: 'data/examples/getLetters/responses/getLetters_pending.json',
40-
PENDING5: 'data/examples/getLetters/responses/getLetters_pending-5.json',
41-
PENDING10: 'data/examples/getLetters/responses/getLetters_pending-10.json',
42-
ACCEPTED: 'data/examples/getLetters/responses/getLetters_accepted.json',
43-
};
44-
45-
const mapkey = page ? `${status}${page}` : status;
46-
const filename = mapExampleGetResponse(mapkey, getLettersfileMap);
47-
if (!filename) {
48-
throw { message: `Not found: ${status}`, status: 404 };
49-
}
39+
const filename = mapExampleGetResponse(status, getLettersfileMap);
40+
if (!filename) {
41+
throw {message: `Not found: ${status}`, status: 404};
42+
}
5043

51-
const content = await fs.readFile(filename, 'utf8');
52-
return JSON.parse(content);
53-
},
44+
const content = await fs.readFile(filename, 'utf8');
45+
const response = JSON.parse(content);
46+
response.data.splice(limit);
47+
return response;
48+
}
5449

55-
async patchLettersResponse(request) {
50+
async function patchLettersResponse(request) {
51+
const patchLettersFileMap = {
52+
'data/examples/patchLetter/requests/patchLetter.json': 'data/examples/patchLetter/responses/patchLetter.json',
53+
};
54+
const filename = mapExampleResponse(request, patchLettersFileMap);
55+
if (!filename) {
56+
throw {message: 'Not found: ', status: 404};
57+
}
5658

57-
const patchLettersFileMap = {
58-
'data/examples/patchLetter/requests/patchLetter.json': 'data/examples/patchLetter/responses/patchLetter.json',
59-
};
60-
const filename = mapExampleResponse(request, patchLettersFileMap);
61-
if (!filename) {
62-
throw { message: 'Not found: ', status: 404 };
63-
}
59+
const content = await fs.readFile(filename, 'utf8');
60+
return JSON.parse(content);
61+
}
6462

65-
const content = await fs.readFile(filename, 'utf8');
66-
return JSON.parse(content);
67-
},
63+
module.exports = {
64+
getLettersResponse,
65+
patchLettersResponse
6866
};

0 commit comments

Comments
 (0)