Skip to content

Commit 37fe000

Browse files
docs(readme): improve example snippets (#169)
1 parent 69faf73 commit 37fe000

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

README.md

+11-19
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,26 @@ client = Finch(
2727
access_token="My Access Token",
2828
)
2929

30-
page = client.hris.directory.list(
31-
candidate_id="<candidate id>",
32-
)
33-
directory = page.individuals[0]
34-
print(directory.first_name)
30+
page = client.hris.directory.list()
31+
print(page.page)
3532
```
3633

3734
## Async usage
3835

3936
Simply import `AsyncFinch` instead of `Finch` and use `await` with each API call:
4037

4138
```python
39+
import asyncio
4240
from finch import AsyncFinch
4341

4442
client = AsyncFinch(
4543
access_token="My Access Token",
4644
)
4745

4846

49-
async def main():
50-
page = await client.hris.directory.list(
51-
candidate_id="<candidate id>",
52-
)
53-
print(page.individuals[0].first_name)
47+
async def main() -> None:
48+
page = await client.hris.directory.list()
49+
print(page.page)
5450

5551

5652
asyncio.run(main())
@@ -138,10 +134,8 @@ from finch import Finch
138134

139135
client = Finch()
140136

141-
client.hris.directory.list(
142-
path_params=[],
143-
params={},
144-
)
137+
page = client.hris.directory.list()
138+
print(page.page)
145139
```
146140

147141
## Webhook Verification
@@ -183,7 +177,7 @@ from finch import Finch
183177
client = Finch()
184178

185179
try:
186-
client.hris.directory.list()
180+
client.hris.company.retrieve()
187181
except finch.APIConnectionError as e:
188182
print("The server could not be reached")
189183
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -304,13 +298,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
304298
from finch import Finch
305299

306300
client = Finch()
307-
page = client.hris.directory.with_raw_response.list()
308-
response = page.individuals[0]
309-
301+
response = client.hris.directory.with_raw_response.list()
310302
print(response.headers.get('X-My-Header'))
311303

312304
directory = response.parse() # get the object that `hris.directory.list()` would have returned
313-
print(directory.first_name)
305+
print(directory.id)
314306
```
315307

316308
These methods return an [`APIResponse`](https://github.com/Finch-API/finch-api-python/src/finch/_response.py) object.

0 commit comments

Comments
 (0)