예제 #1
0
def request_user_email(user_id, github_api_auth):
    """
    Get email from the profile
    """

    rsp = requests.get(EndPoint.add_auth_info(EndPoint.user_profile(user_id), github_api_auth))
    # raise error when found nothing
    rsp.raise_for_status()

    rsp = rsp.json()
    ge = GithubUserEmail()
    ge.g_id = rsp['login']
    ge.name = rsp['name'].strip() if rsp['name'] else rsp['login']
    ge.email = rsp['email']
    ge.from_profile = True

    # Get user email from events
    if ge.email is None:
        rsp = requests.get(EndPoint.add_auth_info(EndPoint.user_events(user_id), github_api_auth))
        # raise error when found nothing
        rsp.raise_for_status()

        email = get_email_from_events(rsp, ge.name)
        if email is not None:
            ge.email = email
            ge.from_profile = False
        
    return ge
def request_user_email(user_id, github_api_auth):
    """
    Get email from the profile
    """

    rsp = requests.get(
        EndPoint.add_auth_info(EndPoint.user_profile(user_id),
                               github_api_auth))
    # raise error when found nothing
    rsp.raise_for_status()

    rsp = rsp.json()
    ge = GithubUserEmail()
    ge.g_id = rsp['login']
    ge.name = rsp['name'].strip() if rsp['name'] else rsp['login']
    ge.email = rsp['email']
    ge.from_profile = True

    # Get user email from events
    if ge.email is None:
        rsp = requests.get(
            EndPoint.add_auth_info(EndPoint.user_events(user_id),
                                   github_api_auth))
        # raise error when found nothing
        rsp.raise_for_status()

        email = get_email_from_events(rsp, ge.name)
        if email is not None:
            ge.email = email
            ge.from_profile = False

    return ge
예제 #3
0
def request_user_email(user_id, github_api_auth):
    """
    Get email from the profile
    """

    rsp = requests.get(EndPoint.add_auth_info(EndPoint.user_profile(user_id), github_api_auth))
    # raise error when found nothing
    rsp.raise_for_status()

    rsp = rsp.json()
    ge = GithubUserEmail()
    ge.g_id = rsp['login']
    ge.name = rsp['name'] if rsp['name'] else rsp['login']
    ge.email = rsp['email']

    # TODO user email from events

    return ge
예제 #4
0
def request_user_email(user_id, github_api_auth):
    """
    Get email from the profile
    """

    rsp = requests.get(
        EndPoint.add_auth_info(EndPoint.user_profile(user_id),
                               github_api_auth))
    # raise error when found nothing
    rsp.raise_for_status()

    rsp = rsp.json()
    ge = GithubUserEmail()
    ge.g_id = rsp['login']
    ge.name = rsp['name'] if rsp['name'] else rsp['login']
    ge.email = rsp['email']

    # TODO user email from events

    return ge