|
5 | 5 |
|
6 | 6 | @attr.s(auto_attribs=True)
|
7 | 7 | class Client:
|
8 |
| - """A class for keeping track of data related to the API""" |
| 8 | + """ A class for keeping track of data related to the API """ |
9 | 9 |
|
10 | 10 | base_url: str
|
11 | 11 | cookies: Dict[str, str] = attr.ib(factory=dict, kw_only=True)
|
12 | 12 | headers: Dict[str, str] = attr.ib(factory=dict, kw_only=True)
|
13 | 13 | timeout: float = attr.ib(5.0, kw_only=True)
|
14 | 14 |
|
15 | 15 | def get_headers(self) -> Dict[str, str]:
|
16 |
| - """Get headers to be used in all endpoints""" |
| 16 | + """ Get headers to be used in all endpoints """ |
17 | 17 | return {**self.headers}
|
18 | 18 |
|
19 | 19 | def with_headers(self, headers: Dict[str, str]) -> "Client":
|
20 |
| - """Get a new client matching this one with additional headers""" |
| 20 | + """ Get a new client matching this one with additional headers """ |
21 | 21 | return attr.evolve(self, headers={**self.headers, **headers})
|
22 | 22 |
|
23 | 23 | def get_cookies(self) -> Dict[str, str]:
|
24 | 24 | return {**self.cookies}
|
25 | 25 |
|
26 | 26 | def with_cookies(self, cookies: Dict[str, str]) -> "Client":
|
27 |
| - """Get a new client matching this one with additional cookies""" |
| 27 | + """ Get a new client matching this one with additional cookies """ |
28 | 28 | return attr.evolve(self, cookies={**self.cookies, **cookies})
|
29 | 29 |
|
30 | 30 | def get_timeout(self) -> float:
|
31 | 31 | return self.timeout
|
32 | 32 |
|
33 | 33 | def with_timeout(self, timeout: float) -> "Client":
|
34 |
| - """Get a new client matching this one with a new timeout (in seconds)""" |
| 34 | + """ Get a new client matching this one with a new timeout (in seconds) """ |
35 | 35 | return attr.evolve(self, timeout=timeout)
|
36 | 36 |
|
37 | 37 |
|
38 | 38 | @attr.s(auto_attribs=True)
|
39 | 39 | class AuthenticatedClient(Client):
|
40 |
| - """A Client which has been authenticated for use on secured endpoints""" |
| 40 | + """ A Client which has been authenticated for use on secured endpoints """ |
41 | 41 |
|
42 | 42 | token: str
|
43 | 43 |
|
44 | 44 | def get_headers(self) -> Dict[str, str]:
|
45 |
| - """Get headers to be used in authenticated endpoints""" |
| 45 | + """ Get headers to be used in authenticated endpoints """ |
46 | 46 | return {"Authorization": f"Bearer {self.token}", **self.headers}
|
0 commit comments