Skip to content

Commit a05398c

Browse files
feat(api): add /forward endpoint and other updates (#115)
1 parent 7a28f16 commit a05398c

22 files changed

+1196
-9
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 18
1+
configured_endpoints: 20

api.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# Finch
22

3+
Types:
4+
5+
```python
6+
from finch.types import ForwardResponse
7+
```
8+
39
Methods:
410

11+
- <code title="post /forward">client.<a href="./src/finch/_client.py">forward</a>(\*\*<a href="src/finch/types/top_level_forward_params.py">params</a>) -> <a href="./src/finch/types/forward_response.py">ForwardResponse</a></code>
512
- <code>client.<a href="./src/finch/_client.py">get_access_token</a>(\*args) -> str</code>
613
- <code>client.<a href="./src/finch/_client.py">get_auth_url</a>(\*args) -> str</code>
714

@@ -138,7 +145,7 @@ Methods:
138145
Types:
139146

140147
```python
141-
from finch.types import Provider
148+
from finch.types import BenefitSupportType, Provider
142149
```
143150

144151
Methods:
@@ -164,3 +171,17 @@ Methods:
164171

165172
- <code>client.webhooks.<a href="./src/finch/resources/webhooks.py">unwrap</a>(\*args) -> object</code>
166173
- <code>client.webhooks.<a href="./src/finch/resources/webhooks.py">verify_signature</a>(\*args) -> None</code>
174+
175+
# Employer
176+
177+
## Benefits
178+
179+
Types:
180+
181+
```python
182+
from finch.types.employer import RegisterCompanyBenefitsResponse
183+
```
184+
185+
Methods:
186+
187+
- <code title="post /employer/benefits/register">client.employer.benefits.<a href="./src/finch/resources/employer/benefits.py">register</a>(\*\*<a href="src/finch/types/employer/benefit_register_params.py">params</a>) -> <a href="./src/finch/types/employer/register_company_benefits_response.py">RegisterCompanyBenefitsResponse</a></code>

src/finch/_client.py

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@
1010

1111
from . import resources, _exceptions
1212
from ._qs import Querystring
13+
from .types import ForwardResponse, top_level_forward_params
1314
from ._types import (
1415
NOT_GIVEN,
16+
Body,
1517
Omit,
18+
Query,
1619
Headers,
1720
Timeout,
1821
NotGiven,
1922
Transport,
2023
ProxiesTypes,
2124
RequestOptions,
2225
)
26+
from ._utils import maybe_transform
2327
from ._version import __version__
2428
from ._streaming import Stream as Stream
2529
from ._streaming import AsyncStream as AsyncStream
@@ -30,6 +34,7 @@
3034
DEFAULT_MAX_RETRIES,
3135
SyncAPIClient,
3236
AsyncAPIClient,
37+
make_request_options,
3338
)
3439

