Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DTFS-7049): added POST /emails endpoint for sending emails using…
… GOV.UK Notify service (#820) ## Introduction ✏️ We are moving GOV.UK Notify integration from DTFS to MDM API. ## Resolution ✔️ * Created new helper module `govuk-notify` * It uses npm package `notifications-node-client` to communicate with GOV.UK Notify * Created new NestJs module `emails` with endpoint POST /emails * We create new instance of class `NotifyClient` for each request. This is because each request can have different GOV.UK Notify API key. ### Request example: Auth headers: ``` { govUkNotifyKey: dtfsdev-1234567-1234-1234-abcd-123456789098-abcdefg-1234-1234-6789-def098765432 } ``` Body: ``` { "templateId": "abc45678-474e-4f34-a8d7-12345677890", "sendToEmailAddress": "JohnSm@example.com", "personalisation": { "firstName": "John", "surname": "Smith", } } ``` ### Response example: ``` { "status": 201, "data": { "content": { "body": "Dear John Smith,\r\n\r\nThe status of your MIA for Star has been updated.\r\n\r\n* With regards,\r\n\r\nThe Digital Trade Finance Service team\r\n\r\nEmail: DigitalService.TradeFinance@ukexportfinance.gov.uk\r\nPhone: +44 (0)207 271 8010\r\nOpening times: Monday to Friday, 9am to 5pm (excluding public holidays)", "from_email": "digital.trade.finance@example.com", "subject": "Status update: Star bridge", "unsubscribe_link": null }, "id": "trans-id-123-0a55-48ae-ad6c-09874363723a", "reference": "123456789-474e-4f34-a8d7-abde48cdffce-1713345234336", "scheduled_for": null, "template": { "id": "123456789-474e-4f34-a8d7-abde48cdffce", "uri": "https://api.notifications.service.gov.uk/services/11111111-2222-3333-4444-55555555555/templates/123456789-474e-4f34-a8d7-abde48cdffce", "version": 24 }, "uri": "https://api.notifications.service.gov.uk/v2/notifications/trans-id-123-0a55-48ae-ad6c-09874363723a" } } ``` ## New packages * `notifications-node-client` - GOV.UK Notify package ## New Environment variables * NA ## Miscellaneous ➕ * Copied API test helper `withStringFieldValidationApiTests` from `tfs-api` project * Created API test helper `withEmailFieldValidationApiTests` * Created API test helper `withObjectFieldValidationApiTests` * Copied API test helper prepareModifiedRequest from `tfs-api` project * Moved reusable sub tests from withStringFieldValidationApiTests, like: * withRequiredFieldValidationApiTests * withTypeFieldValidationApiTests * Removed ``` forbidNonWhitelisted: true, transformOptions: { enableImplicitConversion: true, }, ``` from global ValidationPipe. It was creating auto transformations after moving to single object payload.
- Loading branch information