From c0de457b1a7632d9f83a40107462eb4770ab713e Mon Sep 17 00:00:00 2001 From: Alex Saunders Date: Tue, 7 Nov 2023 10:21:27 +0000 Subject: [PATCH] MLPAB-1416: Send how evidence is being sent to OPG in reduced-fee-requested event (#817) --- internal/app/donor_store.go | 14 ++++---- internal/app/donor_store_test.go | 32 ++++++++++++------- .../app/testdata/reduced-fee-requested.json | 7 +++- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/internal/app/donor_store.go b/internal/app/donor_store.go index 899d3f2753..414e69fd2b 100644 --- a/internal/app/donor_store.go +++ b/internal/app/donor_store.go @@ -198,9 +198,10 @@ func (s *donorStore) Put(ctx context.Context, lpa *page.Lpa) error { if len(unsentKeys) > 0 { if err := s.eventClient.Send(ctx, "reduced-fee-requested", reducedFeeRequestedEvent{ - UID: lpa.UID, - RequestType: lpa.FeeType.String(), - Evidence: unsentKeys, + UID: lpa.UID, + RequestType: lpa.FeeType.String(), + Evidence: unsentKeys, + EvidenceDelivery: lpa.EvidenceDelivery.String(), }); err != nil { s.logger.Print(err) } else { @@ -285,7 +286,8 @@ type previousApplicationLinkedEvent struct { } type reducedFeeRequestedEvent struct { - UID string `json:"uid"` - RequestType string `json:"requestType"` - Evidence []string `json:"evidence"` + UID string `json:"uid"` + RequestType string `json:"requestType"` + Evidence []string `json:"evidence"` + EvidenceDelivery string `json:"evidenceDelivery"` } diff --git a/internal/app/donor_store_test.go b/internal/app/donor_store_test.go index 8d7493db7f..dddd355a90 100644 --- a/internal/app/donor_store_test.go +++ b/internal/app/donor_store_test.go @@ -485,15 +485,17 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocuments(t *testing.T) { FeeType: pay.HalfFee, Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending}, HasSentApplicationUpdatedEvent: true, + EvidenceDelivery: pay.Upload, }). Return(nil) eventClient := newMockEventClient(t) eventClient. On("Send", ctx, "reduced-fee-requested", reducedFeeRequestedEvent{ - UID: "M-1111", - RequestType: "HalfFee", - Evidence: []string{"lpa-uid-evidence-a-uid"}, + UID: "M-1111", + RequestType: "HalfFee", + Evidence: []string{"lpa-uid-evidence-a-uid"}, + EvidenceDelivery: "upload", }). Return(nil) @@ -517,6 +519,7 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocuments(t *testing.T) { FeeType: pay.HalfFee, Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending}, HasSentApplicationUpdatedEvent: true, + EvidenceDelivery: pay.Upload, }) assert.Nil(t, err) @@ -591,9 +594,10 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenEventClientSe eventClient := newMockEventClient(t) eventClient. On("Send", ctx, "reduced-fee-requested", reducedFeeRequestedEvent{ - UID: "M-1111", - RequestType: "HalfFee", - Evidence: []string{"lpa-uid-evidence-a-uid"}, + UID: "M-1111", + RequestType: "HalfFee", + Evidence: []string{"lpa-uid-evidence-a-uid"}, + EvidenceDelivery: "upload", }). Return(expectedError) @@ -623,6 +627,7 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenEventClientSe FeeType: pay.HalfFee, Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending}, HasSentApplicationUpdatedEvent: true, + EvidenceDelivery: pay.Upload, }) assert.Nil(t, err) @@ -635,9 +640,10 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenDocumentStore eventClient := newMockEventClient(t) eventClient. On("Send", ctx, "reduced-fee-requested", reducedFeeRequestedEvent{ - UID: "M-1111", - RequestType: "HalfFee", - Evidence: []string{"lpa-uid-evidence-a-uid"}, + UID: "M-1111", + RequestType: "HalfFee", + Evidence: []string{"lpa-uid-evidence-a-uid"}, + EvidenceDelivery: "upload", }). Return(nil) @@ -670,6 +676,7 @@ func TestDonorStorePutWhenReducedFeeRequestedAndUnsentDocumentsWhenDocumentStore FeeType: pay.HalfFee, Tasks: page.Tasks{PayForLpa: actor.PaymentTaskPending}, HasSentApplicationUpdatedEvent: true, + EvidenceDelivery: pay.Upload, }) assert.Nil(t, err) @@ -859,9 +866,10 @@ func TestEventSchema(t *testing.T) { }, }, "reduced-fee-requested": reducedFeeRequestedEvent{ - UID: "M-0000-0000-0000", - RequestType: "NoFee", - Evidence: []string{"key"}, + UID: "M-0000-0000-0000", + RequestType: "NoFee", + Evidence: []string{"key"}, + EvidenceDelivery: "upload", }, } diff --git a/internal/app/testdata/reduced-fee-requested.json b/internal/app/testdata/reduced-fee-requested.json index f55df8aabc..e5840622eb 100644 --- a/internal/app/testdata/reduced-fee-requested.json +++ b/internal/app/testdata/reduced-fee-requested.json @@ -20,7 +20,12 @@ "items": { "type": "string" } + }, + "evidenceDelivery": { + "type": "string", + "description": "How the evidence is being delivered to OPG", + "enum": ["upload", "post"] } }, - "required": ["uid", "requestType", "evidence"] + "required": ["uid", "requestType", "evidence", "evidenceDelivery"] }