def METHOD_NAME(result_out, part_msg, log, piid_flag=None):
    """Checks the status of the API endpoint and makes the appropriate print outs."""
    passed = '\033[1;32m...passed\033[1;0m'
    failed = '\033[1;31m...failed\033[1;0m'
    if result_out.status_code in [200, 201, 403, 401]:
        try:
            if piid_flag == 'export':
                content_str = result_out.content.decode()
                if content_str.startswith('id'):
                    msg = "Data exported successfully"
                    # the data are returned as text. No easy way to check the status. If ID
                    # exists, then claim success.
                else:
                    msg = content_str
            elif 'status' in result_out.json() and result_out.json()['status'] == 'error':
                msg = result_out.json()['message']
                log.error(part_msg + failed)
                log.debug(msg)
                raise RuntimeError
            elif 'success' in result_out.json() and not result_out.json()['success']:
                msg = result_out.json()
                log.error(part_msg + failed)
                log.debug(msg)
                raise RuntimeError
            else:
                if piid_flag == 'organizations':
                    msg = 'Number of organizations:\t' + str(
                        len(result_out.json()['organizations'][0]))
                elif piid_flag == 'users':
                    msg = 'Number of users:\t' + str(len(result_out.json()['users'][0]))
                elif piid_flag == 'mappings':
                    msg = pprint.pformat(result_out.json()['suggested_column_mappings'],
                                         indent=2, width=70)
                else:
                    msg = pprint.pformat(result_out.json(), indent=2, width=70)
        except BaseException:
            log.error(part_msg + failed)
            log.debug('Unknown error during request results recovery')
            raise RuntimeError
        log.info(part_msg + passed)
        log.debug(msg)
    elif result_out.status_code in [204]:
        msg = result_out.content
        log.info(part_msg + passed)
        log.debug(msg)
    else:
        msg = result_out.reason
        log.error(part_msg + failed)
        log.debug(msg)
        raise RuntimeError
    return