move status mapping logic to the api client

also added tests 👼
This commit is contained in:
Leo Hemsted
2017-09-20 16:02:15 +01:00
parent f8fab35ee7
commit 03397f416e
4 changed files with 41 additions and 12 deletions

View File

@@ -13,18 +13,9 @@ from app.notify_client.api_key_api_client import KEY_TYPE_NORMAL, KEY_TYPE_TEST,
def api_integration(service_id):
return render_template(
'views/api/index.html',
api_notifications=map_letters_to_accepted(notification_api_client.get_notifications_for_service(
service_id=service_id,
include_jobs=False,
include_from_test_key=True
))
api_notifications=notification_api_client.get_api_notifications_for_service(service_id)
)
def map_letters_to_accepted(notifications):
for notification in notifications['notifications']:
if notification['notification_type'] == 'letter' and notification['status'] in ('created', 'sending'):
notification['status'] = 'accepted'
return notifications
@main.route("/services/<service_id>/api/documentation")
@login_required