-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgeocoding.py
More file actions
30 lines (23 loc) · 823 Bytes
/
geocoding.py
File metadata and controls
30 lines (23 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import typing as t
from ..core.rate_limit import rate_limiter
from ..core.validation import validate_response
class TextGeocoding:
"""Manage text geocoding calls."""
def __init__(self, api):
"""Init."""
self.client = api
@rate_limiter
def post(self, text: str) -> t.Dict[str, t.Any]:
"""
Geocode a location text. Retrieve geojson data for a textual location
input.
(https://api.hrflow.ai/v1/text/geocoding).
Args:
text: <string>
The location text to geocode.
Returns:
Geojson data for the given location text.
"""
payload = {"text": text}
response = self.client.post("text/geocoding", json=payload)
return validate_response(response)