Skip to content

Commit cce9350

Browse files
committed
feat: Finish implementation of feature/lists-api-support
- feat: add custom error classes for handling HTTP errors - added `_check_response` for standardized error handling. - Refactored client List methods to use correct file upload logic - restructured test cases for list-related features. - added dependencies for dev to pyproject.toml
1 parent abc6209 commit cce9350

File tree

13 files changed

+512
-53
lines changed

13 files changed

+512
-53
lines changed

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Development Installation
4141
Usage
4242
-----
4343

44+
### Geocoding
45+
4446
```python
4547
from geocodio import GeocodioClient
4648
@@ -71,6 +73,72 @@ data = client.geocode(
7173
print(data)
7274
```
7375

76+
### List API
77+
78+
The List API allows you to manage lists of addresses or coordinates for batch processing.
79+
80+
```python
81+
from geocodio import GeocodioClient
82+
83+
# Initialize the client with your API key
84+
client = GeocodioClient("YOUR_API_KEY")
85+
86+
# Create a new list
87+
new_list = client.create_list(
88+
name="My Addresses",
89+
description="A list of addresses to geocode",
90+
items=[
91+
"1600 Pennsylvania Ave, Washington, DC",
92+
"1 Infinite Loop, Cupertino, CA"
93+
]
94+
)
95+
print(new_list)
96+
97+
# Get all lists
98+
lists = client.get_lists()
99+
print(lists)
100+
101+
# Get a specific list
102+
list_id = new_list.list.id
103+
list_details = client.get_list(list_id)
104+
print(list_details)
105+
106+
# Update a list
107+
updated_list = client.update_list(
108+
list_id=list_id,
109+
name="Updated List Name",
110+
description="Updated description"
111+
)
112+
print(updated_list)
113+
114+
# Add items to a list
115+
added_items = client.add_items_to_list(
116+
list_id=list_id,
117+
items=[
118+
"123 Anywhere St, Chicago, IL",
119+
"456 Oak St, Los Angeles, CA"
120+
]
121+
)
122+
print(added_items)
123+
124+
# Geocode all items in a list
125+
geocoded_list = client.geocode_list(
126+
list_id=list_id,
127+
fields=["timezone", "cd"]
128+
)
129+
print(geocoded_list)
130+
131+
# Remove items from a list
132+
item_ids = [item.id for item in added_items.items]
133+
client.remove_items_from_list(
134+
list_id=list_id,
135+
item_ids=item_ids
136+
)
137+
138+
# Delete a list
139+
client.delete_list(list_id)
140+
```
141+
74142
Error Handling
75143
--------------
76144
@@ -93,4 +161,4 @@ Issues: <https://github.com/geocodio/geocodio-library-python/issues>
93161
License
94162
-------
95163
96-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
164+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

pyproject.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,24 @@ classifiers = [
2424
"Topic :: Software Development :: Libraries :: Python Modules",
2525
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
2626
"Topic :: Scientific/Engineering :: GIS",
27-
"Framework :: HTTP Client",
2827
]
2928
dependencies = [
3029
"httpx>=0.24.0",
3130
]
3231

32+
[project.optional-dependencies]
33+
dev = [
34+
"pytest>=7.0.0",
35+
"pytest-cov>=4.0.0",
36+
"pytest-mock>=3.10.0",
37+
"pytest-httpx>=0.27.0",
38+
"black>=23.0.0",
39+
"isort>=5.12.0",
40+
"flake8>=6.0.0",
41+
"mypy>=1.0.0",
42+
"python-dotenv>=1.0.0",
43+
]
44+
3345
[project.urls]
3446
Homepage = "https://geocod.io"
3547
Documentation = "https://geocodio.readthedocs.io"
@@ -44,4 +56,4 @@ testpaths = ["tests"]
4456
python_files = "test_*.py"
4557
python_functions = "test_*"
4658
python_classes = "Test*"
47-
addopts = "-v --cov=geocodio --cov-report=term-missing"
59+
addopts = "-v --cov=geocodio --cov-report=term-missing"

0 commit comments

Comments
 (0)