File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ class GeocachingApi:
3535 def __init__ (
3636 self ,
3737 * ,
38+ token : str ,
3839 request_timeout : int = 8 ,
3940 session : Optional [ClientSession ] = None ,
4041 token_refresh_method : Optional [Callable [[], Awaitable [str ]]] = None ,
41- token : str ,
4242 ) -> None :
4343 """Initialize connection with the Geocaching API."""
4444 self ._session = session
@@ -121,7 +121,16 @@ async def update(self) -> GeocachingStatus:
121121 async def _update_user (self , data : Dict [str , Any ] = None ) -> None :
122122 assert self ._status
123123 if data is None :
124- data = await self ._request ("GET" , f"/{ GEOCACHING_API_VERSION } /users/me?fields=username,referenceCode" )
124+ fields = "," .join ([
125+ "username" ,
126+ "referenceCode" ,
127+ "findCount" ,
128+ "hideCount" ,
129+ "favoritePoints" ,
130+ "souvenirCount" ,
131+ "awardedFavoritePoints"
132+ ])
133+ data = await self ._request ("GET" , f"/{ GEOCACHING_API_VERSION } /users/me?fields={ fields } " )
125134 self ._status .user .update_from_dict (data )
126135
127136 async def close (self ) -> None :
Original file line number Diff line number Diff line change 55
66@dataclass
77class GeocachingUser :
8- username : Optional [str ] = None
98 reference_code : Optional [str ] = None
9+ username : Optional [str ] = None
10+ find_count : Optional [int ] = None
11+ hide_count : Optional [int ] = None
12+ favorite_points : Optional [int ] = None
13+ souvenir_count : Optional [int ] = None
14+ awarded_favorite_points : Optional [int ] = None
1015
1116 def update_from_dict (self , data : Dict [str , Any ]) -> None :
1217 if "username" in data :
1318 self .username = data ["username" ]
1419 if "reference" in data :
1520 self .reference_code = data ["referenceCode" ]
21+ if "findCount" in data :
22+ self .find_count = data ["findCount" ]
23+ if "hideCount" in data :
24+ self .hide_count = data ["hideCount" ]
25+ if "favoritePoints" in data :
26+ self .favorite_points = data ["favoritePoints" ]
27+ if "souvenirCount" in data :
28+ self .souvenir_count = data ["souvenirCount" ]
29+ if "awardedFavoritePoints" in data :
30+ self .awarded_favorite_points = data ["awardedFavoritePoints" ]
1631
1732 pass
1833
Original file line number Diff line number Diff line change @@ -10,4 +10,6 @@ async def test():
1010 status :GeocachingStatus = None
1111 api = GeocachingApi (token = TOKEN )
1212 status = await api .update ()
13- assert (status .user .username is not None )
13+
14+ assert (status .user .username is not None )
15+ assert (status .user .find_count is not None )
You can’t perform that action at this time.
0 commit comments