Skip to content

docs(readme): improve example snippets #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,26 @@ client = Finch(
access_token="My Access Token",
)

page = client.hris.directory.list(
candidate_id="<candidate id>",
)
directory = page.individuals[0]
print(directory.first_name)
page = client.hris.directory.list()
print(page.page)
```

## Async usage

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

```python
import asyncio
from finch import AsyncFinch

client = AsyncFinch(
access_token="My Access Token",
)


async def main():
page = await client.hris.directory.list(
candidate_id="<candidate id>",
)
print(page.individuals[0].first_name)
async def main() -> None:
page = await client.hris.directory.list()
print(page.page)


asyncio.run(main())
Expand Down Expand Up @@ -138,10 +134,8 @@ from finch import Finch

client = Finch()

client.hris.directory.list(
path_params=[],
params={},
)
page = client.hris.directory.list()
print(page.page)
```

## Webhook Verification
Expand Down Expand Up @@ -183,7 +177,7 @@ from finch import Finch
client = Finch()

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

client = Finch()
page = client.hris.directory.with_raw_response.list()
response = page.individuals[0]

response = client.hris.directory.with_raw_response.list()
print(response.headers.get('X-My-Header'))

directory = response.parse() # get the object that `hris.directory.list()` would have returned
print(directory.first_name)
print(directory.id)
```

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