Esempio n. 1
0
def queues_enqueue_client(queue_id, client_id, system_id, source_id):
    try:
        if system_id == system_variables.LOCAL_SYSTEM_ID:
            if source_id == system_variables.RAILS_SYSTEM_ID:
                return response_renderer.successful_text_response(
                    rails_enqueue_client(queue_id, client_id))
            elif source_id == system_variables.PHP_SYSTEM_ID:
                return response_renderer.successful_text_response(
                    php_enqueue_client(queue_id, client_id))
            else:
                return response_renderer.successful_object_response(
                    enqueue_client(queue_id, client_id))
        else:
            return response_renderer.successful_text_response(
                external_enqueue_client(queue_id, client_id, system_id))
    except exceptions.InvalidParameter as e:
        return response_renderer.bad_request_error_response(e.message)
    except exceptions.NotFound as e:
        return response_renderer.not_found_error_response(e.message)
    except exceptions.RailsApiError as e:
        return response_renderer.bad_request_error_response(e.message)
    except exceptions.PhpApiError as e:
        return response_renderer.bad_request_error_response(e.message)
    except json.decoder.JSONDecodeError as e:
        return response_renderer.bad_request_error_response(
            "External API returned a non-parseable JSON")
Esempio n. 2
0
def queues_create(name, description, capacity, owner_id, longitude, latitude):
    try:
        new_queue = create_queue(name, description, owner_id, capacity,
                                 longitude, latitude)
        return response_renderer.successful_object_response(new_queue)
    except exceptions.InvalidParameter as e:
        return response_renderer.bad_request_error_response(e.message)
Esempio n. 3
0
def clients_create(name):
    try:
        new_client = create_client(name)
        return response_renderer.successful_object_response(new_client)
    except exceptions.InvalidParameter as e:
        return response_renderer.bad_request_error_response(e.message)
Esempio n. 4
0
def clients_show(client_id):
    try:
        data = get_client(client_id)
        return response_renderer.successful_object_response(data)
    except exceptions.NotFound as e:
        return response_renderer.not_found_error_response(e.message)
Esempio n. 5
0
def queues_serve_next(queue_id):
    try:
        attended_client = serve_next(queue_id)
        return response_renderer.successful_object_response(attended_client)
    except exceptions.InvalidParameter as e:
        return response_renderer.bad_request_error_response(e.message)
Esempio n. 6
0
def queues_show(queue_id):
    try:
        data = get_queue(queue_id)
        return response_renderer.successful_object_response(data)
    except exceptions.NotFound as e:
        return response_renderer.not_found_error_response(e.message)
Esempio n. 7
0
def owners_create(name):
    try:
        new_owner = create_owner(name)
        return response_renderer.successful_object_response(new_owner)
    except exceptions.InvalidParameter as e:
        return response_renderer.bad_request_error_response(e.message)
Esempio n. 8
0
def owners_show(owner_id):
    try:
        data = get_owner(owner_id)
        return response_renderer.successful_object_response(data)
    except exceptions.NotFound as e:
        return response_renderer.not_found_error_response(e.message)