(self, as_client: httpx.AsyncClient, bssid: str, body: dict)
| 31 | self._load_api(creds, headers) |
| 32 | |
| 33 | async def geolocate(self, as_client: httpx.AsyncClient, bssid: str, body: dict) -> Tuple[bool, GeolocationResponse]: |
| 34 | endpoint_name = inspect.currentframe().f_code.co_name |
| 35 | |
| 36 | verb = "POST" |
| 37 | base_url = f"/geolocation/v1/geolocate" |
| 38 | data_type = "json" # json, data or None |
| 39 | |
| 40 | if bssid: |
| 41 | payload = { |
| 42 | "considerIp": False, |
| 43 | "wifiAccessPoints": [ |
| 44 | { |
| 45 | "macAddress": "00:25:9c:cf:1c:ad" |
| 46 | }, |
| 47 | { |
| 48 | "macAddress": bssid |
| 49 | }, |
| 50 | ] |
| 51 | } |
| 52 | else: |
| 53 | payload = body |
| 54 | |
| 55 | self._load_endpoint(endpoint_name) |
| 56 | req = await self._query(as_client, verb, endpoint_name, base_url, None, payload, data_type) |
| 57 | |
| 58 | # Parsing |
| 59 | data = json.loads(req.text) |
| 60 | |
| 61 | resp = GeolocationResponse() |
| 62 | if "error" in data: |
| 63 | return False, resp |
| 64 | |
| 65 | resp._scrape(data) |
| 66 | |
| 67 | return True, resp |
no test coverage detected