Example #1
0
def get_token(login: Login) -> str:
    try:
        acc = CitybikeAccount(login)
        return acc.get_token()
    except LoginError:
        raise HTTPException(status_code=401, detail="Login invalid")
Example #2
0
async def get_account(
        login_bearer: HTTPAuthorizationCredentials = Security(login_bearer)):
    try:
        return CitybikeAccount(login_bearer.credentials)
    except LoginError:
        raise HTTPException(status_code=401, detail="Login invalid")
Example #3
0
def get_uphill_challenge_details(challenge_id: int,
                                 acc: CitybikeAccount = Depends(get_account)):
    details = acc.get_uphill_challenge_detail(challenge_id)
    if details is None:
        raise HTTPException(status_code=404, detail="Challenge not found")
    return details
Example #4
0
def accept_uphill_challenge(challenge_id: int,
                            acc: CitybikeAccount = Depends(get_account)):
    acc.accept_uphill_challenge(challenge_id)
Example #5
0
def cancel_current_uphill_challenge(
        acc: CitybikeAccount = Depends(get_account)):
    acc.cancel_current_uphill_challenge()
Example #6
0
def get_current_uphill_challenge(acc: CitybikeAccount = Depends(get_account)):
    return acc.get_current_uphill_challenge()
Example #7
0
def get_available_uphill_challenges(
        acc: CitybikeAccount = Depends(get_account)):
    return acc.get_uphill_challenges()
Example #8
0
def get_userinfo(acc: CitybikeAccount = Depends(get_account)):
    return acc.get_user_info()
Example #9
0
def get_rides_since(acc: CitybikeAccount, since: datetime = datetime.min):
    for r in acc.get_rides():
        if r.start_time >= since:
            yield r
        else:
            break