diff --git a/src/finch/_base_client.py b/src/finch/_base_client.py index d9300541..3d2ff12d 100644 --- a/src/finch/_base_client.py +++ b/src/finch/_base_client.py @@ -519,7 +519,7 @@ def _build_request( # so that passing a `TypedDict` doesn't cause an error. # https://github.com/microsoft/pyright/issues/3526#event-6715453066 params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None, - json=json_data, + json=json_data if is_given(json_data) else None, files=files, **kwargs, ) diff --git a/src/finch/resources/hris/benefits/individuals.py b/src/finch/resources/hris/benefits/individuals.py index 19ab83a7..c6e472cf 100644 --- a/src/finch/resources/hris/benefits/individuals.py +++ b/src/finch/resources/hris/benefits/individuals.py @@ -51,7 +51,7 @@ def enroll_many( self, benefit_id: str, *, - individuals: Iterable[individual_enroll_many_params.Individual], + individuals: Iterable[individual_enroll_many_params.Individual] | 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, @@ -234,7 +234,7 @@ def enroll_many( self, benefit_id: str, *, - individuals: Iterable[individual_enroll_many_params.Individual], + individuals: Iterable[individual_enroll_many_params.Individual] | 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, diff --git a/src/finch/resources/sandbox/directory.py b/src/finch/resources/sandbox/directory.py index 6d2d4cb1..0cb518ab 100644 --- a/src/finch/resources/sandbox/directory.py +++ b/src/finch/resources/sandbox/directory.py @@ -45,7 +45,7 @@ def with_streaming_response(self) -> DirectoryWithStreamingResponse: def create( self, *, - body: Iterable[directory_create_params.Body], + body: Iterable[directory_create_params.Body] | 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, @@ -101,7 +101,7 @@ def with_streaming_response(self) -> AsyncDirectoryWithStreamingResponse: async def create( self, *, - body: Iterable[directory_create_params.Body], + body: Iterable[directory_create_params.Body] | 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, diff --git a/src/finch/types/hris/benefits/individual_enroll_many_params.py b/src/finch/types/hris/benefits/individual_enroll_many_params.py index 95164f87..b5358caf 100644 --- a/src/finch/types/hris/benefits/individual_enroll_many_params.py +++ b/src/finch/types/hris/benefits/individual_enroll_many_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable, Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict __all__ = [ "IndividualEnrollManyParams", @@ -15,7 +15,7 @@ class IndividualEnrollManyParams(TypedDict, total=False): - individuals: Required[Iterable[Individual]] + individuals: Iterable[Individual] """Array of the individual_id to enroll and a configuration object.""" diff --git a/src/finch/types/sandbox/directory_create_params.py b/src/finch/types/sandbox/directory_create_params.py index 1684d178..939c3170 100644 --- a/src/finch/types/sandbox/directory_create_params.py +++ b/src/finch/types/sandbox/directory_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable, Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, TypedDict from ..income_param import IncomeParam from ..location_param import LocationParam @@ -21,7 +21,7 @@ class DirectoryCreateParams(TypedDict, total=False): - body: Required[Iterable[Body]] + body: Iterable[Body] """Array of individuals to create. Takes all combined fields from `/individual` and `/employment` endpoints. All diff --git a/tests/api_resources/hris/benefits/test_individuals.py b/tests/api_resources/hris/benefits/test_individuals.py index 29438100..6fe22b42 100644 --- a/tests/api_resources/hris/benefits/test_individuals.py +++ b/tests/api_resources/hris/benefits/test_individuals.py @@ -27,7 +27,31 @@ class TestIndividuals: def test_method_enroll_many(self, client: Finch) -> None: individual = client.hris.benefits.individuals.enroll_many( benefit_id="benefit_id", - individuals=[{}], + ) + assert_matches_type(SyncSinglePage[EnrolledIndividual], individual, path=["response"]) + + @parametrize + def test_method_enroll_many_with_all_params(self, client: Finch) -> None: + individual = client.hris.benefits.individuals.enroll_many( + benefit_id="benefit_id", + individuals=[ + { + "configuration": { + "annual_contribution_limit": "individual", + "annual_maximum": 500000, + "catch_up": False, + "company_contribution": { + "amount": 400, + "type": "fixed", + }, + "employee_deduction": { + "amount": 1000, + "type": "fixed", + }, + }, + "individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a", + } + ], ) assert_matches_type(SyncSinglePage[EnrolledIndividual], individual, path=["response"]) @@ -35,7 +59,6 @@ def test_method_enroll_many(self, client: Finch) -> None: def test_raw_response_enroll_many(self, client: Finch) -> None: response = client.hris.benefits.individuals.with_raw_response.enroll_many( benefit_id="benefit_id", - individuals=[{}], ) assert response.is_closed is True @@ -47,7 +70,6 @@ def test_raw_response_enroll_many(self, client: Finch) -> None: def test_streaming_response_enroll_many(self, client: Finch) -> None: with client.hris.benefits.individuals.with_streaming_response.enroll_many( benefit_id="benefit_id", - individuals=[{}], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -62,7 +84,6 @@ def test_path_params_enroll_many(self, client: Finch) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"): client.hris.benefits.individuals.with_raw_response.enroll_many( benefit_id="", - individuals=[{}], ) @parametrize @@ -203,7 +224,31 @@ class TestAsyncIndividuals: async def test_method_enroll_many(self, async_client: AsyncFinch) -> None: individual = await async_client.hris.benefits.individuals.enroll_many( benefit_id="benefit_id", - individuals=[{}], + ) + assert_matches_type(AsyncSinglePage[EnrolledIndividual], individual, path=["response"]) + + @parametrize + async def test_method_enroll_many_with_all_params(self, async_client: AsyncFinch) -> None: + individual = await async_client.hris.benefits.individuals.enroll_many( + benefit_id="benefit_id", + individuals=[ + { + "configuration": { + "annual_contribution_limit": "individual", + "annual_maximum": 500000, + "catch_up": False, + "company_contribution": { + "amount": 400, + "type": "fixed", + }, + "employee_deduction": { + "amount": 1000, + "type": "fixed", + }, + }, + "individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a", + } + ], ) assert_matches_type(AsyncSinglePage[EnrolledIndividual], individual, path=["response"]) @@ -211,7 +256,6 @@ async def test_method_enroll_many(self, async_client: AsyncFinch) -> None: async def test_raw_response_enroll_many(self, async_client: AsyncFinch) -> None: response = await async_client.hris.benefits.individuals.with_raw_response.enroll_many( benefit_id="benefit_id", - individuals=[{}], ) assert response.is_closed is True @@ -223,7 +267,6 @@ async def test_raw_response_enroll_many(self, async_client: AsyncFinch) -> None: async def test_streaming_response_enroll_many(self, async_client: AsyncFinch) -> None: async with async_client.hris.benefits.individuals.with_streaming_response.enroll_many( benefit_id="benefit_id", - individuals=[{}], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -238,7 +281,6 @@ async def test_path_params_enroll_many(self, async_client: AsyncFinch) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"): await async_client.hris.benefits.individuals.with_raw_response.enroll_many( benefit_id="", - individuals=[{}], ) @parametrize diff --git a/tests/api_resources/sandbox/test_directory.py b/tests/api_resources/sandbox/test_directory.py index a42d4fcb..104e1a24 100644 --- a/tests/api_resources/sandbox/test_directory.py +++ b/tests/api_resources/sandbox/test_directory.py @@ -19,16 +19,97 @@ class TestDirectory: @parametrize def test_method_create(self, client: Finch) -> None: + directory = client.sandbox.directory.create() + assert_matches_type(DirectoryCreateResponse, directory, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Finch) -> None: directory = client.sandbox.directory.create( - body=[{}], + body=[ + { + "class_code": "class_code", + "custom_fields": [ + { + "name": "name", + "value": {}, + } + ], + "department": {"name": "name"}, + "dob": "dob", + "emails": [ + { + "data": "data", + "type": "work", + } + ], + "employment": { + "subtype": "full_time", + "type": "employee", + }, + "employment_status": "active", + "encrypted_ssn": "encrypted_ssn", + "end_date": "end_date", + "ethnicity": "asian", + "first_name": "first_name", + "gender": "female", + "income": { + "amount": 0, + "currency": "currency", + "effective_date": "effective_date", + "unit": "yearly", + }, + "income_history": [ + { + "amount": 0, + "currency": "currency", + "effective_date": "effective_date", + "unit": "yearly", + } + ], + "is_active": True, + "last_name": "last_name", + "latest_rehire_date": "latest_rehire_date", + "location": { + "city": "city", + "country": "country", + "line1": "line1", + "line2": "line2", + "name": "name", + "postal_code": "postal_code", + "source_id": "source_id", + "state": "state", + }, + "manager": {"id": "id"}, + "middle_name": "middle_name", + "phone_numbers": [ + { + "data": "data", + "type": "work", + } + ], + "preferred_name": "preferred_name", + "residence": { + "city": "city", + "country": "country", + "line1": "line1", + "line2": "line2", + "name": "name", + "postal_code": "postal_code", + "source_id": "source_id", + "state": "state", + }, + "source_id": "source_id", + "ssn": "ssn", + "start_date": "start_date", + "title": "title", + } + ], ) assert_matches_type(DirectoryCreateResponse, directory, path=["response"]) @parametrize def test_raw_response_create(self, client: Finch) -> None: - response = client.sandbox.directory.with_raw_response.create( - body=[{}], - ) + response = client.sandbox.directory.with_raw_response.create() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -37,9 +118,7 @@ def test_raw_response_create(self, client: Finch) -> None: @parametrize def test_streaming_response_create(self, client: Finch) -> None: - with client.sandbox.directory.with_streaming_response.create( - body=[{}], - ) as response: + with client.sandbox.directory.with_streaming_response.create() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -54,16 +133,97 @@ class TestAsyncDirectory: @parametrize async def test_method_create(self, async_client: AsyncFinch) -> None: + directory = await async_client.sandbox.directory.create() + assert_matches_type(DirectoryCreateResponse, directory, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None: directory = await async_client.sandbox.directory.create( - body=[{}], + body=[ + { + "class_code": "class_code", + "custom_fields": [ + { + "name": "name", + "value": {}, + } + ], + "department": {"name": "name"}, + "dob": "dob", + "emails": [ + { + "data": "data", + "type": "work", + } + ], + "employment": { + "subtype": "full_time", + "type": "employee", + }, + "employment_status": "active", + "encrypted_ssn": "encrypted_ssn", + "end_date": "end_date", + "ethnicity": "asian", + "first_name": "first_name", + "gender": "female", + "income": { + "amount": 0, + "currency": "currency", + "effective_date": "effective_date", + "unit": "yearly", + }, + "income_history": [ + { + "amount": 0, + "currency": "currency", + "effective_date": "effective_date", + "unit": "yearly", + } + ], + "is_active": True, + "last_name": "last_name", + "latest_rehire_date": "latest_rehire_date", + "location": { + "city": "city", + "country": "country", + "line1": "line1", + "line2": "line2", + "name": "name", + "postal_code": "postal_code", + "source_id": "source_id", + "state": "state", + }, + "manager": {"id": "id"}, + "middle_name": "middle_name", + "phone_numbers": [ + { + "data": "data", + "type": "work", + } + ], + "preferred_name": "preferred_name", + "residence": { + "city": "city", + "country": "country", + "line1": "line1", + "line2": "line2", + "name": "name", + "postal_code": "postal_code", + "source_id": "source_id", + "state": "state", + }, + "source_id": "source_id", + "ssn": "ssn", + "start_date": "start_date", + "title": "title", + } + ], ) assert_matches_type(DirectoryCreateResponse, directory, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncFinch) -> None: - response = await async_client.sandbox.directory.with_raw_response.create( - body=[{}], - ) + response = await async_client.sandbox.directory.with_raw_response.create() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -72,9 +232,7 @@ async def test_raw_response_create(self, async_client: AsyncFinch) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: - async with async_client.sandbox.directory.with_streaming_response.create( - body=[{}], - ) as response: + async with async_client.sandbox.directory.with_streaming_response.create() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python"