@@ -27,30 +27,26 @@ client = Finch(
27
27
access_token = " My Access Token" ,
28
28
)
29
29
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)
35
32
```
36
33
37
34
## Async usage
38
35
39
36
Simply import ` AsyncFinch ` instead of ` Finch ` and use ` await ` with each API call:
40
37
41
38
``` python
39
+ import asyncio
42
40
from finch import AsyncFinch
43
41
44
42
client = AsyncFinch(
45
43
access_token = " My Access Token" ,
46
44
)
47
45
48
46
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)
54
50
55
51
56
52
asyncio.run(main())
@@ -138,10 +134,8 @@ from finch import Finch
138
134
139
135
client = Finch()
140
136
141
- client.hris.directory.list(
142
- path_params = [],
143
- params = {},
144
- )
137
+ page = client.hris.directory.list()
138
+ print (page.page)
145
139
```
146
140
147
141
## Webhook Verification
@@ -183,7 +177,7 @@ from finch import Finch
183
177
client = Finch()
184
178
185
179
try :
186
- client.hris.directory.list ()
180
+ client.hris.company.retrieve ()
187
181
except finch.APIConnectionError as e:
188
182
print (" The server could not be reached" )
189
183
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
304
298
from finch import Finch
305
299
306
300
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()
310
302
print (response.headers.get(' X-My-Header' ))
311
303
312
304
directory = response.parse() # get the object that `hris.directory.list()` would have returned
313
- print (directory.first_name )
305
+ print (directory.id )
314
306
```
315
307
316
308
These methods return an [ ` APIResponse ` ] ( https://github.com/Finch-API/finch-api-python/src/finch/_response.py ) object.
0 commit comments