|
6 | 6 | import requests |
7 | 7 | from .logbook import Logbook |
8 | 8 |
|
| 9 | + |
9 | 10 | class ClubLogError(Exception): |
10 | 11 | """An error raised when an issue occurs with the ClubLog API.""" |
11 | | - def __init__(self, message="An error occurred while interfacing with the ClubLog API"): |
| 12 | + |
| 13 | + def __init__( |
| 14 | + self, message="An error occurred while interfacing with the ClubLog API" |
| 15 | + ): |
12 | 16 | super().__init__(message) |
13 | 17 |
|
| 18 | + |
14 | 19 | class ClubLogClient: |
15 | 20 | """This is a wrapper for the ClubLog API, holding a user's authentication\ |
16 | 21 | to perform actions on their behalf. |
17 | 22 | """ |
18 | 23 |
|
19 | | - def __init__(self, email: str, callsign: str, password: str, |
20 | | - timeout: int = 15): |
| 24 | + def __init__(self, email: str, callsign: str, password: str, timeout: int = 15): |
21 | 25 | """Initializes a ClubLogClient object. |
22 | 26 |
|
23 | | - Args: |
24 | | - email (str): Email address for the ClubLog account |
25 | | - callsign (str): Callsign for the ClubLog account |
26 | | - password (str): Password for the ClubLog account |
27 | | - timeout (int, optional): Timeout for requests. Defaults to 15. |
| 27 | + Args: |
| 28 | + email (str): Email address for the ClubLog account |
| 29 | + callsign (str): Callsign for the ClubLog account |
| 30 | + password (str): Password for the ClubLog account |
| 31 | + timeout (int, optional): Timeout for requests. Defaults to 15. |
28 | 32 | """ |
29 | 33 | self.email = email |
30 | 34 | self.callsign = callsign |
31 | 35 | self.password = password |
32 | 36 | self.timeout = timeout |
33 | 37 | self.base_url = "https://clublog.org/getadif.php" |
34 | 38 |
|
35 | | - |
36 | 39 | def fetch_logbook(self) -> Logbook: |
37 | 40 | """Fetch the user's ClubLog logbook. |
38 | 41 | Raises: |
39 | 42 | HTTPError: An error occurred while trying to make a connection. |
40 | 43 | Returns: |
41 | 44 | qspylib.logbook.Logbook: A logbook containing the user's QSOs. |
42 | 45 | """ |
43 | | - data = { |
44 | | - 'email': self.email, |
45 | | - 'password': self.password, |
46 | | - 'call': self.callsign |
47 | | - } |
| 46 | + data = {"email": self.email, "password": self.password, "call": self.callsign} |
48 | 47 | # filter down to only used params |
49 | 48 | data = {k: v for k, v in data.items() if v is not None} |
50 | 49 |
|
|
0 commit comments