-
Notifications
You must be signed in to change notification settings - Fork 1
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
Legacy v2 SMS Pydantic Models #117
Comments
Had an initial conversation with QA and followed up with questions. |
Ran ENP unit tests on temporary models to verify. |
https://docs.pydantic.dev/latest/migration/#required-optional-and-nullable-fields For the anyOf constraint on recipient_id and phone_number, Pydantic doesn't have a direct/clean equivalent. Adding field_validator to callback_url to restrict to https (per notification-api v2 schema) |
mypy seems to have problems with (among other things) the use of aliasing i.e. personalisation aliased with personalization mypy check failed pydantic/pydantic#6713 (comment) Update: The solution is that although the first parameter of Field is 'default', you have to specify it by name vs. position for mypy to see it. personalisation: dict[str, str | int | float] | None = Field(default=None, alias='personalization') |
Checking the unittest coverage and met with Evan to discuss local Postman testing, including generation of JWT token |
Discussed current changes and possible testing methodology with QA Potential issues to be discussed with team and/or addressed on Monday
|
Discussed testing with Cris and given that validation is to be addressed in #112, testing for now can just return a 400 if validation fails. |
NOTE: QA Validation is deferred to another ticket to be created. |
Made changes based on review suggestions. Simplified UUID and HTTPS validation. |
Co-authored-by: Chris Johnson <[email protected]>
User Story - Business Need
We need Pydantic models representing the notification-api
/v2/notification/sms
endpoint. This will help us prepare to wrap notification-api with va-enp-api.User Story(ies)
As a VA Notify dev
I want Pydantic models for all routes
So that our API is fast and consistent
Additional Info and Resources
post_sms_request
is in notification-apiapp/v2/notifications/notification_schemas.py
Acceptance Criteria
/v2/notifications/sms
Note: Leaving this AC unchecked due to inability to properly test response fields due to hardcoded response. Testing dependent on DB for proper responses.
QA Considerations
QA Validation is deferred to another ticket to be created.
Potential Dependencies
Dev Testing
Unit tests added to cover valid and invalid data
Tested locally with the following POST payloads and verifying a response of 201 Created
Response data is currently hardcoded and not included in testing
Basic validation of required optional fields but proper validation and error responses to be addressed in later ticket.
/v2/notifications/sms
/legacy/v2/notifications/sms
Required fields (template_id and phone_number)
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101" }
Required fields (template_id and recipient_identifier)
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "recipient_identifier": { "id_type": "ICN", "id_value": "some-id-value" } }
Required fields (template_id, phone_number, and recipient_identifier)
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101", "recipient_identifier": { "id_type": "ICN", "id_value": "some-id-value" } }
Optional personalisation fields (includes email specific options since the model is shared)
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101", "personalisation": { "additionalProp1": "string", "additionalProp2": "string", "ListProp1": [ "Item1", 1, 1.0 ] } }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101", "personalisation": { "additionalProp1": "string", "additionalProp2": "string", "file_obj": { "file": "U29tZSByYW5kb20gZmlsZSBkYXRh", "filename": "string", "sending_method": "attach" } } }
Optional fields
{ "billing_code": "12345", "callback_url": "https://example.com/", "personalisation": { "additionalProp1": "string", "additionalProp2": 1, "additionalProp3": 1.0 }, "reference": "an-external-id", "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101", "sms_sender_id": "4f44ffc8-1ff8-4832-b1af-0b615691b6ea", "scheduled_for": "2024-03-15T10:00:00Z", "email_reply_to_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1" }
scheduled_for validation is out of scope
Validation failures (400 Error: Bad Request)
{ "template_id": "foo", "phone_number": "+18005550101" }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+1800550101" }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "recipient_identifier": { "id_value": "some-id-value" } }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "recipient_identifier": { "id_type": "ICN" } }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "recipient_identifier": { "id_type": "FOO", "id_value": "some-id-value" } }
{ "callback_url": "http://example.com/", "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101" }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101", "personalisation": { "file_obj": { "filename": "string", "sending_method": "attach" } } }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101", "personalisation": { "file_obj": { "file": "U29tZSByYW5kb20gZmlsZSBkYXRh", "sending_method": "attach" } } }
{ "template_id": "a71400e3-b2f8-4bd1-91c0-27f9ca7106a1", "phone_number": "+18005550101", "personalisation": { "file_obj": { "file": "U29tZSByYW5kb20gZmlsZSBkYXRh", "filename": "string", "sending_method": "foo" } } }
Out of Scope
Fixing inconsistencies in the notification-api on the POST request. Any inconsistencies will be brought to va-enp-api because this is a "legacy" route. notification-api requests can fail in many ways. We are not going to replicate the responses in this ticket.
Any before/after request validation regarding phone number or recipient (follow-on ticket)
QA Automation will be handled in a follow-on ticket
The text was updated successfully, but these errors were encountered: