Skip to content

Commit

Permalink
Adding in user details to the payload (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddmason authored Mar 18, 2024
1 parent 42b462b commit 6411661
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions server/__mock-data__/session-water-pollution.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ const yesterday = moment().seconds(0).milliseconds(0).subtract(1, 'days')
const today = moment().seconds(0).milliseconds(0)

const session = JSON.parse(`{
"home": {
"reporterName": "John Smith",
"reporterPhoneNumber": "012345678910",
"reporterAccessCode": "password"
},
"water-pollution/water-feature": [
{
"questionId": 500,
Expand Down Expand Up @@ -78,6 +83,9 @@ const payload =
reportType: 100,
datetimeObserved: yesterday.toISOString(),
datetimeReported: today.toISOString(),
reporterName: 'John Smith',
reporterPhoneNumber: '012345678910',
reporterAccessCode: 'password',
otherDetails: 'test',
questionSetId: 100,
data: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ describe(url, () => {
expect(sendMessage).toHaveBeenCalledWith(expect.objectContaining({
reportingAnEnvironmentalProblem: expect.objectContaining({
reportType: 100,
reporterName: 'John Smith',
reporterPhoneNumber: '012345678910',
reporterAccessCode: 'password',
otherDetails: otherInfo,
questionSetId: 100,
data: expect.arrayContaining([
Expand Down
5 changes: 5 additions & 0 deletions server/routes/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const handlers = {
fullName,
phone
})
request.yar.set(constants.redisKeys.HOME, {
reporterName: fullName,
reporterPhoneNumber: phone,
reporterAccessCode: accessCode
})
return h.redirect(constants.routes.WATER_POLUTION)
} else {
// Handle error for bad accessCode
Expand Down
6 changes: 4 additions & 2 deletions server/routes/water-pollution/other-information.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ const handlers = {
}

const buildPayload = (session) => {
const reporter = session.get(constants.redisKeys.HOME)
return {
reportingAnEnvironmentalProblem: {
sessionGuid: session.id,
reportType: questionSets.WATER_POLLUTION.questionSetId,
datetimeObserved: session.get(constants.redisKeys.SUBMISSION_TIMESTAMP),
datetimeReported: session.get(constants.redisKeys.WATER_POLLUTION_WHEN),
otherDetails: session.get(constants.redisKeys.WATER_POLLUTION_OTHER_INFORMATION),
questionSetId: questionSets.WATER_POLLUTION.questionSetId, // duplication?
data: buildAnswerDataset(session, questionSets.WATER_POLLUTION)
questionSetId: questionSets.WATER_POLLUTION.questionSetId,
data: buildAnswerDataset(session, questionSets.WATER_POLLUTION),
...reporter
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions server/schemas/sirp-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
"type": "string",
"format": "date-time"
},
"reporterName": {
"type": "string"
},
"reporterPhoneNumber": {
"type": "string"
},
"reporterAccessCode": {
"type": "string"
},
"questionSetId": {
"type": "number"
},
Expand Down

0 comments on commit 6411661

Please sign in to comment.