Skip to content

feat(api): add /forward endpoint and other updates #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 18
configured_endpoints: 19
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,15 @@ Methods:

- <code>client.webhooks.<a href="./src/finch/resources/webhooks.py">unwrap</a>(\*args) -> object</code>
- <code>client.webhooks.<a href="./src/finch/resources/webhooks.py">verify_signature</a>(\*args) -> None</code>

# RequestForwarding

Types:

```python
from finch.types import RequestForwardingForwardResponse
```

Methods:

- <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>
4 changes: 4 additions & 0 deletions src/finch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 13 additions & 1 deletion src/finch/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
141 changes: 141 additions & 0 deletions src/finch/resources/request_forwarding.py
Original file line number Diff line number Diff line change
@@ -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,
)
6 changes: 6 additions & 0 deletions src/finch/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
3 changes: 3 additions & 0 deletions src/finch/types/hris/employment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/finch/types/hris/pay_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/finch/types/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions src/finch/types/request_forwarding_forward_params.py
Original file line number Diff line number Diff line change
@@ -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.
"""
66 changes: 66 additions & 0 deletions src/finch/types/request_forwarding_forward_response.py
Original file line number Diff line number Diff line change
@@ -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.
"""
Loading