Skip to content

Commit ef97220

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

12 files changed

+356
-5
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 18
1+
configured_endpoints: 19

api.md

+12
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,15 @@ Methods:
164164

165165
- <code>client.webhooks.<a href="./src/finch/resources/webhooks.py">unwrap</a>(\*args) -> object</code>
166166
- <code>client.webhooks.<a href="./src/finch/resources/webhooks.py">verify_signature</a>(\*args) -> None</code>
167+
168+
# RequestForwarding
169+
170+
Types:
171+
172+
```python
173+
from finch.types import RequestForwardingForwardResponse
174+
```
175+
176+
Methods:
177+
178+
- <code title="post /forward">client.request_forwarding.<a href="./src/finch/resources/request_forwarding.py">forward</a>(\*\*<a href="src/finch/types/request_forwarding_forward_params.py">params</a>) -> <a href="./src/finch/types/request_forwarding_forward_response.py">RequestForwardingForwardResponse</a></code>

src/finch/_client.py

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Finch(SyncAPIClient):
5050
providers: resources.Providers
5151
account: resources.Account
5252
webhooks: resources.Webhooks
53+
request_forwarding: resources.RequestForwarding
5354

5455
# client options
5556
access_token: str | None
@@ -123,6 +124,7 @@ def __init__(
123124
self.providers = resources.Providers(self)
124125
self.account = resources.Account(self)
125126
self.webhooks = resources.Webhooks(self)
127+
self.request_forwarding = resources.RequestForwarding(self)
126128

127129
@property
128130
def qs(self) -> Querystring:
@@ -313,6 +315,7 @@ class AsyncFinch(AsyncAPIClient):
313315
providers: resources.AsyncProviders
314316
account: resources.AsyncAccount
315317
webhooks: resources.AsyncWebhooks
318+
request_forwarding: resources.AsyncRequestForwarding
316319

317320
# client options
318321
access_token: str | None
@@ -386,6 +389,7 @@ def __init__(
386389
self.providers = resources.AsyncProviders(self)
387390
self.account = resources.AsyncAccount(self)
388391
self.webhooks = resources.AsyncWebhooks(self)
392+
self.request_forwarding = resources.AsyncRequestForwarding(self)
389393

390394
@property
391395
def qs(self) -> Querystring:

src/finch/resources/__init__.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,17 @@
44
from .account import Account, AsyncAccount
55
from .webhooks import Webhooks, AsyncWebhooks
66
from .providers import Providers, AsyncProviders
7+
from .request_forwarding import RequestForwarding, AsyncRequestForwarding
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+
"RequestForwarding",
19+
"AsyncRequestForwarding",
20+
]
+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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 RequestForwardingForwardResponse, request_forwarding_forward_params
8+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9+
from .._utils import maybe_transform
10+
from .._resource import SyncAPIResource, AsyncAPIResource
11+
from .._base_client import make_request_options
12+
13+
__all__ = ["RequestForwarding", "AsyncRequestForwarding"]
14+
15+
16+
class RequestForwarding(SyncAPIResource):
17+
def forward(
18+
self,
19+
*,
20+
method: str,
21+
route: str,
22+
data: Optional[str] | NotGiven = NOT_GIVEN,
23+
headers: Optional[object] | NotGiven = NOT_GIVEN,
24+
params: Optional[object] | NotGiven = NOT_GIVEN,
25+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
26+
# The extra values given here take precedence over values defined on the client or passed to this method.
27+
extra_headers: Headers | None = None,
28+
extra_query: Query | None = None,
29+
extra_body: Body | None = None,
30+
timeout: float | None | NotGiven = NOT_GIVEN,
31+
) -> RequestForwardingForwardResponse:
32+
"""
33+
The Forward API allows you to make direct requests to an employment system.
34+
35+
Args:
36+
method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
37+
, `PUT` , `DELETE` , and `PATCH`.
38+
39+
route: The URL route path for the forwarded request. This value must begin with a
40+
forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
41+
underscores.
42+
43+
data: The body for the forwarded request. This value must be specified as either a
44+
string or a valid JSON object.
45+
46+
headers: The HTTP headers to include on the forwarded request. This value must be
47+
specified as an object of key-value pairs. Example:
48+
`{"Content-Type": "application/xml", "X-API-Version": "v1" }`
49+
50+
params: The query parameters for the forwarded request. This value must be specified as
51+
a valid JSON object rather than a query string.
52+
53+
extra_headers: Send extra headers
54+
55+
extra_query: Add additional query parameters to the request
56+
57+
extra_body: Add additional JSON properties to the request
58+
59+
timeout: Override the client-level default timeout for this request, in seconds
60+
"""
61+
return self._post(
62+
"/forward",
63+
body=maybe_transform(
64+
{
65+
"method": method,
66+
"route": route,
67+
"data": data,
68+
"headers": headers,
69+
"params": params,
70+
},
71+
request_forwarding_forward_params.RequestForwardingForwardParams,
72+
),
73+
options=make_request_options(
74+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
75+
),
76+
cast_to=RequestForwardingForwardResponse,
77+
)
78+
79+
80+
class AsyncRequestForwarding(AsyncAPIResource):
81+
async def forward(
82+
self,
83+
*,
84+
method: str,
85+
route: str,
86+
data: Optional[str] | NotGiven = NOT_GIVEN,
87+
headers: Optional[object] | NotGiven = NOT_GIVEN,
88+
params: Optional[object] | NotGiven = NOT_GIVEN,
89+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
90+
# The extra values given here take precedence over values defined on the client or passed to this method.
91+
extra_headers: Headers | None = None,
92+
extra_query: Query | None = None,
93+
extra_body: Body | None = None,
94+
timeout: float | None | NotGiven = NOT_GIVEN,
95+
) -> RequestForwardingForwardResponse:
96+
"""
97+
The Forward API allows you to make direct requests to an employment system.
98+
99+
Args:
100+
method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
101+
, `PUT` , `DELETE` , and `PATCH`.
102+
103+
route: The URL route path for the forwarded request. This value must begin with a
104+
forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
105+
underscores.
106+
107+
data: The body for the forwarded request. This value must be specified as either a
108+
string or a valid JSON object.
109+
110+
headers: The HTTP headers to include on the forwarded request. This value must be
111+
specified as an object of key-value pairs. Example:
112+
`{"Content-Type": "application/xml", "X-API-Version": "v1" }`
113+
114+
params: The query parameters for the forwarded request. This value must be specified as
115+
a valid JSON object rather than a query string.
116+
117+
extra_headers: Send extra headers
118+
119+
extra_query: Add additional query parameters to the request
120+
121+
extra_body: Add additional JSON properties to the request
122+
123+
timeout: Override the client-level default timeout for this request, in seconds
124+
"""
125+
return await self._post(
126+
"/forward",
127+
body=maybe_transform(
128+
{
129+
"method": method,
130+
"route": route,
131+
"data": data,
132+
"headers": headers,
133+
"params": params,
134+
},
135+
request_forwarding_forward_params.RequestForwardingForwardParams,
136+
),
137+
options=make_request_options(
138+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
139+
),
140+
cast_to=RequestForwardingForwardResponse,
141+
)

src/finch/types/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
from .provider import Provider as Provider
1010
from .introspection import Introspection as Introspection
1111
from .disconnect_response import DisconnectResponse as DisconnectResponse
12+
from .request_forwarding_forward_params import (
13+
RequestForwardingForwardParams as RequestForwardingForwardParams,
14+
)
15+
from .request_forwarding_forward_response import (
16+
RequestForwardingForwardResponse as RequestForwardingForwardResponse,
17+
)

src/finch/types/hris/employment_data.py

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class EmploymentData(BaseModel):
8282
Please reach out to your Finch representative if you would like access.
8383
"""
8484

85+
source_id: Optional[str] = None
86+
"""The source system's unique employment identifier for this individual"""
87+
8588
start_date: Optional[str] = None
8689

8790
title: Optional[str] = None

src/finch/types/hris/pay_statement.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class PayStatement(BaseModel):
117117
taxes: Optional[List[Optional[Tax]]] = None
118118
"""The array of taxes objects associated with this pay statement."""
119119

120-
total_hours: Optional[int] = None
120+
total_hours: Optional[float] = None
121121
"""The number of hours worked for this pay period"""
122122

123123
type: Optional[Literal["regular_payroll", "off_cycle_payroll", "one_time_payment"]] = None

src/finch/types/provider.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ class Provider(BaseModel):
2222

2323
manual: Optional[bool] = None
2424
"""
25-
Whether the Finch integration with this provider uses the Assisted Connect Flow
26-
by default.
25+
[DEPRECATED] Whether the Finch integration with this provider uses the Assisted
26+
Connect Flow by default. This field is now deprecated. Please check for a `type`
27+
of `assisted` in the `authentication_methods` field instead.
2728
"""
2829

2930
mfa_required: Optional[bool] = None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# File generated from our OpenAPI spec by Stainless.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import Required, TypedDict
7+
8+
__all__ = ["RequestForwardingForwardParams"]
9+
10+
11+
class RequestForwardingForwardParams(TypedDict, total=False):
12+
method: Required[str]
13+
"""The HTTP method for the forwarded request.
14+
15+
Valid values include: `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`.
16+
"""
17+
18+
route: Required[str]
19+
"""The URL route path for the forwarded request.
20+
21+
This value must begin with a forward-slash ( / ) and may only contain
22+
alphanumeric characters, hyphens, and underscores.
23+
"""
24+
25+
data: Optional[str]
26+
"""The body for the forwarded request.
27+
28+
This value must be specified as either a string or a valid JSON object.
29+
"""
30+
31+
headers: Optional[object]
32+
"""The HTTP headers to include on the forwarded request.
33+
34+
This value must be specified as an object of key-value pairs. Example:
35+
`{"Content-Type": "application/xml", "X-API-Version": "v1" }`
36+
"""
37+
38+
params: Optional[object]
39+
"""The query parameters for the forwarded request.
40+
41+
This value must be specified as a valid JSON object rather than a query string.
42+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# File generated from our OpenAPI spec by Stainless.
2+
3+
from typing import Optional
4+
5+
from pydantic import Field as FieldInfo
6+
7+
from .._models import BaseModel
8+
9+
__all__ = ["RequestForwardingForwardResponse", "Request"]
10+
11+
12+
class Request(BaseModel):
13+
data: Optional[str]
14+
"""The body that was specified for the forwarded request.
15+
16+
If a value was not specified in the original request, this value will be
17+
returned as null ; otherwise, this value will always be returned as a string.
18+
"""
19+
20+
headers: Optional[object]
21+
"""The specified HTTP headers that were included in the forwarded request.
22+
23+
If no headers were specified, this will be returned as `null`.
24+
"""
25+
26+
method: str
27+
"""The HTTP method that was specified for the forwarded request.
28+
29+
Valid values include: `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`.
30+
"""
31+
32+
params: Optional[object]
33+
"""The query parameters that were included in the forwarded request.
34+
35+
If no query parameters were specified, this will be returned as `null`.
36+
"""
37+
38+
route: str
39+
"""The URL route path that was specified for the forwarded request."""
40+
41+
42+
class RequestForwardingForwardResponse(BaseModel):
43+
data: Optional[str]
44+
"""
45+
A string representation of the HTTP response body of the forwarded request’s
46+
response received from the underlying integration’s API. This field may be null
47+
in the case where the upstream system’s response is empty.
48+
"""
49+
50+
headers: Optional[object]
51+
"""
52+
The HTTP headers of the forwarded request’s response, exactly as received from
53+
the underlying integration’s API.
54+
"""
55+
56+
request: Request
57+
"""
58+
An object containing details of your original forwarded request, for your ease
59+
of reference.
60+
"""
61+
62+
status_code: int = FieldInfo(alias="statusCode")
63+
"""
64+
The HTTP status code of the forwarded request’s response, exactly received from
65+
the underlying integration’s API. This value will be returned as an integer.
66+
"""

0 commit comments

Comments
 (0)