mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-04 17:53:57 -05:00
Merge pull request #852 from alphagov/receive-sms-messages
Initial creation of the endpoint to receive sms messages
This commit is contained in:
@@ -123,6 +123,7 @@ def init_app(app):
|
||||
url_for('notifications.process_ses_response'),
|
||||
url_for('notifications.process_firetext_response'),
|
||||
url_for('notifications.process_mmg_response'),
|
||||
url_for('notifications.receive_mmg_sms'),
|
||||
url_for('status.show_delivery_status'),
|
||||
url_for('spec.get_spec')
|
||||
]
|
||||
|
||||
@@ -49,6 +49,15 @@ from app.errors import (
|
||||
register_errors(notifications)
|
||||
|
||||
|
||||
@notifications.route('/notifications/sms/receive/mmg', methods=['POST'])
|
||||
def receive_mmg_sms():
|
||||
post_data = request.get_json()
|
||||
post_data.pop('MSISDN', None)
|
||||
current_app.logger.info("Recieve notification form data: {}".format(post_data))
|
||||
|
||||
return "RECEIVED"
|
||||
|
||||
|
||||
@notifications.route('/notifications/email/ses', methods=['POST'])
|
||||
def process_ses_response():
|
||||
client_name = 'SES'
|
||||
|
||||
18
tests/app/notifications/test_receive_notification.py
Normal file
18
tests/app/notifications/test_receive_notification.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from flask import json
|
||||
|
||||
|
||||
def test_receive_notification_returns_received_to_mmg(client):
|
||||
data = {"ID": "1234",
|
||||
"MSISDN": "447700900855",
|
||||
"Message": "Some message to notify",
|
||||
"Trigger": "Trigger?",
|
||||
"Number": "40604",
|
||||
"Channel": "SMS",
|
||||
"DateReceived": "2012-06-27-12:33:00"
|
||||
}
|
||||
response = client.post(path='/notifications/sms/receive/mmg',
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json')])
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.get_data(as_text=True) == 'RECEIVED'
|
||||
Reference in New Issue
Block a user