3540
__all__ = [
@@ -50,6 +55,7 @@ class Finch(SyncAPIClient):
5055
providers: resources.Providers
5156
account: resources.Account
5257
webhooks: resources.Webhooks
58+
employer: resources.Employer
5359

5460
# client options
5561
access_token: str | None
@@ -123,6 +129,7 @@ def __init__(
123129
self.providers = resources.Providers(self)
124130
self.account = resources.Account(self)
125131
self.webhooks = resources.Webhooks(self)
132+
self.employer = resources.Employer(self)
126133

127134
@property
128135
def qs(self) -> Querystring:
@@ -216,6 +223,72 @@ def copy(
216223
def __del__(self) -> None:
217224
self.close()
218225

226+
def forward(
227+
self,
228+
*,
229+
method: str,
230+
route: str,
231+
data: Optional[str] | NotGiven = NOT_GIVEN,
232+
headers: Optional[object] | NotGiven = NOT_GIVEN,
233+
params: Optional[object] | NotGiven = NOT_GIVEN,
234+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
235+
# The extra values given here take precedence over values defined on the client or passed to this method.
236+
extra_headers: Headers | None = None,
237+
extra_query: Query | None = None,
238+
extra_body: Body | None = None,
239+
timeout: float | None | NotGiven = NOT_GIVEN,
240+
) -> ForwardResponse:
241+
"""The Forward API allows you to make direct requests to an employment system.
242+
243+
If
244+
Finch’s unified API doesn’t have a data model that cleanly fits your needs, then
245+
Forward allows you to push or pull data models directly against an integration’s
246+
API.
247+
248+
Args:
249+
method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
250+
, `PUT` , `DELETE` , and `PATCH`.
251+
252+
route: The URL route path for the forwarded request. This value must begin with a
253+
forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
254+
underscores.
255+
256+
data: The body for the forwarded request. This value must be specified as either a
257+
string or a valid JSON object.
258+
259+
headers: The HTTP headers to include on the forwarded request. This value must be
260+
specified as an object of key-value pairs. Example:
261+
`{"Content-Type": "application/xml", "X-API-Version": "v1" }`
262+
263+
params: The query parameters for the forwarded request. This value must be specified as
264+
a valid JSON object rather than a query string.
265+
266+
extra_headers: Send extra headers
267+
268+
extra_query: Add additional query parameters to the request
269+
270+
extra_body: Add additional JSON properties to the request
271+
272+
timeout: Override the client-level default timeout for this request, in seconds
273+
"""
274+
return self.post(
275+
"/forward",
276+
body=maybe_transform(
277+
{
278+
"method": method,
279+
"route": route,
280+
"data": data,
281+
"headers": headers,
282+
"params": params,
283+
},
284+
top_level_forward_params.TopLevelForwardParams,
285+
),
286+
options=make_request_options(
287+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
288+
),
289+
cast_to=ForwardResponse,
290+
)
291+
219292
def get_access_token(
220293
self,
221294
code: str,
@@ -313,6 +386,7 @@ class AsyncFinch(AsyncAPIClient):
313386
providers: resources.AsyncProviders
314387
account: resources.AsyncAccount
315388
webhooks: resources.AsyncWebhooks
389+
employer: resources.AsyncEmployer
316390

317391
# client options
318392
access_token: str | None
@@ -386,6 +460,7 @@ def __init__(
386460
self.providers = resources.AsyncProviders(self)
387461
self.account = resources.AsyncAccount(self)
388462
self.webhooks = resources.AsyncWebhooks(self)
463+
self.employer = resources.AsyncEmployer(self)
389464

390465
@property
391466
def qs(self) -> Querystring:
@@ -482,6 +557,72 @@ def __del__(self) -> None:
482557
except Exception:
483558
pass
484559

560+
async def forward(
561+
self,
562+
*,
563+
method: str,
564+
route: str,
565+
data: Optional[str] | NotGiven = NOT_GIVEN,
566+
headers: Optional[object] | NotGiven = NOT_GIVEN,
567+
params: Optional[object] | NotGiven = NOT_GIVEN,
568+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
569+
# The extra values given here take precedence over values defined on the client or passed to this method.
570+
extra_headers: Headers | None = None,
571+
extra_query: Query | None = None,
572+
extra_body: Body | None = None,
573+
timeout: float | None | NotGiven = NOT_GIVEN,
574+
) -> ForwardResponse:
575+
"""The Forward API allows you to make direct requests to an employment system.
576+
577+
If
578+
Finch’s unified API doesn’t have a data model that cleanly fits your needs, then
579+
Forward allows you to push or pull data models directly against an integration’s
580+
API.
581+
582+
Args:
583+
method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
584+
, `PUT` , `DELETE` , and `PATCH`.
585+
586+
route: The URL route path for the forwarded request. This value must begin with a
587+
forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
588+
underscores.
589+
590+
data: The body for the forwarded request. This value must be specified as either a
591+
string or a valid JSON object.
592+
593+
headers: The HTTP headers to include on the forwarded request. This value must be
594+
specified as an object of key-value pairs. Example:
595+
`{"Content-Type": "application/xml", "X-API-Version": "v1" }`
596+
597+
params: The query parameters for the forwarded request. This value must be specified as
598+
a valid JSON object rather than a query string.
599+
600+
extra_headers: Send extra headers
601+
602+
extra_query: Add additional query parameters to the request
603+
604+
extra_body: Add additional JSON properties to the request
605+
606+
timeout: Override the client-level default timeout for this request, in seconds
607+
"""
608+
return await self.post(
609+
"/forward",
610+
body=maybe_transform(
611+
{
612+
"method": method,
613+
"route": route,
614+
"data": data,
615+
"headers": headers,
616+
"params": params,
617+
},
618+
top_level_forward_params.TopLevelForwardParams,
619+
),
620+
options=make_request_options(
621+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
622+
),
623+
cast_to=ForwardResponse,
624+
)
625+
485626
async def get_access_token(
486627
self,
487628
code: str,

src/finch/resources/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
from .hris import HRIS, AsyncHRIS
44
from .account import Account, AsyncAccount
5+
from .employer import Employer, AsyncEmployer
56
from .webhooks import Webhooks, AsyncWebhooks
67
from .providers import Providers, AsyncProviders
78

8-
__all__ = ["HRIS", "AsyncHRIS", "Providers", "AsyncProviders", "Account", "AsyncAccount", "Webhooks", "AsyncWebhooks"]
9+
__all__ = [
10+
"HRIS",
11+
"AsyncHRIS",
12+
"Providers",
13+
"AsyncProviders",
14+
"Account",
15+
"AsyncAccount",
16+
"Webhooks",
17+
"AsyncWebhooks",
18+
"Employer",
19+
"AsyncEmployer",
20+
]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# File generated from our OpenAPI spec by Stainless.
2+
3+
from .benefits import Benefits, AsyncBenefits
4+
from .employer import Employer, AsyncEmployer
5+
6+
__all__ = ["Benefits", "AsyncBenefits", "Employer", "AsyncEmployer"]
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# File generated from our OpenAPI spec by Stainless.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
7+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
8+
from ..._utils import maybe_transform
9+
from ..._resource import SyncAPIResource, AsyncAPIResource
10+
from ...types.hris import BenefitType, BenefitFrequency
11+
from ..._base_client import make_request_options
12+
from ...types.employer import RegisterCompanyBenefitsResponse, benefit_register_params
13+
14+
__all__ = ["Benefits", "AsyncBenefits"]
15+
16+
17+
class Benefits(SyncAPIResource):
18+
def register(
19+
self,
20+
*,
21+
description: str | NotGiven = NOT_GIVEN,
22+
frequency: Optional[BenefitFrequency] | NotGiven = NOT_GIVEN,
23+
type: Optional[BenefitType] | NotGiven = NOT_GIVEN,
24+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
25+
# The extra values given here take precedence over values defined on the client or passed to this method.
26+
extra_headers: Headers | None = None,
27+
extra_query: Query | None = None,
28+
extra_body: Body | None = None,
29+
timeout: float | None | NotGiven = NOT_GIVEN,
30+
) -> RegisterCompanyBenefitsResponse:
31+
"""
32+
**Availability: Assisted Benefits providers only**
33+
34+
Register existing benefits from the customer on the provider, on Finch's end.
35+
Please use the `/provider` endpoint to view available types for each provider.
36+
37+
Args:
38+
type: Type of benefit.
39+
40+
extra_headers: Send extra headers
41+
42+
extra_query: Add additional query parameters to the request
43+
44+
extra_body: Add additional JSON properties to the request
45+
46+
timeout: Override the client-level default timeout for this request, in seconds
47+
"""
48+
return self._post(
49+
"/employer/benefits/register",
50+
body=maybe_transform(
51+
{
52+
"description": description,
53+
"frequency": frequency,
54+
"type": type,
55+
},
56+
benefit_register_params.BenefitRegisterParams,
57+
),
58+
options=make_request_options(
59+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
60+
),
61+
cast_to=RegisterCompanyBenefitsResponse,
62+
)
63+
64+
65+
class AsyncBenefits(AsyncAPIResource):
66+
async def register(
67+
self,
68+
*,
69+
description: str | NotGiven = NOT_GIVEN,
70+
frequency: Optional[BenefitFrequency] | NotGiven = NOT_GIVEN,
71+
type: Optional[BenefitType] | NotGiven = NOT_GIVEN,
72+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
73+
# The extra values given here take precedence over values defined on the client or passed to this method.
74+
extra_headers: Headers | None = None,
75+
extra_query: Query | None = None,
76+
extra_body: Body | None = None,
77+
timeout: float | None | NotGiven = NOT_GIVEN,
78+
) -> RegisterCompanyBenefitsResponse:
79+
"""
80+
**Availability: Assisted Benefits providers only**
81+
82+
Register existing benefits from the customer on the provider, on Finch's end.
83+
Please use the `/provider` endpoint to view available types for each provider.
84+
85+
Args:
86+
type: Type of benefit.
87+
88+
extra_headers: Send extra headers
89+
90+
extra_query: Add additional query parameters to the request
91+
92+
extra_body: Add additional JSON properties to the request
93+
94+
timeout: Override the client-level default timeout for this request, in seconds
95+
"""
96+
return await self._post(
97+
"/employer/benefits/register",
98+
body=maybe_transform(
99+
{
100+
"description": description,
101+
"frequency": frequency,
102+
"type": type,
103+
},
104+
benefit_register_params.BenefitRegisterParams,
105+
),
106+
options=make_request_options(
107+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
108+
),
109+
cast_to=RegisterCompanyBenefitsResponse,
110+
)

0 commit comments

Comments
 (0)