def view_letter_notification_as_preview(service_id, notification_id, filetype):

    if filetype not in ('pdf', 'png'):
        abort(404)
    notification = notification_api_client.get_notification(
        service_id, str(notification_id))
    try:
        if notification['status'] == "validation-failed":
            preview = notification_api_client.get_notification_letter_preview_with_overlay(
                service_id,
                notification_id,
                filetype,
                page=request.args.get('page'))
        else:
            preview = notification_api_client.get_notification_letter_preview(
                service_id,
                notification_id,
                filetype,
                page=request.args.get('page'))

        display_file = base64.b64decode(preview['content'])
    except APIError:
        display_file = get_preview_error_image()

    return display_file
Exemple #2
0
def get_letter_file_data(service_id, notification_id, filetype, with_metadata=False):
    try:
        preview = notification_api_client.get_notification_letter_preview(
            service_id,
            notification_id,
            filetype,
            page=request.args.get('page')
        )

        display_file = base64.b64decode(preview['content'])
    except APIError:
        display_file = get_preview_error_image()
        preview = {"metadata": {}}

    if with_metadata:
        return display_file, preview['metadata']
    return display_file
Exemple #3
0
def view_letter_notification_as_preview(service_id, notification_id, filetype):

    if filetype not in ('pdf', 'png'):
        abort(404)

    try:
        preview = notification_api_client.get_notification_letter_preview(
            service_id,
            notification_id,
            filetype,
            page=request.args.get('page'))

        display_file = base64.b64decode(preview['content'])
    except APIError:
        display_file = get_preview_error_image()

    return display_file