Commit Graph

55 Commits

Author SHA1 Message Date
Cliff Hill
afc1de61f6 Even more cleanup.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:58:22 -05:00
Cliff Hill
9523cc1d97 Cleaning up with black, isort, flake8.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Cliff Hill
69a9accfca Getting NotificationStatus implemented everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:32 -05:00
Cliff Hill
985ad27b3e Getting imports right to use app.enums
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:32 -05:00
Cliff Hill
ac9591ec7c More tweaks, trying to get tests to be clean.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Cliff Hill
908d695b54 More cleanup.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07:00
Steven Reilly
ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00
Katie Smith
b440f3f904 Use Draft-07 and Draft7Validator everywhere
We were using the Draft4Validator in one place, so this updates it to
the Draft7Validator instead.

The schemas were mostly using draft 4 of the JSON schema, though there
were a couple of schemas that were already of version 7. This updates
them all to version 7, which is the latest version fully supported by
the jsonschema Python package. There are some breaking changes in the
newer version of the schema, but I could not see anywhere would these
affect us. Some of these schemas were not valid in version 4, but are
now valid in version 7 because `"required": []` was not valid in earlier
versions.
2022-04-14 14:46:10 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Leo Hemsted
7ecd7341b0 add broadcast to template_types and add broadcast_data
had to go through the code and change a few places where we filter on
template types. i specifically didn't worry about jobs or notifications.

Also, add braodcast_data - a json column that might contain arbitrary
broadcast data that we'll figure out as we go. We don't know what it'll
look like, but it should be returned by the API
2020-07-06 15:47:13 +01:00
Chris Hill-Scott
7032bac178 Start allowing any three lines in addresses
This is part of moving away from `postcode` and towards `address line 7`

We think it will be easier for people to map their existing data to our
API if we let them fill in any 3 lines, instead of requiring at least
1, 2, and postcode specifically.
2020-04-09 18:19:53 +01:00
Pea Tyczynska
5a1094b6fd Throw error if postage parameter for precompiled POST request incorrect 2019-01-10 16:04:06 +00:00
Pea Tyczynska
56bae2b077 Allow users to set postage per precompiled letter 2019-01-09 17:49:19 +00:00
Katie Smith
8c22a6afda Change schema format name of datetime format
Renamed the 'datetime' format to 'datetime_within_next_day'. This format
is used to validate the date and time of scheduled notifications, not to
check the format of a datetime.
2018-06-27 09:11:38 +01:00
Rebecca Law
ecc4cde4de Update the get_notification_by_id to return a sensible message if the id is not a valid UUID.
Previously "Result not found" would be returned when the id is not a valid uuid, which does not make sense.
Now the message says "notification_id is not a valid UUID", this should be a clearer message for the client service.
2018-04-03 16:37:41 +01:00
Alexey Bezhan
5327298371 Add a view function for pre-compiled PDF letters
Adds a separate view function that is registered under the same
route as existing letter POST notification.
2018-02-23 17:52:24 +00:00
Rebecca Law
e0d0b2f4fd Merge branch 'add-reply-to-notifications' of github.com:alphagov/notifications-api into add-reply-to-notifications 2017-11-23 16:57:17 +00:00
Ken Tsang
df98f0dec1 Update schema to allow include_jobs on get_notis 2017-11-16 14:44:28 +00:00
Rebecca Law
4eec11b633 Added an optional parameter in the form for POST /v2/notifications/sms and /service/<service_id>/send-notification to pass in the SMS sender id.
The send_sms_to_provider still needs to use the SMS sender being passed in to the POST.

