Skip to content

feat(client)!: restructure some methods #80

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
Aug 29, 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
146 changes: 73 additions & 73 deletions api.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/finch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@


class Finch(SyncAPIClient):
ats: resources.ATS
hris: resources.HRIS
ats: resources.ATS
providers: resources.Providers
account: resources.Account

Expand Down Expand Up @@ -112,8 +112,8 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.ats = resources.ATS(self)
self.hris = resources.HRIS(self)
self.ats = resources.ATS(self)
self.providers = resources.Providers(self)
self.account = resources.Account(self)

Expand Down Expand Up @@ -268,8 +268,8 @@ def get_auth_url(


class AsyncFinch(AsyncAPIClient):
ats: resources.AsyncATS
hris: resources.AsyncHRIS
ats: resources.AsyncATS
providers: resources.AsyncProviders
account: resources.AsyncAccount

Expand Down Expand Up @@ -335,8 +335,8 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self.ats = resources.AsyncATS(self)
self.hris = resources.AsyncHRIS(self)
self.ats = resources.AsyncATS(self)
self.providers = resources.AsyncProviders(self)
self.account = resources.AsyncAccount(self)

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from .account import Account, AsyncAccount
from .providers import Providers, AsyncProviders

__all__ = ["ATS", "AsyncATS", "HRIS", "AsyncHRIS", "Providers", "AsyncProviders", "Account", "AsyncAccount"]
__all__ = ["HRIS", "AsyncHRIS", "ATS", "AsyncATS", "Providers", "AsyncProviders", "Account", "AsyncAccount"]
11 changes: 7 additions & 4 deletions src/finch/resources/hris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
from .benefits import Benefits, AsyncBenefits
from .payments import Payments, AsyncPayments
from .directory import Directory, AsyncDirectory
from .employments import Employments, AsyncEmployments
from .individuals import Individuals, AsyncIndividuals
from .pay_statements import PayStatements, AsyncPayStatements

__all__ = [
"CompanyResource",
"AsyncCompanyResource",
"Payments",
"AsyncPayments",
"PayStatements",
"AsyncPayStatements",
"Directory",
"AsyncDirectory",
"Individuals",
"AsyncIndividuals",
"Employments",
"AsyncEmployments",
"Payments",
"AsyncPayments",
"PayStatements",
"AsyncPayStatements",
"Benefits",
"AsyncBenefits",
"HRIS",
Expand Down
10 changes: 5 additions & 5 deletions src/finch/resources/hris/benefits/individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
EnrolledIndividual,
UnenrolledIndividual,
IndividualEnrolledIDsResponse,
individual_unenroll_params,
individual_enroll_many_params,
individual_unenroll_many_params,
individual_retrieve_many_benefits_params,
)

Expand Down Expand Up @@ -147,7 +147,7 @@ def retrieve_many_benefits(
model=IndividualBenefit,
)

def unenroll(
def unenroll_many(
self,
benefit_id: str,
*,
Expand Down Expand Up @@ -179,7 +179,7 @@ def unenroll(
f"/employer/benefits/{benefit_id}/individuals",
page=SyncSinglePage[UnenrolledIndividual],
body=maybe_transform(
{"individual_ids": individual_ids}, individual_unenroll_params.IndividualUnenrollParams
{"individual_ids": individual_ids}, individual_unenroll_many_params.IndividualUnenrollManyParams
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
Expand Down Expand Up @@ -314,7 +314,7 @@ def retrieve_many_benefits(
model=IndividualBenefit,
)

def unenroll(
def unenroll_many(
self,
benefit_id: str,
*,
Expand Down Expand Up @@ -346,7 +346,7 @@ def unenroll(
f"/employer/benefits/{benefit_id}/individuals",
page=AsyncSinglePage[UnenrolledIndividual],
body=maybe_transform(
{"individual_ids": individual_ids}, individual_unenroll_params.IndividualUnenrollParams
{"individual_ids": individual_ids}, individual_unenroll_many_params.IndividualUnenrollManyParams
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@

from typing import List

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform
from ...._resource import SyncAPIResource, AsyncAPIResource
from ....pagination import SyncResponsesPage, AsyncResponsesPage
from ...._base_client import AsyncPaginator, make_request_options
from ....types.hris.individuals import (
EmploymentDataResponse,
employment_data_retrieve_many_params,
)
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import maybe_transform
from ..._resource import SyncAPIResource, AsyncAPIResource
from ...pagination import SyncResponsesPage, AsyncResponsesPage
from ...types.hris import EmploymentDataResponse, employment_retrieve_many_params
from ..._base_client import AsyncPaginator, make_request_options

__all__ = ["EmploymentData", "AsyncEmploymentData"]
__all__ = ["Employments", "AsyncEmployments"]


class EmploymentData(SyncAPIResource):
class Employments(SyncAPIResource):
def retrieve_many(
self,
*,
requests: List[employment_data_retrieve_many_params.Request],
requests: List[employment_retrieve_many_params.Request],
# 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,
Expand Down Expand Up @@ -50,9 +47,7 @@ def retrieve_many(
return self._get_api_list(
"/employer/employment",
page=SyncResponsesPage[EmploymentDataResponse],
body=maybe_transform(
{"requests": requests}, employment_data_retrieve_many_params.EmploymentDataRetrieveManyParams
),
body=maybe_transform({"requests": requests}, employment_retrieve_many_params.EmploymentRetrieveManyParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand All @@ -61,11 +56,11 @@ def retrieve_many(
)


class AsyncEmploymentData(AsyncAPIResource):
class AsyncEmployments(AsyncAPIResource):
def retrieve_many(
self,
*,
requests: List[employment_data_retrieve_many_params.Request],
requests: List[employment_retrieve_many_params.Request],
# 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,
Expand Down Expand Up @@ -94,9 +89,7 @@ def retrieve_many(
return self._get_api_list(
"/employer/employment",
page=AsyncResponsesPage[EmploymentDataResponse],
body=maybe_transform(
{"requests": requests}, employment_data_retrieve_many_params.EmploymentDataRetrieveManyParams
),
body=maybe_transform({"requests": requests}, employment_retrieve_many_params.EmploymentRetrieveManyParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down
21 changes: 13 additions & 8 deletions src/finch/resources/hris/hris.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .payments import Payments, AsyncPayments
from .directory import Directory, AsyncDirectory
from ..._resource import SyncAPIResource, AsyncAPIResource
from .employments import Employments, AsyncEmployments
from .individuals import Individuals, AsyncIndividuals
from .pay_statements import PayStatements, AsyncPayStatements

Expand All @@ -20,35 +21,39 @@

class HRIS(SyncAPIResource):
company: CompanyResource
payments: Payments
pay_statements: PayStatements
directory: Directory
individuals: Individuals
employments: Employments
payments: Payments
pay_statements: PayStatements
benefits: Benefits

def __init__(self, client: Finch) -> None:
super().__init__(client)
self.company = CompanyResource(client)
self.payments = Payments(client)
self.pay_statements = PayStatements(client)
self.directory = Directory(client)
self.individuals = Individuals(client)
self.employments = Employments(client)
self.payments = Payments(client)
self.pay_statements = PayStatements(client)
self.benefits = Benefits(client)


class AsyncHRIS(AsyncAPIResource):
company: AsyncCompanyResource
payments: AsyncPayments
pay_statements: AsyncPayStatements
directory: AsyncDirectory
individuals: AsyncIndividuals
employments: AsyncEmployments
payments: AsyncPayments
pay_statements: AsyncPayStatements
benefits: AsyncBenefits

def __init__(self, client: AsyncFinch) -> None:
super().__init__(client)
self.company = AsyncCompanyResource(client)
self.payments = AsyncPayments(client)
self.pay_statements = AsyncPayStatements(client)
self.directory = AsyncDirectory(client)
self.individuals = AsyncIndividuals(client)
self.employments = AsyncEmployments(client)
self.payments = AsyncPayments(client)
self.pay_statements = AsyncPayStatements(client)
self.benefits = AsyncBenefits(client)
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,19 @@

from __future__ import annotations

from typing import TYPE_CHECKING, List, Optional
from typing import List, Optional

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform
from ...._resource import SyncAPIResource, AsyncAPIResource
from ....pagination import SyncResponsesPage, AsyncResponsesPage
from ....types.hris import IndividualResponse, individual_retrieve_many_params
from ...._base_client import AsyncPaginator, make_request_options
from .employment_data import EmploymentData, AsyncEmploymentData

if TYPE_CHECKING:
from ...._client import Finch, AsyncFinch
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import maybe_transform
from ..._resource import SyncAPIResource, AsyncAPIResource
from ...pagination import SyncResponsesPage, AsyncResponsesPage
from ...types.hris import IndividualResponse, individual_retrieve_many_params
from ..._base_client import AsyncPaginator, make_request_options

__all__ = ["Individuals", "AsyncIndividuals"]


class Individuals(SyncAPIResource):
employment_data: EmploymentData

def __init__(self, client: Finch) -> None:
super().__init__(client)
self.employment_data = EmploymentData(client)

def retrieve_many(
self,
*,
Expand Down Expand Up @@ -68,12 +58,6 @@ def retrieve_many(


class AsyncIndividuals(AsyncAPIResource):
employment_data: AsyncEmploymentData

def __init__(self, client: AsyncFinch) -> None:
super().__init__(client)
self.employment_data = AsyncEmploymentData(client)

def retrieve_many(
self,
*,
Expand Down
6 changes: 0 additions & 6 deletions src/finch/resources/hris/individuals/__init__.py

This file was deleted.

5 changes: 5 additions & 0 deletions src/finch/types/hris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .benefit_type import BenefitType as BenefitType
from .pay_statement import PayStatement as PayStatement
from .company_benefit import CompanyBenefit as CompanyBenefit
from .employment_data import EmploymentData as EmploymentData
from .benefit_frequency import BenefitFrequency as BenefitFrequency
from .supported_benefit import SupportedBenefit as SupportedBenefit
from .benfit_contribution import BenfitContribution as BenfitContribution
Expand All @@ -17,9 +18,13 @@
from .benefit_update_params import BenefitUpdateParams as BenefitUpdateParams
from .pay_statement_response import PayStatementResponse as PayStatementResponse
from .individual_in_directory import IndividualInDirectory as IndividualInDirectory
from .employment_data_response import EmploymentDataResponse as EmploymentDataResponse
from .pay_statement_response_body import (
PayStatementResponseBody as PayStatementResponseBody,
)
from .employment_retrieve_many_params import (
EmploymentRetrieveManyParams as EmploymentRetrieveManyParams,
)
from .individual_retrieve_many_params import (
IndividualRetrieveManyParams as IndividualRetrieveManyParams,
)
Expand Down
6 changes: 3 additions & 3 deletions src/finch/types/hris/benefits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from .individual_benefit import IndividualBenefit as IndividualBenefit
from .enrolled_individual import EnrolledIndividual as EnrolledIndividual
from .unenrolled_individual import UnenrolledIndividual as UnenrolledIndividual
from .individual_unenroll_params import (
IndividualUnenrollParams as IndividualUnenrollParams,
)
from .individual_enroll_many_params import (
IndividualEnrollManyParams as IndividualEnrollManyParams,
)
from .individual_unenroll_many_params import (
IndividualUnenrollManyParams as IndividualUnenrollManyParams,
)
from .individual_enrolled_ids_response import (
IndividualEnrolledIDsResponse as IndividualEnrolledIDsResponse,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from typing import List
from typing_extensions import TypedDict

__all__ = ["IndividualUnenrollParams"]
__all__ = ["IndividualUnenrollManyParams"]


class IndividualUnenrollParams(TypedDict, total=False):
class IndividualUnenrollManyParams(TypedDict, total=False):
individual_ids: List[str]
"""Array of individual_ids to unenroll."""
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from pydantic import Field as FieldInfo

from ...income import Income
from ...._models import BaseModel
from ...location import Location
from ..income import Income
from ..._models import BaseModel
from ..location import Location

__all__ = ["EmploymentData", "Department", "Employment", "Manager"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Optional

from ...._models import BaseModel
from ..._models import BaseModel
from .employment_data import EmploymentData

__all__ = ["EmploymentDataResponse"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from typing import List
from typing_extensions import Required, TypedDict

__all__ = ["EmploymentDataRetrieveManyParams", "Request"]
__all__ = ["EmploymentRetrieveManyParams", "Request"]


class EmploymentDataRetrieveManyParams(TypedDict, total=False):
class EmploymentRetrieveManyParams(TypedDict, total=False):
requests: Required[List[Request]]
"""The array of batch requests."""

Expand Down
9 changes: 0 additions & 9 deletions src/finch/types/hris/individuals/__init__.py

This file was deleted.

Loading