Skip to content

Commit 4109f6c

Browse files
feat(api): benefits mutation API endpoints (create benefit, update benefit, enroll individual, unenroll individual) now properly return async response types (#649)
1 parent bc6c22d commit 4109f6c

File tree

7 files changed

+51
-42
lines changed

7 files changed

+51
-42
lines changed

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 46
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-8c83f0eae70d2a02ed3e2059fc251affdccd2f848f45445e4fed64dfd9ca5985.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bf858f37d7ab420841ddc6329dad8c46377308b6a5c8e935908011d0f9845e22.yml
33
openapi_spec_hash: 2523952a32436e3c7fd3b55508c2e7ee
4-
config_hash: ce10384813f68ba3fed61c7b601b396b
4+
config_hash: 4a8def48077df6382ed9fe00588baecf

api.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,19 @@ Types:
189189

190190
```python
191191
from finch.types.hris.benefits import (
192+
EnrolledIndividualBenifit,
192193
IndividualBenefit,
193-
IndividualEnrollManyResponse,
194194
IndividualEnrolledIDsResponse,
195195
IndividualUnenrollManyResponse,
196196
)
197197
```
198198

199199
Methods:
200200

201-
- <code title="post /employer/benefits/{benefit_id}/individuals">client.hris.benefits.individuals.<a href="./src/finch/resources/hris/benefits/individuals.py">enroll_many</a>(benefit_id, \*\*<a href="src/finch/types/hris/benefits/individual_enroll_many_params.py">params</a>) -> <a href="./src/finch/types/hris/benefits/individual_enroll_many_response.py">IndividualEnrollManyResponse</a></code>
201+
- <code title="post /employer/benefits/{benefit_id}/individuals">client.hris.benefits.individuals.<a href="./src/finch/resources/hris/benefits/individuals.py">enroll_many</a>(benefit_id, \*\*<a href="src/finch/types/hris/benefits/individual_enroll_many_params.py">params</a>) -> <a href="./src/finch/types/hris/benefits/enrolled_individual_benifit.py">EnrolledIndividualBenifit</a></code>
202202
- <code title="get /employer/benefits/{benefit_id}/enrolled">client.hris.benefits.individuals.<a href="./src/finch/resources/hris/benefits/individuals.py">enrolled_ids</a>(benefit_id) -> <a href="./src/finch/types/hris/benefits/individual_enrolled_ids_response.py">IndividualEnrolledIDsResponse</a></code>
203203
- <code title="get /employer/benefits/{benefit_id}/individuals">client.hris.benefits.individuals.<a href="./src/finch/resources/hris/benefits/individuals.py">retrieve_many_benefits</a>(benefit_id, \*\*<a href="src/finch/types/hris/benefits/individual_retrieve_many_benefits_params.py">params</a>) -> <a href="./src/finch/types/hris/benefits/individual_benefit.py">SyncSinglePage[IndividualBenefit]</a></code>
204-
- <code title="delete /employer/benefits/{benefit_id}/individuals">client.hris.benefits.individuals.<a href="./src/finch/resources/hris/benefits/individuals.py">unenroll_many</a>(benefit_id, \*\*<a href="src/finch/types/hris/benefits/individual_unenroll_many_params.py">params</a>) -> <a href="./src/finch/types/hris/benefits/individual_unenroll_many_response.py">SyncSinglePage[object]</a></code>
204+
- <code title="delete /employer/benefits/{benefit_id}/individuals">client.hris.benefits.individuals.<a href="./src/finch/resources/hris/benefits/individuals.py">unenroll_many</a>(benefit_id, \*\*<a href="src/finch/types/hris/benefits/individual_unenroll_many_params.py">params</a>) -> <a href="./src/finch/types/hris/benefits/individual_unenroll_many_response.py">IndividualUnenrollManyResponse</a></code>
205205

206206
# Providers
207207

src/finch/resources/hris/benefits/individuals.py

+14-17
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
individual_retrieve_many_benefits_params,
2424
)
2525
from ....types.hris.benefits.individual_benefit import IndividualBenefit
26-
from ....types.hris.benefits.individual_enroll_many_response import IndividualEnrollManyResponse
26+
from ....types.hris.benefits.enrolled_individual_benifit import EnrolledIndividualBenifit
2727
from ....types.hris.benefits.individual_enrolled_ids_response import IndividualEnrolledIDsResponse
28+
from ....types.hris.benefits.individual_unenroll_many_response import IndividualUnenrollManyResponse
2829

