From ca279627291f77491aba59ca166f04176ff78f34 Mon Sep 17 00:00:00 2001 From: MishNajam <61416092+MishNajam@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:20:56 +0000 Subject: [PATCH] Vega 2656 add appointment type and new status (#277) * VEGA-2656 add appointment type and new status to Attorney struct * Update unit tests * make appointmentType optional * Revert counting attorneys by appointmentType --- docs/example-lpa.json | 1 + docs/schemas/2024-10/lpa.json | 8 ++++++++ internal/shared/person.go | 31 ++++++++++++++++++++++--------- lambda/create/main_test.go | 1 + lambda/create/validate_test.go | 22 ++++++++++++---------- mock-apigw/main.go | 1 + 6 files changed, 45 insertions(+), 19 deletions(-) diff --git a/docs/example-lpa.json b/docs/example-lpa.json index ddd82528..e443dcc1 100644 --- a/docs/example-lpa.json +++ b/docs/example-lpa.json @@ -26,6 +26,7 @@ }, "dateOfBirth": "1982-07-24", "status": "active", + "appointmentType": "original", "channel": "paper" } ], diff --git a/docs/schemas/2024-10/lpa.json b/docs/schemas/2024-10/lpa.json index 2f3c01f2..7477219e 100644 --- a/docs/schemas/2024-10/lpa.json +++ b/docs/schemas/2024-10/lpa.json @@ -43,6 +43,14 @@ "signedAt": { "type": "string", "format": "date-time" + }, + "status": { + "type": "string", + "enum": ["active", "inactive", "replacement", "removed"] + }, + "appointmentType": { + "type": "string", + "enum": ["original", "replacement"] } } } diff --git a/internal/shared/person.go b/internal/shared/person.go index c98f7eaf..b49d65c3 100644 --- a/internal/shared/person.go +++ b/internal/shared/person.go @@ -57,24 +57,37 @@ type AttorneyStatus string const ( AttorneyStatusActive = AttorneyStatus("active") + AttorneyStatusInactive = AttorneyStatus("inactive") AttorneyStatusReplacement = AttorneyStatus("replacement") AttorneyStatusRemoved = AttorneyStatus("removed") ) func (a AttorneyStatus) IsValid() bool { - return a == AttorneyStatusActive || a == AttorneyStatusReplacement || a == AttorneyStatusRemoved + return a == AttorneyStatusActive || a == AttorneyStatusReplacement || a == AttorneyStatusRemoved || a == AttorneyStatusInactive +} + +type AppointmentType string + +const ( + AppointmentTypeOriginal = AppointmentType("original") + AppointmentTypeReplacement = AppointmentType("replacement") +) + +func (a AppointmentType) IsValid() bool { + return true } type Attorney struct { Person - Address Address `json:"address"` - DateOfBirth Date `json:"dateOfBirth"` - Email string `json:"email,omitempty"` - Status AttorneyStatus `json:"status"` - Mobile string `json:"mobile,omitempty"` - SignedAt *time.Time `json:"signedAt,omitempty"` - ContactLanguagePreference Lang `json:"contactLanguagePreference,omitempty"` - Channel Channel `json:"channel"` + Address Address `json:"address"` + DateOfBirth Date `json:"dateOfBirth"` + Email string `json:"email,omitempty"` + Status AttorneyStatus `json:"status"` + AppointmentType AppointmentType `json:"appointmentType"` + Mobile string `json:"mobile,omitempty"` + SignedAt *time.Time `json:"signedAt,omitempty"` + ContactLanguagePreference Lang `json:"contactLanguagePreference,omitempty"` + Channel Channel `json:"channel"` } type TrustCorporation struct { diff --git a/lambda/create/main_test.go b/lambda/create/main_test.go index c99abdb9..2aacae1e 100644 --- a/lambda/create/main_test.go +++ b/lambda/create/main_test.go @@ -47,6 +47,7 @@ var ( Line1: "attorney-line1", Country: "GB", }, + AppointmentType: shared.AppointmentTypeOriginal, DateOfBirth: makeDate("2020-02-03"), ContactLanguagePreference: shared.LangEn, Status: shared.AttorneyStatusActive, diff --git a/lambda/create/validate_test.go b/lambda/create/validate_test.go index bf69cc5b..49a6b7e2 100644 --- a/lambda/create/validate_test.go +++ b/lambda/create/validate_test.go @@ -26,11 +26,12 @@ func makeAttorney() shared.Attorney { FirstNames: "Sharonda", LastName: "Graciani", }, - Address: validAddress, - Email: "some@example.com", - Channel: shared.ChannelOnline, - DateOfBirth: newDate("1977-10-30"), - Status: shared.AttorneyStatusActive, + Address: validAddress, + AppointmentType: shared.AppointmentTypeOriginal, + Email: "some@example.com", + Channel: shared.ChannelOnline, + DateOfBirth: newDate("1977-10-30"), + Status: shared.AttorneyStatusActive, } } @@ -41,11 +42,12 @@ func makeReplacementAttorney() shared.Attorney { FirstNames: "Sharonda", LastName: "Graciani", }, - Address: validAddress, - Email: "some@example.com", - Channel: shared.ChannelOnline, - DateOfBirth: newDate("1977-10-30"), - Status: shared.AttorneyStatusReplacement, + Address: validAddress, + AppointmentType: shared.AppointmentTypeReplacement, + Email: "some@example.com", + Channel: shared.ChannelOnline, + DateOfBirth: newDate("1977-10-30"), + Status: shared.AttorneyStatusReplacement, } } diff --git a/mock-apigw/main.go b/mock-apigw/main.go index a8756417..e5e86db0 100644 --- a/mock-apigw/main.go +++ b/mock-apigw/main.go @@ -148,6 +148,7 @@ func handlePactState(r *http.Request) error { "lastName": "Vallar", "dateOfBirth": "2001-01-17", "status": "active", + "appointmentType": "original", "address": { "line1": "71 South Western Terrace", "town": "Milton",