@@ -56,6 +56,7 @@ class Finch(SyncAPIClient):
56
56
hris : resources .HRIS
57
57
providers : resources .Providers
58
58
account : resources .Account
59
+ webhooks : resources .Webhooks
59
60
request_forwarding : resources .RequestForwarding
60
61
jobs : resources .Jobs
61
62
sandbox : resources .Sandbox
@@ -156,6 +157,7 @@ def __init__(
156
157
self .hris = resources .HRIS (self )
157
158
self .providers = resources .Providers (self )
158
159
self .account = resources .Account (self )
160
+ self .webhooks = resources .Webhooks (self )
159
161
self .request_forwarding = resources .RequestForwarding (self )
160
162
self .jobs = resources .Jobs (self )
161
163
self .sandbox = resources .Sandbox (self )
@@ -299,6 +301,70 @@ def copy(
299
301
# client.with_options(timeout=10).foo.create(...)
300
302
with_options = copy
301
303
304
+ def get_access_token (
305
+ self ,
306
+ code : str ,
307
+ * ,
308
+ redirect_uri : str | None = None ,
309
+ ) -> str :
310
+ """DEPRECATED: use client.access_tokens.create instead."""
311
+ if self .client_id is None :
312
+ raise ValueError ("Expected client_id to be set in order to call get_access_token" )
313
+
314
+ if self .client_secret is None :
315
+ raise ValueError ("Expected client_secret to be set in order to call get_access_token" )
316
+
317
+ response = self .post (
318
+ "/auth/token" ,
319
+ body = {
320
+ "client_id" : self .client_id ,
321
+ "client_secret" : self .client_secret ,
322
+ "code" : code ,
323
+ "redirect_uri" : redirect_uri ,
324
+ },
325
+ options = {"headers" : {"Authorization" : Omit ()}},
326
+ cast_to = httpx .Response ,
327
+ )
328
+ data = response .json ()
329
+ return str (data ["access_token" ])
330
+
331
+ def get_auth_url (
332
+ self ,
333
+ * ,
334
+ products : str ,
335
+ redirect_uri : str ,
336
+ sandbox : bool ,
337
+ ) -> str :
338
+ """
339
+ Returns the authorization url which can be visited in order to obtain an
340
+ authorization code from Finch. The authorization code can then be exchanged for
341
+ an access token for the Finch api by calling get_access_token().
342
+ """
343
+ if self .client_id is None :
344
+ raise ValueError ("Expected the client_id to be set in order to call get_auth_url" )
345
+
346
+ return str (
347
+ httpx .URL (
348
+ "https://connect.tryfinch.com/authorize" ,
349
+ params = {
350
+ "client_id" : self .client_id ,
351
+ "products" : products ,
352
+ "redirect_uri" : redirect_uri ,
353
+ "sandbox" : sandbox ,
354
+ },
355
+ )
356
+ )
357
+
358
+ def with_access_token (
359
+ self ,
360
+ access_token : str ,
361
+ ) -> Self :
362
+ """
363
+ Returns a copy of the current Finch client with the given access token for
364
+ authentication.
365
+ """
366
+ return self .with_options (access_token = access_token )
367
+
302
368
@override
303
369
def _make_status_error (
304
370
self ,
@@ -338,6 +404,7 @@ class AsyncFinch(AsyncAPIClient):
338
404
hris : resources .AsyncHRIS
339
405
providers : resources .AsyncProviders
340
406
account : resources .AsyncAccount
407
+ webhooks : resources .AsyncWebhooks
341
408
request_forwarding : resources .AsyncRequestForwarding
342
409
jobs : resources .AsyncJobs
343
410
sandbox : resources .AsyncSandbox
@@ -438,6 +505,7 @@ def __init__(
438
505
self .hris = resources .AsyncHRIS (self )
439
506
self .providers = resources .AsyncProviders (self )
440
507
self .account = resources .AsyncAccount (self )
508
+ self .webhooks = resources .AsyncWebhooks (self )
441
509
self .request_forwarding = resources .AsyncRequestForwarding (self )
442
510
self .jobs = resources .AsyncJobs (self )
443
511
self .sandbox = resources .AsyncSandbox (self )
@@ -581,6 +649,70 @@ def copy(
581
649
# client.with_options(timeout=10).foo.create(...)
582
650
with_options = copy
583
651
652
+ async def get_access_token (
653
+ self ,
654
+ code : str ,
655
+ * ,
656
+ redirect_uri : str | None = None ,
657
+ ) -> str :
658
+ """DEPRECATED: use client.access_tokens.create instead."""
659
+ if self .client_id is None :
660
+ raise ValueError ("Expected client_id to be set in order to call get_access_token" )
661
+
662
+ if self .client_secret is None :
663
+ raise ValueError ("Expected client_secret to be set in order to call get_access_token" )
664
+
665
+ response = await self .post (
666
+ "/auth/token" ,
667
+ body = {
668
+ "client_id" : self .client_id ,
669
+ "client_secret" : self .client_secret ,
670
+ "code" : code ,
671
+ "redirect_uri" : redirect_uri ,
672
+ },
673
+ options = {"headers" : {"Authorization" : Omit ()}},
674
+ cast_to = httpx .Response ,
675
+ )
676
+ data = response .json ()
677
+ return str (data ["access_token" ])
678
+
679
+ def get_auth_url (
680
+ self ,
681
+ * ,
682
+ products : str ,
683
+ redirect_uri : str ,
684
+ sandbox : bool ,
685
+ ) -> str :
686
+ """
687
+ Returns the authorization url which can be visited in order to obtain an
688
+ authorization code from Finch. The authorization code can then be exchanged for
689
+ an access token for the Finch api by calling get_access_token().
690
+ """
691
+ if self .client_id is None :
692
+ raise ValueError ("Expected the client_id to be set in order to call get_auth_url" )
693
+
694
+ return str (
695
+ httpx .URL (
696
+ "https://connect.tryfinch.com/authorize" ,
697
+ params = {
698
+ "client_id" : self .client_id ,
699
+ "products" : products ,
700
+ "redirect_uri" : redirect_uri ,
701
+ "sandbox" : sandbox ,
702
+ },
703
+ )
704
+ )
705
+
706
+ def with_access_token (
707
+ self ,
708
+ access_token : str ,
709
+ ) -> Self :
710
+ """
711
+ Returns a copy of the current Finch client with the given access token for
712
+ authentication.
713
+ """
714
+ return self .with_options (access_token = access_token )
715
+
584
716
@override
585
717
def _make_status_error (
586
718
self ,
0 commit comments