2930
__all__ = ["Individuals", "AsyncIndividuals"]
3031

@@ -60,7 +61,7 @@ def enroll_many(
6061
extra_query: Query | None = None,
6162
extra_body: Body | None = None,
6263
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
63-
) -> IndividualEnrollManyResponse:
64+
) -> EnrolledIndividualBenifit:
6465
"""Enroll an individual into a deduction or contribution.
6566
6667
This is an overwrite
@@ -87,7 +88,7 @@ def enroll_many(
8788
options=make_request_options(
8889
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
8990
),
90-
cast_to=IndividualEnrollManyResponse,
91+
cast_to=EnrolledIndividualBenifit,
9192
)
9293

9394
def enrolled_ids(
@@ -179,7 +180,7 @@ def unenroll_many(
179180
extra_query: Query | None = None,
180181
extra_body: Body | None = None,
181182
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
182-
) -> SyncSinglePage[object]:
183+
) -> IndividualUnenrollManyResponse:
183184
"""
184185
Unenroll individuals from a deduction or contribution
185186
@@ -196,17 +197,15 @@ def unenroll_many(
196197
"""
197198
if not benefit_id:
198199
raise ValueError(f"Expected a non-empty value for `benefit_id` but received {benefit_id!r}")
199-
return self._get_api_list(
200+
return self._delete(
200201
f"/employer/benefits/{benefit_id}/individuals",
201-
page=SyncSinglePage[object],
202202
body=maybe_transform(
203203
{"individual_ids": individual_ids}, individual_unenroll_many_params.IndividualUnenrollManyParams
204204
),
205205
options=make_request_options(
206206
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
207207
),
208-
model=object,
209-
method="delete",
208+
cast_to=IndividualUnenrollManyResponse,
210209
)
211210

212211

@@ -241,7 +240,7 @@ async def enroll_many(
241240
extra_query: Query | None = None,
242241
extra_body: Body | None = None,
243242
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
244-
) -> IndividualEnrollManyResponse:
243+
) -> EnrolledIndividualBenifit:
245244
"""Enroll an individual into a deduction or contribution.
246245
247246
This is an overwrite
@@ -268,7 +267,7 @@ async def enroll_many(
268267
options=make_request_options(
269268
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
270269
),
271-
cast_to=IndividualEnrollManyResponse,
270+
cast_to=EnrolledIndividualBenifit,
272271
)
273272

274273
async def enrolled_ids(
@@ -349,7 +348,7 @@ def retrieve_many_benefits(
349348
model=IndividualBenefit,
350349
)
351350

352-
def unenroll_many(
351+
async def unenroll_many(
353352
self,
354353
benefit_id: str,
355354
*,
@@ -360,7 +359,7 @@ def unenroll_many(
360359
extra_query: Query | None = None,
361360
extra_body: Body | None = None,
362361
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
363-
) -> AsyncPaginator[object, AsyncSinglePage[object]]:
362+
) -> IndividualUnenrollManyResponse:
364363
"""
365364
Unenroll individuals from a deduction or contribution
366365
@@ -377,17 +376,15 @@ def unenroll_many(
377376
"""
378377
if not benefit_id:
379378
raise ValueError(f"Expected a non-empty value for `benefit_id` but received {benefit_id!r}")
380-
return self._get_api_list(
379+
return await self._delete(
381380
f"/employer/benefits/{benefit_id}/individuals",
382-
page=AsyncSinglePage[object],
383-
body=maybe_transform(
381+
body=await async_maybe_transform(
384382
{"individual_ids": individual_ids}, individual_unenroll_many_params.IndividualUnenrollManyParams
385383
),
386384
options=make_request_options(
387385
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
388386
),
389-
model=object,
390-
method="delete",
387+
cast_to=IndividualUnenrollManyResponse,
391388
)
392389

393390

src/finch/types/hris/benefits/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from __future__ import annotations
44

55
from .individual_benefit import IndividualBenefit as IndividualBenefit
6+
from .enrolled_individual_benifit import EnrolledIndividualBenifit as EnrolledIndividualBenifit
67
from .individual_enroll_many_params import IndividualEnrollManyParams as IndividualEnrollManyParams
7-
from .individual_enroll_many_response import IndividualEnrollManyResponse as IndividualEnrollManyResponse
88
from .individual_unenroll_many_params import IndividualUnenrollManyParams as IndividualUnenrollManyParams
99
from .individual_enrolled_ids_response import IndividualEnrolledIDsResponse as IndividualEnrolledIDsResponse
10+
from .individual_unenroll_many_response import IndividualUnenrollManyResponse as IndividualUnenrollManyResponse
1011
from .individual_retrieve_many_benefits_params import (
1112
IndividualRetrieveManyBenefitsParams as IndividualRetrieveManyBenefitsParams,
1213
)

src/finch/types/hris/benefits/individual_enroll_many_response.py renamed to src/finch/types/hris/benefits/enrolled_individual_benifit.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
from ...._models import BaseModel
55

6-
__all__ = ["IndividualEnrollManyResponse"]
6+
__all__ = ["EnrolledIndividualBenifit"]
77

88

9-
class IndividualEnrollManyResponse(BaseModel):
9+
class EnrolledIndividualBenifit(BaseModel):
1010
job_id: str
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
4+
from ...._models import BaseModel
5+
6+
__all__ = ["IndividualUnenrollManyResponse"]
7+
8+
9+
class IndividualUnenrollManyResponse(BaseModel):
10+
job_id: str

tests/api_resources/hris/benefits/test_individuals.py

+18-17
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
from finch.pagination import SyncSinglePage, AsyncSinglePage
1414
from finch.types.hris.benefits import (
1515
IndividualBenefit,
16-
IndividualEnrollManyResponse,
16+
EnrolledIndividualBenifit,
1717
IndividualEnrolledIDsResponse,
18+
IndividualUnenrollManyResponse,
1819
)
1920

2021
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -28,7 +29,7 @@ def test_method_enroll_many(self, client: Finch) -> None:
2829
individual = client.hris.benefits.individuals.enroll_many(
2930
benefit_id="benefit_id",
3031
)
31-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
32+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
3233

3334
@parametrize
3435
def test_method_enroll_many_with_all_params(self, client: Finch) -> None:
@@ -54,7 +55,7 @@ def test_method_enroll_many_with_all_params(self, client: Finch) -> None:
5455
}
5556
],
5657
)
57-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
58+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
5859

5960
@parametrize
6061
def test_raw_response_enroll_many(self, client: Finch) -> None:
@@ -65,7 +66,7 @@ def test_raw_response_enroll_many(self, client: Finch) -> None:
6566
assert response.is_closed is True
6667
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
6768
individual = response.parse()
68-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
69+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
6970

7071
@parametrize
7172
def test_streaming_response_enroll_many(self, client: Finch) -> None:
@@ -76,7 +77,7 @@ def test_streaming_response_enroll_many(self, client: Finch) -> None:
7677
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
7778

7879
individual = response.parse()
79-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
80+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
8081

8182
assert cast(Any, response.is_closed) is True
8283

@@ -176,15 +177,15 @@ def test_method_unenroll_many(self, client: Finch) -> None:
176177
individual = client.hris.benefits.individuals.unenroll_many(
177178
benefit_id="benefit_id",
178179
)
179-
assert_matches_type(SyncSinglePage[object], individual, path=["response"])
180+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
180181

181182
@parametrize
182183
def test_method_unenroll_many_with_all_params(self, client: Finch) -> None:
183184
individual = client.hris.benefits.individuals.unenroll_many(
184185
benefit_id="benefit_id",
185186
individual_ids=["string"],
186187
)
187-
assert_matches_type(SyncSinglePage[object], individual, path=["response"])
188+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
188189

189190
@parametrize
190191
def test_raw_response_unenroll_many(self, client: Finch) -> None:
@@ -195,7 +196,7 @@ def test_raw_response_unenroll_many(self, client: Finch) -> None:
195196
assert response.is_closed is True
196197
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
197198
individual = response.parse()
198-
assert_matches_type(SyncSinglePage[object], individual, path=["response"])
199+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
199200

200201
@parametrize
201202
def test_streaming_response_unenroll_many(self, client: Finch) -> None:
@@ -206,7 +207,7 @@ def test_streaming_response_unenroll_many(self, client: Finch) -> None:
206207
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
207208

208209
individual = response.parse()
209-
assert_matches_type(SyncSinglePage[object], individual, path=["response"])
210+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
210211

211212
assert cast(Any, response.is_closed) is True
212213

@@ -226,7 +227,7 @@ async def test_method_enroll_many(self, async_client: AsyncFinch) -> None:
226227
individual = await async_client.hris.benefits.individuals.enroll_many(
227228
benefit_id="benefit_id",
228229
)
229-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
230+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
230231

231232
@parametrize
232233
async def test_method_enroll_many_with_all_params(self, async_client: AsyncFinch) -> None:
@@ -252,7 +253,7 @@ async def test_method_enroll_many_with_all_params(self, async_client: AsyncFinch
252253
}
253254
],
254255
)
255-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
256+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
256257

