Beispiel #1
0
 def get_league_data(self) -> [LeagueData]:
     with self.db_mutex:
         res = list(self.league_data_collection.find())
     league_data = []
     for r in res:
         ld = LeagueData()
         ld.__dict__ = r
         ld.creation_date = ld.creation_date.replace(tzinfo=timezone.utc)
         league_data.append(ld)
     return league_data
Beispiel #2
0
    def login(self, username: str, password: str) -> (User, [LeagueData]):
        data = {
            "email": username,
            "password": password,
            "ext": False
        }

        r = self._do_post("/user/login", data, False)

        if r.status_code == 200:
            j = r.json()
            self.token = j["token"]
            self.token_expire = parse_date(j["tokenExp"])

            self._username = username
            self._password = password

            self.user = User(j["user"])
            league_data = [LeagueData(d) for d in j["leagues"]]
            return self.user, league_data

        elif r.status_code == 401:
            raise KickbaseLoginException()
        else:
            raise KickbaseException()
Beispiel #3
0
    def leagues(self) -> [LeagueData]:
        r = self._do_get("/leagues/", True)

        if r.status_code == 200:
            j = r.json()
            return [LeagueData(d) for d in j["leagues"]]
        else:
            raise KickbaseException()