Log out the currently logged-in user.

    There's a really crappy side-effect here - the session_id
    attribute of the `client` passed in will be reset to None if the
    logout succeeds, which is going to be almost always, let's hope.

def logout(client):
    """Log out the currently logged-in user.

    There's a really crappy side-effect here - the session_id
    attribute of the `client` passed in will be reset to None if the
    logout succeeds, which is going to be almost always, let's hope.

    """
    if not client.session_id:
        client.request_session()

    concierge_request_header = client.construct_concierge_header(
        url=("http://membersuite.com/contracts/IConciergeAPIService/"
             "Logout"))

    logout_result = client.client.service.Logout(
        _soapheaders=[concierge_request_header])

    result = logout_result["body"]["LogoutResult"]

    if result["SessionID"] is None:  # Success!
        client.session_id = None
    else:  # Failure . . .
        raise LogoutError(result=result)