257258
@parametrize
258259
async def test_raw_response_enroll_many(self, async_client: AsyncFinch) -> None:
@@ -263,7 +264,7 @@ async def test_raw_response_enroll_many(self, async_client: AsyncFinch) -> None:
263264
assert response.is_closed is True
264265
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
265266
individual = response.parse()
266-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
267+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
267268

268269
@parametrize
269270
async def test_streaming_response_enroll_many(self, async_client: AsyncFinch) -> None:
@@ -274,7 +275,7 @@ async def test_streaming_response_enroll_many(self, async_client: AsyncFinch) ->
274275
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
275276

276277
individual = await response.parse()
277-
assert_matches_type(IndividualEnrollManyResponse, individual, path=["response"])
278+
assert_matches_type(EnrolledIndividualBenifit, individual, path=["response"])
278279

279280
assert cast(Any, response.is_closed) is True
280281

@@ -374,15 +375,15 @@ async def test_method_unenroll_many(self, async_client: AsyncFinch) -> None:
374375
individual = await async_client.hris.benefits.individuals.unenroll_many(
375376
benefit_id="benefit_id",
376377
)
377-
assert_matches_type(AsyncSinglePage[object], individual, path=["response"])
378+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
378379

379380
@parametrize
380381
async def test_method_unenroll_many_with_all_params(self, async_client: AsyncFinch) -> None:
381382
individual = await async_client.hris.benefits.individuals.unenroll_many(
382383
benefit_id="benefit_id",
383384
individual_ids=["string"],
384385
)
385-
assert_matches_type(AsyncSinglePage[object], individual, path=["response"])
386+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
386387

387388
@parametrize
388389
async def test_raw_response_unenroll_many(self, async_client: AsyncFinch) -> None:
@@ -393,7 +394,7 @@ async def test_raw_response_unenroll_many(self, async_client: AsyncFinch) -> Non
393394
assert response.is_closed is True
394395
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
395396
individual = response.parse()
396-
assert_matches_type(AsyncSinglePage[object], individual, path=["response"])
397+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
397398

398399
@parametrize
399400
async def test_streaming_response_unenroll_many(self, async_client: AsyncFinch) -> None:
@@ -404,7 +405,7 @@ async def test_streaming_response_unenroll_many(self, async_client: AsyncFinch)
404405
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
405406

406407
individual = await response.parse()
407-
assert_matches_type(AsyncSinglePage[object], individual, path=["response"])
408+
assert_matches_type(IndividualUnenrollManyResponse, individual, path=["response"])
408409

409410
assert cast(Any, response.is_closed) is True
410411

0 commit comments

Comments
 (0)