Esempio n. 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")
Esempio n. 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")
Esempio n. 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
Esempio n. 4
0
def accept_uphill_challenge(challenge_id: int,
                            acc: CitybikeAccount = Depends(get_account)):
    acc.accept_uphill_challenge(challenge_id)
Esempio n. 5
0
def cancel_current_uphill_challenge(
        acc: CitybikeAccount = Depends(get_account)):
    acc.cancel_current_uphill_challenge()
Esempio n. 6
0
def get_current_uphill_challenge(acc: CitybikeAccount = Depends(get_account)):
    return acc.get_current_uphill_challenge()
Esempio n. 7
0
def get_available_uphill_challenges(
        acc: CitybikeAccount = Depends(get_account)):
    return acc.get_uphill_challenges()
Esempio n. 8
0
def get_userinfo(acc: CitybikeAccount = Depends(get_account)):
    return acc.get_user_info()
Esempio n. 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