Skip to content

Commit 387334e

Browse files
authored
Merge pull request #821 from companieshouse/feature/IDVA5-2643-reverify-acsp-client-add-application-type-query-param-email-sender
Updating sendIdentityVerificationEmail method sig to accept app type query param
2 parents 932db58 + 8d0891c commit 387334e

File tree

2 files changed

+80
-5
lines changed

2 files changed

+80
-5
lines changed

src/services/acsp/service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,18 @@ export default class {
9090
return resp;
9191
}
9292

93-
public async sendIdentityVerificationEmail (emailData: ClientVerificationEmail): Promise<HttpResponse> {
94-
const url = `/acsp-api/verify-client-identity/send-identity-verification-email`;
93+
/**
94+
* Send an identity verification email to verify or reverify a client identity web app.
95+
* @param emailData the email data containing verification details
96+
* @param queryParams optional query parameters
97+
* @param queryParams.application_type optional application type to filter the verification or reverification services.
98+
* @returns Promise that resolves to the HTTP response from the API
99+
*/
100+
public async sendIdentityVerificationEmail (emailData: ClientVerificationEmail, queryParams?: { application_type?: string }): Promise<HttpResponse> {
101+
let url = `/acsp-api/verify-client-identity/send-identity-verification-email`;
102+
if (queryParams?.application_type) {
103+
url += `?application_type=${queryParams.application_type}`;
104+
}
95105
return this.client.httpPost(url, emailData);
96106
}
97107
}

test/services/acsp/acsp.spec.ts

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,78 @@ describe("ACSP Verifiy a client send confirmation email", async () => {
103103
it("should return 200 on successful email send", async () => {
104104
sinon.stub(mockValues.requestClient, "httpPost").resolves(mockValues.mockSendEmail[200]);
105105
const ofService: AcspService = new AcspService(mockValues.requestClient);
106-
const data = await ofService.sendIdentityVerificationEmail(mockValues.mockClientVerificationEmail);
106+
const data = await ofService.sendIdentityVerificationEmail(mockValues.mockClientVerificationEmail, { application_type: "verification" });
107107
expect(data.status).to.equal(200);
108108
})
109+
109110
it("should return 500 if email fails", async () => {
110111
sinon.stub(mockValues.requestClient, "httpPost").resolves(mockValues.mockSendEmail[500]);
111112
const ofService: AcspService = new AcspService(mockValues.requestClient);
112-
const data = await ofService.sendIdentityVerificationEmail(mockValues.mockClientVerificationEmail);
113+
const data = await ofService.sendIdentityVerificationEmail(mockValues.mockClientVerificationEmail, { application_type: "verification" });
113114
expect(data.status).to.equal(500);
114115
})
115-
})
116+
117+
it("should call correct URL with verification query parameter", async () => {
118+
const httpPostStub = sinon.stub(mockValues.requestClient, "httpPost").resolves(mockValues.mockSendEmail[200]);
119+
const ofService: AcspService = new AcspService(mockValues.requestClient);
120+
121+
await ofService.sendIdentityVerificationEmail(
122+
mockValues.mockClientVerificationEmail,
123+
{ application_type: "verification" }
124+
);
125+
126+
expect(httpPostStub.calledWith(
127+
"/acsp-api/verify-client-identity/send-identity-verification-email?application_type=verification",
128+
mockValues.mockClientVerificationEmail
129+
)).to.be.true;
130+
})
131+
132+
it("should call URL without query parameter when application_type is not provided", async () => {
133+
const httpPostStub = sinon.stub(mockValues.requestClient, "httpPost").resolves(mockValues.mockSendEmail[200]);
134+
const ofService: AcspService = new AcspService(mockValues.requestClient);
135+
136+
await ofService.sendIdentityVerificationEmail(mockValues.mockClientVerificationEmail);
137+
138+
expect(httpPostStub.calledWith(
139+
"/acsp-api/verify-client-identity/send-identity-verification-email",
140+
mockValues.mockClientVerificationEmail
141+
)).to.be.true;
142+
})
143+
});
144+
145+
describe("ACSP Reverify a client send confirmation email", async () => {
146+
it("should return 200 on successful reverification email send", async () => {
147+
sinon.stub(mockValues.requestClient, "httpPost").resolves(mockValues.mockSendEmail[200]);
148+
const ofService: AcspService = new AcspService(mockValues.requestClient);
149+
const data = await ofService.sendIdentityVerificationEmail(
150+
mockValues.mockClientVerificationEmail,
151+
{ application_type: "reverification" }
152+
);
153+
expect(data.status).to.equal(200);
154+
})
155+
156+
it("should return 500 if reverification email fails", async () => {
157+
sinon.stub(mockValues.requestClient, "httpPost").resolves(mockValues.mockSendEmail[500]);
158+
const ofService: AcspService = new AcspService(mockValues.requestClient);
159+
const data = await ofService.sendIdentityVerificationEmail(
160+
mockValues.mockClientVerificationEmail,
161+
{ application_type: "reverification" }
162+
);
163+
expect(data.status).to.equal(500);
164+
})
165+
166+
it("should call correct URL with reverification query parameter", async () => {
167+
const httpPostStub = sinon.stub(mockValues.requestClient, "httpPost").resolves(mockValues.mockSendEmail[200]);
168+
const ofService: AcspService = new AcspService(mockValues.requestClient);
169+
170+
await ofService.sendIdentityVerificationEmail(
171+
mockValues.mockClientVerificationEmail,
172+
{ application_type: "reverification" }
173+
);
174+
175+
expect(httpPostStub.calledWith(
176+
"/acsp-api/verify-client-identity/send-identity-verification-email?application_type=reverification",
177+
mockValues.mockClientVerificationEmail
178+
)).to.be.true;
179+
})
180+
});

0 commit comments

Comments
 (0)