diff --git a/.stats.yml b/.stats.yml index 2d2fedb9..a78b7ab0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 18 +configured_endpoints: 19 diff --git a/api.md b/api.md index 24fa1691..f2ebbce6 100644 --- a/api.md +++ b/api.md @@ -164,3 +164,15 @@ Methods: - client.webhooks.unwrap(\*args) -> object - client.webhooks.verify_signature(\*args) -> None + +# RequestForwarding + +Types: + +```python +from finch.types import RequestForwardingForwardResponse +``` + +Methods: + +- client.request_forwarding.forward(\*\*params) -> RequestForwardingForwardResponse diff --git a/src/finch/_client.py b/src/finch/_client.py index 17d3e583..013c8161 100644 --- a/src/finch/_client.py +++ b/src/finch/_client.py @@ -50,6 +50,7 @@ class Finch(SyncAPIClient): providers: resources.Providers account: resources.Account webhooks: resources.Webhooks + request_forwarding: resources.RequestForwarding # client options access_token: str | None @@ -123,6 +124,7 @@ def __init__( self.providers = resources.Providers(self) self.account = resources.Account(self) self.webhooks = resources.Webhooks(self) + self.request_forwarding = resources.RequestForwarding(self) @property def qs(self) -> Querystring: @@ -313,6 +315,7 @@ class AsyncFinch(AsyncAPIClient): providers: resources.AsyncProviders account: resources.AsyncAccount webhooks: resources.AsyncWebhooks + request_forwarding: resources.AsyncRequestForwarding # client options access_token: str | None @@ -386,6 +389,7 @@ def __init__( self.providers = resources.AsyncProviders(self) self.account = resources.AsyncAccount(self) self.webhooks = resources.AsyncWebhooks(self) + self.request_forwarding = resources.AsyncRequestForwarding(self) @property def qs(self) -> Querystring: diff --git a/src/finch/resources/__init__.py b/src/finch/resources/__init__.py index 1a47fea5..8e71749e 100644 --- a/src/finch/resources/__init__.py +++ b/src/finch/resources/__init__.py @@ -4,5 +4,17 @@ from .account import Account, AsyncAccount from .webhooks import Webhooks, AsyncWebhooks from .providers import Providers, AsyncProviders +from .request_forwarding import RequestForwarding, AsyncRequestForwarding -__all__ = ["HRIS", "AsyncHRIS", "Providers", "AsyncProviders", "Account", "AsyncAccount", "Webhooks", "AsyncWebhooks"] +__all__ = [ + "HRIS", + "AsyncHRIS", + "Providers", + "AsyncProviders", + "Account", + "AsyncAccount", + "Webhooks", + "AsyncWebhooks", + "RequestForwarding", + "AsyncRequestForwarding", +] diff --git a/src/finch/resources/request_forwarding.py b/src/finch/resources/request_forwarding.py new file mode 100644 index 00000000..49296124 --- /dev/null +++ b/src/finch/resources/request_forwarding.py @@ -0,0 +1,141 @@ +# File generated from our OpenAPI spec by Stainless. + +from __future__ import annotations + +from typing import Optional + +from ..types import RequestForwardingForwardResponse, request_forwarding_forward_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import maybe_transform +from .._resource import SyncAPIResource, AsyncAPIResource +from .._base_client import make_request_options + +__all__ = ["RequestForwarding", "AsyncRequestForwarding"] + + +class RequestForwarding(SyncAPIResource): + def forward( + self, + *, + method: str, + route: str, + data: Optional[str] | NotGiven = NOT_GIVEN, + headers: Optional[object] | NotGiven = NOT_GIVEN, + params: Optional[object] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | None | NotGiven = NOT_GIVEN, + ) -> RequestForwardingForwardResponse: + """ + The Forward API allows you to make direct requests to an employment system. + + Args: + method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST` + , `PUT` , `DELETE` , and `PATCH`. + + route: The URL route path for the forwarded request. This value must begin with a + forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and + underscores. + + data: The body for the forwarded request. This value must be specified as either a + string or a valid JSON object. + + headers: The HTTP headers to include on the forwarded request. This value must be + specified as an object of key-value pairs. Example: + `{"Content-Type": "application/xml", "X-API-Version": "v1" }` + + params: The query parameters for the forwarded request. This value must be specified as + a valid JSON object rather than a query string. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/forward", + body=maybe_transform( + { + "method": method, + "route": route, + "data": data, + "headers": headers, + "params": params, + }, + request_forwarding_forward_params.RequestForwardingForwardParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RequestForwardingForwardResponse, + ) + + +class AsyncRequestForwarding(AsyncAPIResource): + async def forward( + self, + *, + method: str, + route: str, + data: Optional[str] | NotGiven = NOT_GIVEN, + headers: Optional[object] | NotGiven = NOT_GIVEN, + params: Optional[object] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | None | NotGiven = NOT_GIVEN, + ) -> RequestForwardingForwardResponse: + """ + The Forward API allows you to make direct requests to an employment system. + + Args: + method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST` + , `PUT` , `DELETE` , and `PATCH`. + + route: The URL route path for the forwarded request. This value must begin with a + forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and + underscores. + + data: The body for the forwarded request. This value must be specified as either a + string or a valid JSON object. + + headers: The HTTP headers to include on the forwarded request. This value must be + specified as an object of key-value pairs. Example: + `{"Content-Type": "application/xml", "X-API-Version": "v1" }` + + params: The query parameters for the forwarded request. This value must be specified as + a valid JSON object rather than a query string. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/forward", + body=maybe_transform( + { + "method": method, + "route": route, + "data": data, + "headers": headers, + "params": params, + }, + request_forwarding_forward_params.RequestForwardingForwardParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RequestForwardingForwardResponse, + ) diff --git a/src/finch/types/__init__.py b/src/finch/types/__init__.py index dc60674b..7f44cbc5 100644 --- a/src/finch/types/__init__.py +++ b/src/finch/types/__init__.py @@ -9,3 +9,9 @@ from .provider import Provider as Provider from .introspection import Introspection as Introspection from .disconnect_response import DisconnectResponse as DisconnectResponse +from .request_forwarding_forward_params import ( + RequestForwardingForwardParams as RequestForwardingForwardParams, +) +from .request_forwarding_forward_response import ( + RequestForwardingForwardResponse as RequestForwardingForwardResponse, +) diff --git a/src/finch/types/hris/employment_data.py b/src/finch/types/hris/employment_data.py index 4ae7d44a..1de9c0f8 100644 --- a/src/finch/types/hris/employment_data.py +++ b/src/finch/types/hris/employment_data.py @@ -82,6 +82,9 @@ class EmploymentData(BaseModel): Please reach out to your Finch representative if you would like access. """ + source_id: Optional[str] = None + """The source system's unique employment identifier for this individual""" + start_date: Optional[str] = None title: Optional[str] = None diff --git a/src/finch/types/hris/pay_statement.py b/src/finch/types/hris/pay_statement.py index f9d5515e..3d25a99c 100644 --- a/src/finch/types/hris/pay_statement.py +++ b/src/finch/types/hris/pay_statement.py @@ -117,7 +117,7 @@ class PayStatement(BaseModel): taxes: Optional[List[Optional[Tax]]] = None """The array of taxes objects associated with this pay statement.""" - total_hours: Optional[int] = None + total_hours: Optional[float] = None """The number of hours worked for this pay period""" type: Optional[Literal["regular_payroll", "off_cycle_payroll", "one_time_payment"]] = None diff --git a/src/finch/types/provider.py b/src/finch/types/provider.py index 880077a0..2da2fbcb 100644 --- a/src/finch/types/provider.py +++ b/src/finch/types/provider.py @@ -22,8 +22,9 @@ class Provider(BaseModel): manual: Optional[bool] = None """ - Whether the Finch integration with this provider uses the Assisted Connect Flow - by default. + [DEPRECATED] Whether the Finch integration with this provider uses the Assisted + Connect Flow by default. This field is now deprecated. Please check for a `type` + of `assisted` in the `authentication_methods` field instead. """ mfa_required: Optional[bool] = None diff --git a/src/finch/types/request_forwarding_forward_params.py b/src/finch/types/request_forwarding_forward_params.py new file mode 100644 index 00000000..19fe0062 --- /dev/null +++ b/src/finch/types/request_forwarding_forward_params.py @@ -0,0 +1,42 @@ +# File generated from our OpenAPI spec by Stainless. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Required, TypedDict + +__all__ = ["RequestForwardingForwardParams"] + + +class RequestForwardingForwardParams(TypedDict, total=False): + method: Required[str] + """The HTTP method for the forwarded request. + + Valid values include: `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`. + """ + + route: Required[str] + """The URL route path for the forwarded request. + + This value must begin with a forward-slash ( / ) and may only contain + alphanumeric characters, hyphens, and underscores. + """ + + data: Optional[str] + """The body for the forwarded request. + + This value must be specified as either a string or a valid JSON object. + """ + + headers: Optional[object] + """The HTTP headers to include on the forwarded request. + + This value must be specified as an object of key-value pairs. Example: + `{"Content-Type": "application/xml", "X-API-Version": "v1" }` + """ + + params: Optional[object] + """The query parameters for the forwarded request. + + This value must be specified as a valid JSON object rather than a query string. + """ diff --git a/src/finch/types/request_forwarding_forward_response.py b/src/finch/types/request_forwarding_forward_response.py new file mode 100644 index 00000000..267a4cf9 --- /dev/null +++ b/src/finch/types/request_forwarding_forward_response.py @@ -0,0 +1,66 @@ +# File generated from our OpenAPI spec by Stainless. + +from typing import Optional + +from pydantic import Field as FieldInfo + +from .._models import BaseModel + +__all__ = ["RequestForwardingForwardResponse", "Request"] + + +class Request(BaseModel): + data: Optional[str] + """The body that was specified for the forwarded request. + + If a value was not specified in the original request, this value will be + returned as null ; otherwise, this value will always be returned as a string. + """ + + headers: Optional[object] + """The specified HTTP headers that were included in the forwarded request. + + If no headers were specified, this will be returned as `null`. + """ + + method: str + """The HTTP method that was specified for the forwarded request. + + Valid values include: `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`. + """ + + params: Optional[object] + """The query parameters that were included in the forwarded request. + + If no query parameters were specified, this will be returned as `null`. + """ + + route: str + """The URL route path that was specified for the forwarded request.""" + + +class RequestForwardingForwardResponse(BaseModel): + data: Optional[str] + """ + A string representation of the HTTP response body of the forwarded request’s + response received from the underlying integration’s API. This field may be null + in the case where the upstream system’s response is empty. + """ + + headers: Optional[object] + """ + The HTTP headers of the forwarded request’s response, exactly as received from + the underlying integration’s API. + """ + + request: Request + """ + An object containing details of your original forwarded request, for your ease + of reference. + """ + + status_code: int = FieldInfo(alias="statusCode") + """ + The HTTP status code of the forwarded request’s response, exactly received from + the underlying integration’s API. This value will be returned as an integer. + """ diff --git a/tests/api_resources/test_request_forwarding.py b/tests/api_resources/test_request_forwarding.py new file mode 100644 index 00000000..94b873fa --- /dev/null +++ b/tests/api_resources/test_request_forwarding.py @@ -0,0 +1,64 @@ +# File generated from our OpenAPI spec by Stainless. + +from __future__ import annotations + +import os + +import pytest + +from finch import Finch, AsyncFinch +from finch.types import RequestForwardingForwardResponse +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") +access_token = os.environ.get("API_KEY", "something1234") + + +class TestRequestForwarding: + strict_client = Finch(base_url=base_url, access_token=access_token, _strict_response_validation=True) + loose_client = Finch(base_url=base_url, access_token=access_token, _strict_response_validation=False) + parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"]) + + @parametrize + def test_method_forward(self, client: Finch) -> None: + request_forwarding = client.request_forwarding.forward( + method="string", + route="string", + ) + assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"]) + + @parametrize + def test_method_forward_with_all_params(self, client: Finch) -> None: + request_forwarding = client.request_forwarding.forward( + method="string", + route="string", + data="string", + headers={}, + params={}, + ) + assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"]) + + +class TestAsyncRequestForwarding: + strict_client = AsyncFinch(base_url=base_url, access_token=access_token, _strict_response_validation=True) + loose_client = AsyncFinch(base_url=base_url, access_token=access_token, _strict_response_validation=False) + parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"]) + + @parametrize + async def test_method_forward(self, client: AsyncFinch) -> None: + request_forwarding = await client.request_forwarding.forward( + method="string", + route="string", + ) + assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"]) + + @parametrize + async def test_method_forward_with_all_params(self, client: AsyncFinch) -> None: + request_forwarding = await client.request_forwarding.forward( + method="string", + route="string", + data="string", + headers={}, + params={}, + ) + assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"])