As part of https://www.pivotaltracker.com/story/show/152106587
2017-10-30 13:36:49 +00:00
Ken Tsang
8bdc999818 Update notification schema to include received letter status 2017-10-25 10:48:35 +01:00
Richard Chapman
2fbe492d5c [2/10] Allow API calls to specify the reply address option (#1291)
* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Fixed code style in validators.py to confirm with rules
Update the name of email_reply_to_id to conform better with other attributes in the schema and the resultant code in post_notifications.py
Fixed code style in test_validators.py to confirm with rules
Added tests to test_post_notifications.py to test the email_reply_to_id being present and being incorrect, it being optional is being tested by other tests.

* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Added service_email_reply_to_id to the POST /v2/notifications/email and a test to test the validator

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Caught NoResultFound exception in check_service_email_reply_to_id as it was not being caught when there there was no valid service_id or reply_to_id. Fixed failing tests which were not passing due to the NoResultFound exception and added further tests to check for the good path through the code and an test to check for an invalid service_id

* Fixed code style in validators.py to confirm with rules
Update the name of email_reply_to_id to conform better with other attributes in the schema and the resultant code in post_notifications.py
Fixed code style in test_validators.py to confirm with rules
Added tests to test_post_notifications.py to test the email_reply_to_id being present and being incorrect, it being optional is being tested by other tests.

* Minor update after manual merge to fix check style rule break in test_validators.py where a single space was introduced.

* Updates after code review. Moved the template from the exception message as it was not required and updated the error message to match the field name in the sschema for better debugging and error identification.

* Fixed test after update of exception message
2017-10-04 14:34:45 +01:00
Leo Hemsted
4174c72f21 allow 'accepted' as a proxy for created + sending as well as 'failed' for the three failure types when querying the api 2017-09-20 15:30:14 +01:00
Rebecca Law
0a21f1f3e8 Small refactor to how notification_schemas are tested.
My local build was not always getting the optional requirement for the jsonschema uri format checker (rfc3987).
The requirement has been added to the requirements_for_test file.
I changed the tests to validate the response schema from the post_notifications tests, this way we can tell if we are breaking the contract.
This showed that the email_from was not returning the entire email address but just the username, that has been corrected here.
Removed the response schema validation tests since they are not being testing in the post notification tests.
2017-09-11 11:10:45 +01:00
Leo Hemsted
8e738b783e update test_send_notification to account for new uuid mock 2017-07-31 11:10:05 +01:00
Leo Hemsted
79e33073c9 raise 404 when unknown url
consistent with other endpoints.

also refactor of notification_schema to separate some fns to a different file
2017-07-20 15:23:51 +01:00
Leo Hemsted
2be194d9ce refactor post_notification to separate sms/email and letter flows 2017-07-19 17:02:19 +01:00
Leo Hemsted
7f4eec79e4 add POST letter schema
similar to sms/email, however, for consistency with response values
and internal storage, rather than supplying an "email_address" field
or a "phone_number" field, supply an "address_line_1" and "postcode"
field within the personalisation object.
2017-07-19 17:02:19 +01:00
Rebecca Law
b4c9901eb5 Allow for scheduled_for to be null in schema 2017-05-26 15:53:25 +01:00
Rebecca Law
973cc2c4c9 Changed the scheduled_for datetime to only send and hour of a day to send.
Also expect the date being passed in is BST. The date is converted to UTC before saving. And converted to BST when returning a notification.
2017-05-17 15:06:15 +01:00
Rebecca Law
a6529d2723 Return the scheduled_for datetime in the DATETIME_FORMAT from the post_notification 2017-05-16 09:57:58 +01:00
Rebecca Law
f0e2713bef Add scheduled_for in the post notification request form.
Return scheduled for in get_notification requests.
2017-05-15 17:27:38 +01:00
Rebecca Law
38e5b31e9a Update notification schemas with optional schedule_for element 2017-05-15 15:02:38 +01:00
Rebecca Law
bbdbb9079e Fixed the template uri for the post notification responses.
It was optimistic to think the v2 templates would be complete.
2017-01-04 11:22:50 +00:00
Rebecca Law
7f9111fd90 Removed the oneOf validation in the get_notification_response schema. 2017-01-04 11:00:47 +00:00
imdadahad
fb114f4c80 Merge pull request #772 from alphagov/fix-v2-uri
Fix uri validation in v2 responses
2016-12-16 15:53:26 +00:00
Imdad Ahad
243c4e481f Add uri validation to response schemas:
* Add to root uri and template.uri in responses
* Add tests to validate invalid or missing uri
* General refactoring for clarity
2016-12-15 16:39:15 +00:00
Rebecca Law
7a623de171 Added boby and subject to the get_notifications schema 2016-12-15 16:19:55 +00:00
Imdad Ahad
431ec8acad Retrieve notifications by reference:
* Use get_notifications instead (references may not be unique)
2016-12-12 18:04:20 +00:00
Rebecca Law
4f9b295a5b Merge pull request #766 from alphagov/fix-sms-sender
Fix the from number in the post_sms_response.
2016-12-12 16:46:00 +00:00
Rebecca Law
9973d74d09 Fix the from number in the post_sms_response. If the service.sms_sender is not set the FROM_NUMBER from the config is returned, which is the default for the notification. 2016-12-12 15:07:03 +00:00
Imdad Ahad
620a90fd7c Make get_notifications return single notification by reference 2016-12-07 14:09:56 +00:00
Paul Craig
ab990679b3 Replace marshmallow with jsonschema
Created a new schema that accepts request parameters for the
get_notifications v2 route.
Using that to validate now instead of the marshmallow validation.

Also changed the way formatted error messages are returned because
the previous way was cutting off our failing `enum` messages.
2016-11-28 14:22:51 +00:00
Paul Craig
ffb813bb3f Add get_notifications json schema + tests
Add a schema that corresponds to our response for returning lists
of notifications, and test with a contract test.
2016-11-25 16:50:20 +00:00
Paul Craig
1fce30aaa7 Cost savings
The "cost" value was flawed for a couple of reasons.

1. Lots of messages are free, so in those instances the "cost"
   doesn't tell you anything
2. The query to get the rate was expensive and we don't have
   an obvious way to get it back very efficiently for large numbers
   of notifications.

So we scrapped it.
2016-11-25 15:23:03 +00:00
Rebecca Law
3cddc64e36 Merge pull request #741 from alphagov/fix-v2-post-notification
Small fixes for the V2 post notification endpoints
2016-11-22 16:28:13 +00:00
Rebecca Law
46beece158 For the post_sms_response and post_email_response the reference property is always present but the value can be null.
Added a test for an empty reference.
Remove datetime format on the created_at attribute of a notification, it is not needed.
2016-11-21 17:32:36 +00:00
Paul Craig
82ba2cd226 Create new notification schema
This is the schema that individual notifications will conform to
when they are returned from this API.
JSON logic enforces that the right keys are set depending on the
`"type"`. (eg a schema with `"type": "sms"` must have a
`"phone_number"` value and it cannot have an `"email_address"`)
2016-11-21 15:59:10 +00:00
Rebecca Law
bc434f1736 Create new column in notifications and notification_history to store the client_reference because I remembered that reference is used for email providers. 2016-11-17 13:42:34 +00:00
Rebecca Law
df62be421f Make email_from and subject required attributes of the email_content schema.
Update the format_checkers to raise the specific exception that why the validator can handle multiple messages.
Which led to a refactor of build_error_message.
2016-11-16 17:25:00 +00:00