Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DTFS-7049): added POST /emails endpoint for sending emails using GOV.UK Notify service #820

Merged
merged 32 commits into from
May 31, 2024

Conversation

avaitonis
Copy link
Contributor

@avaitonis avaitonis commented Apr 30, 2024

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": "[email protected]",
    "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: [email protected]\r\nPhone: +44 (0)207 271 8010\r\nOpening times: Monday to Friday, 9am to 5pm (excluding public holidays)",
            "from_email": "[email protected]",
            "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.

@avaitonis avaitonis changed the title WIP feat(DTFS-7049): added POST /emails endpoint for sending emails using GOV.UK Notify service feat(DTFS-7049): added POST /emails endpoint for sending emails using GOV.UK Notify service May 14, 2024
@avaitonis avaitonis force-pushed the feat/DTFS2-7049/new-external-gov-notify-api branch from 8f2f357 to 41d314c Compare May 31, 2024 12:33
@avaitonis avaitonis force-pushed the feat/DTFS2-7049/new-external-gov-notify-api branch from 41d314c to c14fa49 Compare May 31, 2024 12:37
Copy link
Contributor

@oscar-richardson-softwire oscar-richardson-softwire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, LGTM :)

Copy link

sonarcloud bot commented May 31, 2024

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@oscar-richardson-softwire oscar-richardson-softwire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@avaitonis avaitonis merged commit 3a1bf0e into main May 31, 2024
17 checks passed
@avaitonis avaitonis deleted the feat/DTFS2-7049/new-external-gov-notify-api branch May 31, 2024 15:47
abhi-markan added a commit that referenced this pull request Jun 4, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.21.0](v1.20.0...v1.21.0)
(2024-06-04)


### Features

* **DTFS-7049:** added POST /emails endpoint for sending emails using
GOV.UK Notify service
([#820](#820))
([3a1bf0e](3a1bf0e))
* **DTFS2-7049:** fixed tests caused by removal of global transformer
and allowing extra params
([71e44ff](71e44ff))
* **DTFS2-7049:** fixing PR issues
([e0e099e](e0e099e))
* **DTFS2-7049:** removed BadRequestException tests moving payload to
object instead of array
([3bb8d71](3bb8d71))
* **DTFS2-7049:** return error message as string instead of array
([86b5b4d](86b5b4d))
* **DTFS2-7049:** test unknown Gov.UK Notify responses
([c14fa49](c14fa49))
* **DTFS2-7121:** create Companies House endpoint
([#821](#821))
([7860528](7860528))


### Bug Fixes

* **eslint:** reverted back to eslint `8.57.0`
([#905](#905))
([75ca97c](75ca97c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants