Skip to content

fix: correct benfits to benefits #125

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 11, 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
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and offers both synchronous and asynchronous clients powered by [httpx](https://

## Documentation

The API documentation can be found at [https://developer.tryfinch.com/](https://developer.tryfinch.com/).
The API documentation can be found [in the Finch Documentation Center](https://developer.tryfinch.com/).

## Installation

Expand All @@ -27,7 +27,7 @@ client = Finch(
access_token="my access token",
)

page = client.hris.directory.list_individuals(
page = client.hris.directory.list(
candidate_id="<candidate id>",
)
directory = page.individuals[0]
Expand All @@ -47,7 +47,7 @@ client = AsyncFinch(


async def main():
page = await client.hris.directory.list_individuals(
page = await client.hris.directory.list(
candidate_id="<candidate id>",
)
print(page.individuals[0].first_name)
Expand Down Expand Up @@ -77,7 +77,7 @@ client = Finch()

all_directories = []
# Automatically fetches more pages as needed.
for directory in client.hris.directory.list_individuals():
for directory in client.hris.directory.list():
# Do something with directory here
all_directories.append(directory)
print(all_directories)
Expand All @@ -95,7 +95,7 @@ client = AsyncFinch()
async def main() -> None:
all_directories = []
# Iterate through items across all pages, issuing requests as needed.
async for directory in client.hris.directory.list_individuals():
async for directory in client.hris.directory.list():
all_directories.append(directory)
print(all_directories)

Expand All @@ -106,7 +106,7 @@ asyncio.run(main())
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:

```python
first_page = await client.hris.directory.list_individuals()
first_page = await client.hris.directory.list()
if first_page.has_next_page():
print(f"will fetch next page using these details: {first_page.next_page_info()}")
next_page = await first_page.get_next_page()
Expand All @@ -118,7 +118,7 @@ if first_page.has_next_page():
Or just work directly with the returned data:

```python
first_page = await client.hris.directory.list_individuals()
first_page = await client.hris.directory.list()

print(
f"the current start offset for this page: {first_page.paging.offset}"
Expand All @@ -138,7 +138,7 @@ from finch import Finch

client = Finch()

client.hris.directory.list_individuals(
client.hris.directory.list(
path_params=[],
params={},
)
Expand Down Expand Up @@ -183,7 +183,7 @@ from finch import Finch
client = Finch()

try:
client.hris.directory.list_individuals()
client.hris.directory.list()
except finch.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -226,7 +226,7 @@ client = Finch(
)

# Or, configure per-request:
client.with_options(max_retries=5).hris.directory.list_individuals()
client.with_options(max_retries=5).hris.directory.list()
```

### Timeouts
Expand All @@ -249,7 +249,7 @@ client = Finch(
)

# Override per-request:
client.with_options(timeout=5 * 1000).hris.directory.list_individuals()
client.with_options(timeout=5 * 1000).hris.directory.list()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -313,7 +313,7 @@ By default the library closes underlying HTTP connections whenever the client is

## Versioning

This package generally attempts to follow [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

1. Changes that only affect static types, without breaking runtime behavior.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
Expand Down
3 changes: 2 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from finch.types.hris import IndividualInDirectory

Methods:

- <code title="get /employer/directory">client.hris.directory.<a href="./src/finch/resources/hris/directory.py">list_individuals</a>(\*\*<a href="src/finch/types/hris/directory_list_individuals_params.py">params</a>) -> <a href="./src/finch/types/hris/individual_in_directory.py">SyncIndividualsPage[IndividualInDirectory]</a></code>
- <code title="get /employer/directory">client.hris.directory.<a href="./src/finch/resources/hris/directory.py">list</a>(\*\*<a href="src/finch/types/hris/directory_list_params.py">params</a>) -> <a href="./src/finch/types/hris/individual_in_directory.py">SyncIndividualsPage[IndividualInDirectory]</a></code>

## Individuals

Expand Down Expand Up @@ -95,6 +95,7 @@ Types:

```python
from finch.types.hris import (
BenefitContribution,
BenefitFrequency,
BenefitType,
BenfitContribution,
Expand Down
88 changes: 83 additions & 5 deletions src/finch/resources/hris/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

from __future__ import annotations

import typing_extensions

from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import maybe_transform
from ..._resource import SyncAPIResource, AsyncAPIResource
from ...pagination import SyncIndividualsPage, AsyncIndividualsPage
from ...types.hris import IndividualInDirectory, directory_list_individuals_params
from ...types.hris import IndividualInDirectory, directory_list_params
from ..._base_client import AsyncPaginator, make_request_options

__all__ = ["Directory", "AsyncDirectory"]


class Directory(SyncAPIResource):
def list_individuals(
def list(
self,
*,
limit: int | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -54,15 +56,53 @@ def list_individuals(
"limit": limit,
"offset": offset,
},
directory_list_individuals_params.DirectoryListIndividualsParams,
directory_list_params.DirectoryListParams,
),
),
model=IndividualInDirectory,
)

@typing_extensions.deprecated("use `list` instead")
def list_individuals(
self,
*,
limit: int | NotGiven = NOT_GIVEN,
offset: int | 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,
) -> SyncIndividualsPage[IndividualInDirectory]:
"""
Read company directory and organization structure

Args:
limit: Number of employees to return (defaults to all)

offset: Index to start from (defaults to 0)

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.list(
limit=limit,
offset=offset,
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
)


class AsyncDirectory(AsyncAPIResource):
def list_individuals(
def list(
self,
*,
limit: int | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -103,8 +143,46 @@ def list_individuals(
"limit": limit,
"offset": offset,
},
directory_list_individuals_params.DirectoryListIndividualsParams,
directory_list_params.DirectoryListParams,
),
),
model=IndividualInDirectory,
)

@typing_extensions.deprecated("use `list` instead")
def list_individuals(
self,
*,
limit: int | NotGiven = NOT_GIVEN,
offset: int | 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,
) -> AsyncPaginator[IndividualInDirectory, AsyncIndividualsPage[IndividualInDirectory]]:
"""
Read company directory and organization structure

Args:
limit: Number of employees to return (defaults to all)

offset: Index to start from (defaults to 0)

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.list(
limit=limit,
offset=offset,
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
)
2 changes: 2 additions & 0 deletions src/finch/types/hris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
from .benfit_contribution import BenfitContribution as BenfitContribution
from .individual_response import IndividualResponse as IndividualResponse
from .payment_list_params import PaymentListParams as PaymentListParams
from .benefit_contribution import BenefitContribution as BenefitContribution
from .benefit_create_params import BenefitCreateParams as BenefitCreateParams
from .benefit_update_params import BenefitUpdateParams as BenefitUpdateParams
from .directory_list_params import DirectoryListParams as DirectoryListParams
from .pay_statement_response import PayStatementResponse as PayStatementResponse
from .individual_in_directory import IndividualInDirectory as IndividualInDirectory
from .employment_data_response import EmploymentDataResponse as EmploymentDataResponse
Expand Down
16 changes: 16 additions & 0 deletions src/finch/types/hris/benefit_contribution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# File generated from our OpenAPI spec by Stainless.

from typing import Optional
from typing_extensions import Literal

from ..._models import BaseModel

__all__ = ["BenefitContribution"]


class BenefitContribution(BaseModel):
amount: Optional[int] = None
"""Contribution amount in cents (if `fixed`) or basis points (if `percent`)."""

type: Optional[Literal["fixed", "percent"]] = None
"""Contribution type."""
6 changes: 3 additions & 3 deletions src/finch/types/hris/benefits/individual_benefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing_extensions import Literal

from ...._models import BaseModel
from ..benfit_contribution import BenfitContribution
from ..benefit_contribution import BenefitContribution

__all__ = ["IndividualBenefit", "Body"]

Expand All @@ -21,9 +21,9 @@ class Body(BaseModel):
for this individual.
"""

company_contribution: Optional[BenfitContribution] = None
company_contribution: Optional[BenefitContribution] = None

employee_deduction: Optional[BenfitContribution] = None
employee_deduction: Optional[BenefitContribution] = None

hsa_contribution_limit: Optional[Literal["individual", "family"]] = None
"""Type for HSA contribution limit if the benefit is a HSA."""
Expand Down
15 changes: 3 additions & 12 deletions src/finch/types/hris/benfit_contribution.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# File generated from our OpenAPI spec by Stainless.

from typing import Optional
from typing_extensions import Literal

from ..._models import BaseModel
from .benefit_contribution import BenefitContribution

__all__ = ["BenfitContribution"]


class BenfitContribution(BaseModel):
amount: Optional[int] = None
"""Contribution amount in cents (if `fixed`) or basis points (if `percent`)."""

type: Optional[Literal["fixed", "percent"]] = None
"""Contribution type."""
BenfitContribution = BenefitContribution
"""use `BenefitContribution` instead"""
6 changes: 3 additions & 3 deletions src/finch/types/hris/company_benefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
from ..._models import BaseModel
from .benefit_type import BenefitType
from .benefit_frequency import BenefitFrequency
from .benfit_contribution import BenfitContribution
from .benefit_contribution import BenefitContribution

__all__ = ["CompanyBenefit"]


class CompanyBenefit(BaseModel):
benefit_id: str

company_contribution: Optional[BenfitContribution]
company_contribution: Optional[BenefitContribution]

description: Optional[str]

employee_deduction: Optional[BenfitContribution]
employee_deduction: Optional[BenefitContribution]

frequency: Optional[BenefitFrequency]

Expand Down
15 changes: 15 additions & 0 deletions src/finch/types/hris/directory_list_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# File generated from our OpenAPI spec by Stainless.

from __future__ import annotations

from typing_extensions import TypedDict

__all__ = ["DirectoryListParams"]


class DirectoryListParams(TypedDict, total=False):
limit: int
"""Number of employees to return (defaults to all)"""

offset: int
"""Index to start from (defaults to 0)"""
Loading