From cad19463cea8e9f6e8cf168267ef2fa0d3a61b81 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:43:23 +0000 Subject: [PATCH] chore(internal): codegen related update (#501) --- .stats.yml | 4 +- api.md | 15 + src/finch/_client.py | 8 + src/finch/resources/__init__.py | 14 + src/finch/resources/connect/__init__.py | 33 ++ src/finch/resources/connect/connect.py | 102 +++++ src/finch/resources/connect/sessions.py | 348 ++++++++++++++++++ src/finch/types/connect/__init__.py | 8 + src/finch/types/connect/session_new_params.py | 40 ++ .../types/connect/session_new_response.py | 15 + .../connect/session_reauthenticate_params.py | 27 ++ .../session_reauthenticate_response.py | 15 + tests/api_resources/connect/__init__.py | 1 + tests/api_resources/connect/test_sessions.py | 217 +++++++++++ 14 files changed, 845 insertions(+), 2 deletions(-) create mode 100644 src/finch/resources/connect/__init__.py create mode 100644 src/finch/resources/connect/connect.py create mode 100644 src/finch/resources/connect/sessions.py create mode 100644 src/finch/types/connect/__init__.py create mode 100644 src/finch/types/connect/session_new_params.py create mode 100644 src/finch/types/connect/session_new_response.py create mode 100644 src/finch/types/connect/session_reauthenticate_params.py create mode 100644 src/finch/types/connect/session_reauthenticate_response.py create mode 100644 tests/api_resources/connect/__init__.py create mode 100644 tests/api_resources/connect/test_sessions.py diff --git a/.stats.yml b/.stats.yml index a6ca1689..be55dbe9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 37 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-0b6874fdff2a5ed63c4e84830811f10a91e10e9c3e300a33f25422ad0afb945b.yml +configured_endpoints: 39 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-e915b33a18d4e6592966587ef174bbfe316edd9bc1fd7c17f86f372089bf80eb.yml diff --git a/api.md b/api.md index 014e49c7..4d4c1c06 100644 --- a/api.md +++ b/api.md @@ -366,3 +366,18 @@ Methods: - client.payroll.pay_groups.retrieve(pay_group_id) -> PayGroupRetrieveResponse - client.payroll.pay_groups.list(\*\*params) -> SyncSinglePage[PayGroupListResponse] + +# Connect + +## Sessions + +Types: + +```python +from finch.types.connect import SessionNewResponse, SessionReauthenticateResponse +``` + +Methods: + +- client.connect.sessions.new(\*\*params) -> SessionNewResponse +- client.connect.sessions.reauthenticate(\*\*params) -> SessionReauthenticateResponse diff --git a/src/finch/_client.py b/src/finch/_client.py index 3e9651e6..a62e08f0 100644 --- a/src/finch/_client.py +++ b/src/finch/_client.py @@ -61,6 +61,7 @@ class Finch(SyncAPIClient): jobs: resources.Jobs sandbox: resources.Sandbox payroll: resources.Payroll + connect: resources.Connect with_raw_response: FinchWithRawResponse with_streaming_response: FinchWithStreamedResponse @@ -165,6 +166,7 @@ def __init__( self.jobs = resources.Jobs(self) self.sandbox = resources.Sandbox(self) self.payroll = resources.Payroll(self) + self.connect = resources.Connect(self) self.with_raw_response = FinchWithRawResponse(self) self.with_streaming_response = FinchWithStreamedResponse(self) @@ -413,6 +415,7 @@ class AsyncFinch(AsyncAPIClient): jobs: resources.AsyncJobs sandbox: resources.AsyncSandbox payroll: resources.AsyncPayroll + connect: resources.AsyncConnect with_raw_response: AsyncFinchWithRawResponse with_streaming_response: AsyncFinchWithStreamedResponse @@ -517,6 +520,7 @@ def __init__( self.jobs = resources.AsyncJobs(self) self.sandbox = resources.AsyncSandbox(self) self.payroll = resources.AsyncPayroll(self) + self.connect = resources.AsyncConnect(self) self.with_raw_response = AsyncFinchWithRawResponse(self) self.with_streaming_response = AsyncFinchWithStreamedResponse(self) @@ -765,6 +769,7 @@ def __init__(self, client: Finch) -> None: self.jobs = resources.JobsWithRawResponse(client.jobs) self.sandbox = resources.SandboxWithRawResponse(client.sandbox) self.payroll = resources.PayrollWithRawResponse(client.payroll) + self.connect = resources.ConnectWithRawResponse(client.connect) class AsyncFinchWithRawResponse: @@ -777,6 +782,7 @@ def __init__(self, client: AsyncFinch) -> None: self.jobs = resources.AsyncJobsWithRawResponse(client.jobs) self.sandbox = resources.AsyncSandboxWithRawResponse(client.sandbox) self.payroll = resources.AsyncPayrollWithRawResponse(client.payroll) + self.connect = resources.AsyncConnectWithRawResponse(client.connect) class FinchWithStreamedResponse: @@ -789,6 +795,7 @@ def __init__(self, client: Finch) -> None: self.jobs = resources.JobsWithStreamingResponse(client.jobs) self.sandbox = resources.SandboxWithStreamingResponse(client.sandbox) self.payroll = resources.PayrollWithStreamingResponse(client.payroll) + self.connect = resources.ConnectWithStreamingResponse(client.connect) class AsyncFinchWithStreamedResponse: @@ -801,6 +808,7 @@ def __init__(self, client: AsyncFinch) -> None: self.jobs = resources.AsyncJobsWithStreamingResponse(client.jobs) self.sandbox = resources.AsyncSandboxWithStreamingResponse(client.sandbox) self.payroll = resources.AsyncPayrollWithStreamingResponse(client.payroll) + self.connect = resources.AsyncConnectWithStreamingResponse(client.connect) Client = Finch diff --git a/src/finch/resources/__init__.py b/src/finch/resources/__init__.py index 6f6a8cdc..542fbfcc 100644 --- a/src/finch/resources/__init__.py +++ b/src/finch/resources/__init__.py @@ -24,6 +24,14 @@ AccountWithStreamingResponse, AsyncAccountWithStreamingResponse, ) +from .connect import ( + Connect, + AsyncConnect, + ConnectWithRawResponse, + AsyncConnectWithRawResponse, + ConnectWithStreamingResponse, + AsyncConnectWithStreamingResponse, +) from .payroll import ( Payroll, AsyncPayroll, @@ -117,4 +125,10 @@ "AsyncPayrollWithRawResponse", "PayrollWithStreamingResponse", "AsyncPayrollWithStreamingResponse", + "Connect", + "AsyncConnect", + "ConnectWithRawResponse", + "AsyncConnectWithRawResponse", + "ConnectWithStreamingResponse", + "AsyncConnectWithStreamingResponse", ] diff --git a/src/finch/resources/connect/__init__.py b/src/finch/resources/connect/__init__.py new file mode 100644 index 00000000..1679749e --- /dev/null +++ b/src/finch/resources/connect/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .connect import ( + Connect, + AsyncConnect, + ConnectWithRawResponse, + AsyncConnectWithRawResponse, + ConnectWithStreamingResponse, + AsyncConnectWithStreamingResponse, +) +from .sessions import ( + Sessions, + AsyncSessions, + SessionsWithRawResponse, + AsyncSessionsWithRawResponse, + SessionsWithStreamingResponse, + AsyncSessionsWithStreamingResponse, +) + +__all__ = [ + "Sessions", + "AsyncSessions", + "SessionsWithRawResponse", + "AsyncSessionsWithRawResponse", + "SessionsWithStreamingResponse", + "AsyncSessionsWithStreamingResponse", + "Connect", + "AsyncConnect", + "ConnectWithRawResponse", + "AsyncConnectWithRawResponse", + "ConnectWithStreamingResponse", + "AsyncConnectWithStreamingResponse", +] diff --git a/src/finch/resources/connect/connect.py b/src/finch/resources/connect/connect.py new file mode 100644 index 00000000..a6909d8a --- /dev/null +++ b/src/finch/resources/connect/connect.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .sessions import ( + Sessions, + AsyncSessions, + SessionsWithRawResponse, + AsyncSessionsWithRawResponse, + SessionsWithStreamingResponse, + AsyncSessionsWithStreamingResponse, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["Connect", "AsyncConnect"] + + +class Connect(SyncAPIResource): + @cached_property + def sessions(self) -> Sessions: + return Sessions(self._client) + + @cached_property + def with_raw_response(self) -> ConnectWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Finch-API/finch-api-python#accessing-raw-response-data-eg-headers + """ + return ConnectWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ConnectWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Finch-API/finch-api-python#with_streaming_response + """ + return ConnectWithStreamingResponse(self) + + +class AsyncConnect(AsyncAPIResource): + @cached_property + def sessions(self) -> AsyncSessions: + return AsyncSessions(self._client) + + @cached_property + def with_raw_response(self) -> AsyncConnectWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Finch-API/finch-api-python#accessing-raw-response-data-eg-headers + """ + return AsyncConnectWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncConnectWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Finch-API/finch-api-python#with_streaming_response + """ + return AsyncConnectWithStreamingResponse(self) + + +class ConnectWithRawResponse: + def __init__(self, connect: Connect) -> None: + self._connect = connect + + @cached_property + def sessions(self) -> SessionsWithRawResponse: + return SessionsWithRawResponse(self._connect.sessions) + + +class AsyncConnectWithRawResponse: + def __init__(self, connect: AsyncConnect) -> None: + self._connect = connect + + @cached_property + def sessions(self) -> AsyncSessionsWithRawResponse: + return AsyncSessionsWithRawResponse(self._connect.sessions) + + +class ConnectWithStreamingResponse: + def __init__(self, connect: Connect) -> None: + self._connect = connect + + @cached_property + def sessions(self) -> SessionsWithStreamingResponse: + return SessionsWithStreamingResponse(self._connect.sessions) + + +class AsyncConnectWithStreamingResponse: + def __init__(self, connect: AsyncConnect) -> None: + self._connect = connect + + @cached_property + def sessions(self) -> AsyncSessionsWithStreamingResponse: + return AsyncSessionsWithStreamingResponse(self._connect.sessions) diff --git a/src/finch/resources/connect/sessions.py b/src/finch/resources/connect/sessions.py new file mode 100644 index 00000000..7ff62b0e --- /dev/null +++ b/src/finch/resources/connect/sessions.py @@ -0,0 +1,348 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional +from typing_extensions import Literal + +import httpx + +from ... import _legacy_response +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper +from ..._base_client import make_request_options +from ...types.connect import session_new_params, session_reauthenticate_params +from ...types.connect.session_new_response import SessionNewResponse +from ...types.connect.session_reauthenticate_response import SessionReauthenticateResponse + +__all__ = ["Sessions", "AsyncSessions"] + + +class Sessions(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SessionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Finch-API/finch-api-python#accessing-raw-response-data-eg-headers + """ + return SessionsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SessionsWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Finch-API/finch-api-python#with_streaming_response + """ + return SessionsWithStreamingResponse(self) + + def new( + self, + *, + customer_id: str, + customer_name: str, + products: List[ + Literal["company", "directory", "individual", "employment", "payment", "pay_statement", "benefits", "ssn"] + ], + customer_email: Optional[str] | NotGiven = NOT_GIVEN, + integration: Optional[session_new_params.Integration] | NotGiven = NOT_GIVEN, + manual: Optional[bool] | NotGiven = NOT_GIVEN, + minutes_to_expire: Optional[float] | NotGiven = NOT_GIVEN, + redirect_uri: Optional[str] | NotGiven = NOT_GIVEN, + sandbox: Optional[Literal["finch", "provider"]] | 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 | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SessionNewResponse: + """ + Create a new connect session for an employer + + Args: + minutes_to_expire: The number of minutes until the session expires (defaults to 10,080, which is 7 + days) + + 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( + "/connect/sessions", + body=maybe_transform( + { + "customer_id": customer_id, + "customer_name": customer_name, + "products": products, + "customer_email": customer_email, + "integration": integration, + "manual": manual, + "minutes_to_expire": minutes_to_expire, + "redirect_uri": redirect_uri, + "sandbox": sandbox, + }, + session_new_params.SessionNewParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SessionNewResponse, + ) + + def reauthenticate( + self, + *, + connection_id: str, + minutes_to_expire: Optional[int] | NotGiven = NOT_GIVEN, + products: Optional[ + List[ + Literal[ + "company", "directory", "individual", "employment", "payment", "pay_statement", "benefits", "ssn" + ] + ] + ] + | NotGiven = NOT_GIVEN, + redirect_uri: Optional[str] | 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 | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SessionReauthenticateResponse: + """ + Create a new Connect session for reauthenticating an existing connection + + Args: + connection_id: The ID of the existing connection to reauthenticate + + minutes_to_expire: The number of minutes until the session expires (defaults to 10,080, which is 7 + days) + + products: The products to request access to (optional for reauthentication) + + redirect_uri: The URI to redirect to after the Connect flow is completed + + 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( + "/connect/sessions/reauthenticate", + body=maybe_transform( + { + "connection_id": connection_id, + "minutes_to_expire": minutes_to_expire, + "products": products, + "redirect_uri": redirect_uri, + }, + session_reauthenticate_params.SessionReauthenticateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SessionReauthenticateResponse, + ) + + +class AsyncSessions(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSessionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Finch-API/finch-api-python#accessing-raw-response-data-eg-headers + """ + return AsyncSessionsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSessionsWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Finch-API/finch-api-python#with_streaming_response + """ + return AsyncSessionsWithStreamingResponse(self) + + async def new( + self, + *, + customer_id: str, + customer_name: str, + products: List[ + Literal["company", "directory", "individual", "employment", "payment", "pay_statement", "benefits", "ssn"] + ], + customer_email: Optional[str] | NotGiven = NOT_GIVEN, + integration: Optional[session_new_params.Integration] | NotGiven = NOT_GIVEN, + manual: Optional[bool] | NotGiven = NOT_GIVEN, + minutes_to_expire: Optional[float] | NotGiven = NOT_GIVEN, + redirect_uri: Optional[str] | NotGiven = NOT_GIVEN, + sandbox: Optional[Literal["finch", "provider"]] | 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 | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SessionNewResponse: + """ + Create a new connect session for an employer + + Args: + minutes_to_expire: The number of minutes until the session expires (defaults to 10,080, which is 7 + days) + + 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( + "/connect/sessions", + body=await async_maybe_transform( + { + "customer_id": customer_id, + "customer_name": customer_name, + "products": products, + "customer_email": customer_email, + "integration": integration, + "manual": manual, + "minutes_to_expire": minutes_to_expire, + "redirect_uri": redirect_uri, + "sandbox": sandbox, + }, + session_new_params.SessionNewParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SessionNewResponse, + ) + + async def reauthenticate( + self, + *, + connection_id: str, + minutes_to_expire: Optional[int] | NotGiven = NOT_GIVEN, + products: Optional[ + List[ + Literal[ + "company", "directory", "individual", "employment", "payment", "pay_statement", "benefits", "ssn" + ] + ] + ] + | NotGiven = NOT_GIVEN, + redirect_uri: Optional[str] | 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 | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SessionReauthenticateResponse: + """ + Create a new Connect session for reauthenticating an existing connection + + Args: + connection_id: The ID of the existing connection to reauthenticate + + minutes_to_expire: The number of minutes until the session expires (defaults to 10,080, which is 7 + days) + + products: The products to request access to (optional for reauthentication) + + redirect_uri: The URI to redirect to after the Connect flow is completed + + 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( + "/connect/sessions/reauthenticate", + body=await async_maybe_transform( + { + "connection_id": connection_id, + "minutes_to_expire": minutes_to_expire, + "products": products, + "redirect_uri": redirect_uri, + }, + session_reauthenticate_params.SessionReauthenticateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SessionReauthenticateResponse, + ) + + +class SessionsWithRawResponse: + def __init__(self, sessions: Sessions) -> None: + self._sessions = sessions + + self.new = _legacy_response.to_raw_response_wrapper( + sessions.new, + ) + self.reauthenticate = _legacy_response.to_raw_response_wrapper( + sessions.reauthenticate, + ) + + +class AsyncSessionsWithRawResponse: + def __init__(self, sessions: AsyncSessions) -> None: + self._sessions = sessions + + self.new = _legacy_response.async_to_raw_response_wrapper( + sessions.new, + ) + self.reauthenticate = _legacy_response.async_to_raw_response_wrapper( + sessions.reauthenticate, + ) + + +class SessionsWithStreamingResponse: + def __init__(self, sessions: Sessions) -> None: + self._sessions = sessions + + self.new = to_streamed_response_wrapper( + sessions.new, + ) + self.reauthenticate = to_streamed_response_wrapper( + sessions.reauthenticate, + ) + + +class AsyncSessionsWithStreamingResponse: + def __init__(self, sessions: AsyncSessions) -> None: + self._sessions = sessions + + self.new = async_to_streamed_response_wrapper( + sessions.new, + ) + self.reauthenticate = async_to_streamed_response_wrapper( + sessions.reauthenticate, + ) diff --git a/src/finch/types/connect/__init__.py b/src/finch/types/connect/__init__.py new file mode 100644 index 00000000..fe6954ab --- /dev/null +++ b/src/finch/types/connect/__init__.py @@ -0,0 +1,8 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .session_new_params import SessionNewParams as SessionNewParams +from .session_new_response import SessionNewResponse as SessionNewResponse +from .session_reauthenticate_params import SessionReauthenticateParams as SessionReauthenticateParams +from .session_reauthenticate_response import SessionReauthenticateResponse as SessionReauthenticateResponse diff --git a/src/finch/types/connect/session_new_params.py b/src/finch/types/connect/session_new_params.py new file mode 100644 index 00000000..4de7c7e6 --- /dev/null +++ b/src/finch/types/connect/session_new_params.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["SessionNewParams", "Integration"] + + +class SessionNewParams(TypedDict, total=False): + customer_id: Required[str] + + customer_name: Required[str] + + products: Required[ + List[Literal["company", "directory", "individual", "employment", "payment", "pay_statement", "benefits", "ssn"]] + ] + + customer_email: Optional[str] + + integration: Optional[Integration] + + manual: Optional[bool] + + minutes_to_expire: Optional[float] + """ + The number of minutes until the session expires (defaults to 10,080, which is 7 + days) + """ + + redirect_uri: Optional[str] + + sandbox: Optional[Literal["finch", "provider"]] + + +class Integration(TypedDict, total=False): + auth_method: Optional[Literal["assisted", "credential", "oauth", "api_token"]] + + provider: Optional[str] diff --git a/src/finch/types/connect/session_new_response.py b/src/finch/types/connect/session_new_response.py new file mode 100644 index 00000000..2faa96c3 --- /dev/null +++ b/src/finch/types/connect/session_new_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + + +from ..._models import BaseModel + +__all__ = ["SessionNewResponse"] + + +class SessionNewResponse(BaseModel): + connect_url: str + """The Connect URL to redirect the user to for authentication""" + + session_id: str + """The unique identifier for the created connect session""" diff --git a/src/finch/types/connect/session_reauthenticate_params.py b/src/finch/types/connect/session_reauthenticate_params.py new file mode 100644 index 00000000..bb6cfca6 --- /dev/null +++ b/src/finch/types/connect/session_reauthenticate_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["SessionReauthenticateParams"] + + +class SessionReauthenticateParams(TypedDict, total=False): + connection_id: Required[str] + """The ID of the existing connection to reauthenticate""" + + minutes_to_expire: Optional[int] + """ + The number of minutes until the session expires (defaults to 10,080, which is 7 + days) + """ + + products: Optional[ + List[Literal["company", "directory", "individual", "employment", "payment", "pay_statement", "benefits", "ssn"]] + ] + """The products to request access to (optional for reauthentication)""" + + redirect_uri: Optional[str] + """The URI to redirect to after the Connect flow is completed""" diff --git a/src/finch/types/connect/session_reauthenticate_response.py b/src/finch/types/connect/session_reauthenticate_response.py new file mode 100644 index 00000000..1f28765a --- /dev/null +++ b/src/finch/types/connect/session_reauthenticate_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + + +from ..._models import BaseModel + +__all__ = ["SessionReauthenticateResponse"] + + +class SessionReauthenticateResponse(BaseModel): + connect_url: str + """The Connect URL to redirect the user to for reauthentication""" + + session_id: str + """The unique identifier for the created connect session""" diff --git a/tests/api_resources/connect/__init__.py b/tests/api_resources/connect/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/connect/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/connect/test_sessions.py b/tests/api_resources/connect/test_sessions.py new file mode 100644 index 00000000..6ea14912 --- /dev/null +++ b/tests/api_resources/connect/test_sessions.py @@ -0,0 +1,217 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from finch import Finch, AsyncFinch +from tests.utils import assert_matches_type +from finch.types.connect import ( + SessionNewResponse, + SessionReauthenticateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSessions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_new(self, client: Finch) -> None: + session = client.connect.sessions.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + ) + assert_matches_type(SessionNewResponse, session, path=["response"]) + + @parametrize + def test_method_new_with_all_params(self, client: Finch) -> None: + session = client.connect.sessions.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + customer_email="dev@stainlessapi.com", + integration={ + "auth_method": "assisted", + "provider": "provider", + }, + manual=True, + minutes_to_expire=1, + redirect_uri="redirect_uri", + sandbox="finch", + ) + assert_matches_type(SessionNewResponse, session, path=["response"]) + + @parametrize + def test_raw_response_new(self, client: Finch) -> None: + response = client.connect.sessions.with_raw_response.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(SessionNewResponse, session, path=["response"]) + + @parametrize + def test_streaming_response_new(self, client: Finch) -> None: + with client.connect.sessions.with_streaming_response.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert_matches_type(SessionNewResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_reauthenticate(self, client: Finch) -> None: + session = client.connect.sessions.reauthenticate( + connection_id="connection_id", + ) + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + @parametrize + def test_method_reauthenticate_with_all_params(self, client: Finch) -> None: + session = client.connect.sessions.reauthenticate( + connection_id="connection_id", + minutes_to_expire=0, + products=["company", "directory", "individual"], + redirect_uri="https://example.com", + ) + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + @parametrize + def test_raw_response_reauthenticate(self, client: Finch) -> None: + response = client.connect.sessions.with_raw_response.reauthenticate( + connection_id="connection_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + @parametrize + def test_streaming_response_reauthenticate(self, client: Finch) -> None: + with client.connect.sessions.with_streaming_response.reauthenticate( + connection_id="connection_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncSessions: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_new(self, async_client: AsyncFinch) -> None: + session = await async_client.connect.sessions.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + ) + assert_matches_type(SessionNewResponse, session, path=["response"]) + + @parametrize + async def test_method_new_with_all_params(self, async_client: AsyncFinch) -> None: + session = await async_client.connect.sessions.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + customer_email="dev@stainlessapi.com", + integration={ + "auth_method": "assisted", + "provider": "provider", + }, + manual=True, + minutes_to_expire=1, + redirect_uri="redirect_uri", + sandbox="finch", + ) + assert_matches_type(SessionNewResponse, session, path=["response"]) + + @parametrize + async def test_raw_response_new(self, async_client: AsyncFinch) -> None: + response = await async_client.connect.sessions.with_raw_response.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(SessionNewResponse, session, path=["response"]) + + @parametrize + async def test_streaming_response_new(self, async_client: AsyncFinch) -> None: + async with async_client.connect.sessions.with_streaming_response.new( + customer_id="x", + customer_name="x", + products=["company", "directory", "individual"], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert_matches_type(SessionNewResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_reauthenticate(self, async_client: AsyncFinch) -> None: + session = await async_client.connect.sessions.reauthenticate( + connection_id="connection_id", + ) + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + @parametrize + async def test_method_reauthenticate_with_all_params(self, async_client: AsyncFinch) -> None: + session = await async_client.connect.sessions.reauthenticate( + connection_id="connection_id", + minutes_to_expire=0, + products=["company", "directory", "individual"], + redirect_uri="https://example.com", + ) + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + @parametrize + async def test_raw_response_reauthenticate(self, async_client: AsyncFinch) -> None: + response = await async_client.connect.sessions.with_raw_response.reauthenticate( + connection_id="connection_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + @parametrize + async def test_streaming_response_reauthenticate(self, async_client: AsyncFinch) -> None: + async with async_client.connect.sessions.with_streaming_response.reauthenticate( + connection_id="connection_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) + + assert cast(Any, response.is_closed) is True