Skip to content

Commit 09bd418

Browse files
committed
CCM-11580: implement get letter status endpoint in sandbox
1 parent d655b5e commit 09bd418

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

sandbox/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22

33
const config = {
44
ROOT_DIR: __dirname,
5-
URL_PORT: 9000,
5+
URL_PORT: 3000,
66
URL_PATH: 'http://127.0.0.1',
77
BASE_VERSION: '',
88
CONTROLLER_DIRECTORY: path.join(__dirname, 'controllers'),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"data": {
3+
"attributes": {
4+
"reasonCode": 100,
5+
"reasonText": "failed validation",
6+
"specificationId": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
7+
"status": "PENDING"
8+
},
9+
"id": "24L5eYSWGzCHlGmzNxuqVusPxDg",
10+
"type": "Letter"
11+
}
12+
}

sandbox/data/examples/getLetter/responses/getLetter.json renamed to sandbox/data/examples/getLetter/responses/getLetter-2WL5eYSWGzCHlGmzNxuqVusPxDg.json

File renamed without changes.

sandbox/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sandbox/services/LetterService.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ const ResponseProvider = require('../utils/ResponseProvider');
1616
const getLetterStatus = ({ xRequestID, id, xCorrelationID }) => new Promise(
1717
async (resolve, reject) => {
1818
try {
19+
const fileData = await ResponseProvider.getLetterStatusResponse(id);
1920
resolve(Service.successResponse({
2021
xRequestID,
21-
id,
2222
xCorrelationID,
23+
data: fileData,
2324
}));
2425
} catch (e) {
2526
reject(Service.rejectResponse(

sandbox/utils/ResponseProvider.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ function mapExampleGetResponse(parameterValue, exampleResponseMap) {
3131
return match ? match[1] : null;
3232
}
3333

34+
async function getLetterStatusResponse(id) {
35+
console.log(`GET /letters/${id}`)
36+
37+
const filename = `data/examples/getLetter/responses/getLetter-${id}.json`
38+
if (!filename) {
39+
throw {message: `Not found: ${id}`, status: 404};
40+
}
41+
42+
const content = await fs.readFile(filename, 'utf8');
43+
return JSON.parse(content);
44+
}
45+
3446
async function getLettersResponse(status, limit) {
3547
const getLettersfileMap = {
3648
PENDING: 'data/examples/getLetters/responses/getLetters_pending.json',
@@ -61,6 +73,7 @@ async function patchLettersResponse(request) {
6173
}
6274

6375
module.exports = {
76+
getLetterStatusResponse,
6477
getLettersResponse,
6578
patchLettersResponse
6679
};

0 commit comments

Comments
 (0)