diff --git a/app/main/__init__.py b/app/main/__init__.py index 05c023144..042aa1e3d 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -21,7 +21,7 @@ from app.main.views import ( # noqa styleguide, user_profile, choose_service, - api_integration, + api_keys, manage_users, invites, feedback, diff --git a/app/main/validators.py b/app/main/validators.py index e183f3d89..709274dda 100644 --- a/app/main/validators.py +++ b/app/main/validators.py @@ -1,5 +1,5 @@ from wtforms import ValidationError -from notifications_utils.template import Template +from notifications_utils.field import Field from notifications_utils.gsm import get_non_gsm_compatible_characters from app import formatted_list @@ -45,11 +45,11 @@ class ValidGovEmail: class NoCommasInPlaceHolders: - def __init__(self, message='You can’t have commas in your fields'): + def __init__(self, message='You can’t put commas between double brackets'): self.message = message def __call__(self, form, field): - if ',' in ''.join(Template({'content': field.data}).placeholders): + if ',' in ''.join(Field(field.data).placeholders): raise ValidationError(self.message) diff --git a/app/main/views/api_integration.py b/app/main/views/api_keys.py similarity index 99% rename from app/main/views/api_integration.py rename to app/main/views/api_keys.py index 4f3abd346..224121c40 100644 --- a/app/main/views/api_integration.py +++ b/app/main/views/api_keys.py @@ -161,7 +161,8 @@ def api_callbacks(service_id): return render_template( 'views/api/callbacks.html', - received_text_messages_callback=received_text_messages_callback['url'] if received_text_messages_callback else None, + received_text_messages_callback=received_text_messages_callback['url'] + if received_text_messages_callback else None, delivery_status_callback=delivery_status_callback['url'] if delivery_status_callback else None ) diff --git a/app/templates/views/api/callbacks/delivery-status-callback.html b/app/templates/views/api/callbacks/delivery-status-callback.html index b81effaad..ab51f4cb8 100644 --- a/app/templates/views/api/callbacks/delivery-status-callback.html +++ b/app/templates/views/api/callbacks/delivery-status-callback.html @@ -18,12 +18,12 @@
{{ textbox( form.url, - width='2-3', - hint='Valid https URL' + width='1-1', + hint='Must start with https://' ) }} {{ textbox( form.bearer_token, - width='2-3', + width='1-1', hint='At least 10 characters', autocomplete='new-password' ) }} diff --git a/app/templates/views/api/callbacks/received-text-messages-callback.html b/app/templates/views/api/callbacks/received-text-messages-callback.html index 423f55fc3..ed9b4f13e 100644 --- a/app/templates/views/api/callbacks/received-text-messages-callback.html +++ b/app/templates/views/api/callbacks/received-text-messages-callback.html @@ -18,12 +18,12 @@ {{ textbox( form.url, - width='2-3', - hint='Valid https URL' + width='1-1', + hint='Must start with https://' ) }} {{ textbox( form.bearer_token, - width='2-3', + width='1-1', hint='At least 10 characters', autocomplete='new-password' ) }} diff --git a/app/templates/views/callbacks.html b/app/templates/views/callbacks.html index 107a01bcf..c17c129b9 100644 --- a/app/templates/views/callbacks.html +++ b/app/templates/views/callbacks.html @@ -15,31 +15,6 @@

You’ll need to provide a bearer token, for security. We’ll add this to the authorisation header of the callback request.

The callback message is in JSON.

-

Text messages you receive

-

If your service receives text messages in Notify, we can forward them to your callback URL as soon as they arrive.

-
- {% call mapping_table( - caption='Callback message format', - field_headings=['Key', 'Description', 'Format'], - field_headings_visible=True, - caption_visible=False - ) %} - {% for key, description, format in [ - ('id', 'Notify’s id for the received message', 'UUID'), - ('source_number', 'The phone number the message was sent from', '447700912345'), - ('destination_number', 'The number the message was sent to (your number)', '07700987654'), - ('message', 'The received message', 'Hello Notify!'), - ('date_received', 'The UTC datetime that the message was received by Notify', '2017-05-14T12:15:30.000000Z') - ] %} - {% call row() %} - {% call row_heading() %} {{ key }} {% endcall %} - {{ text_field(description) }} - {{ text_field(format) }} - {% endcall %} - {% endfor %} - {% endcall %} -
-

Email and text message delivery receipts

When you send an email or text message through Notify, we can send a receipt to your callback URL to tell you if we were able to deliver it or not.

@@ -68,4 +43,28 @@ {% endcall %}
+

Text messages you receive

+

If your service receives text messages in Notify, we can forward them to your callback URL as soon as they arrive.

+
+ {% call mapping_table( + caption='Callback message format', + field_headings=['Key', 'Description', 'Format'], + field_headings_visible=True, + caption_visible=False + ) %} + {% for key, description, format in [ + ('id', 'Notify’s id for the received message', 'UUID'), + ('source_number', 'The phone number the message was sent from', '447700912345'), + ('destination_number', 'The number the message was sent to (your number)', '07700987654'), + ('message', 'The received message', 'Hello Notify!'), + ('date_received', 'The UTC datetime that the message was received by Notify', '2017-05-14T12:15:30.000000Z') + ] %} + {% call row() %} + {% call row_heading() %} {{ key }} {% endcall %} + {{ text_field(description) }} + {{ text_field(format) }} + {% endcall %} + {% endfor %} + {% endcall %} +
{% endblock %} diff --git a/tests/app/main/test_validators.py b/tests/app/main/test_validators.py index 7c494312b..d2b5fe574 100644 --- a/tests/app/main/test_validators.py +++ b/tests/app/main/test_validators.py @@ -149,7 +149,7 @@ def test_for_commas_in_placeholders( ): with pytest.raises(ValidationError) as error: NoCommasInPlaceHolders()(None, _gen_mock_field('Hello ((name,date))')) - assert str(error.value) == 'You can’t have commas in your fields' + assert str(error.value) == 'You can’t put commas between double brackets' NoCommasInPlaceHolders()(None, _gen_mock_field('Hello ((name))')) diff --git a/tests/app/main/views/test_api_integration.py b/tests/app/main/views/test_api_keys.py similarity index 100% rename from tests/app/main/views/test_api_integration.py rename to tests/app/main/views/test_api_keys.py