Skip to content

Commit

Permalink
chore: lazy load raw resource class properties (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Jan 17, 2024
1 parent 1549d50 commit 1f75530
Show file tree
Hide file tree
Showing 26 changed files with 488 additions and 76 deletions.
8 changes: 8 additions & 0 deletions src/finch/resources/access_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,35 @@ async def create(

class AccessTokensWithRawResponse:
def __init__(self, access_tokens: AccessTokens) -> None:
self._access_tokens = access_tokens

self.create = _legacy_response.to_raw_response_wrapper(
access_tokens.create,
)


class AsyncAccessTokensWithRawResponse:
def __init__(self, access_tokens: AsyncAccessTokens) -> None:
self._access_tokens = access_tokens

self.create = _legacy_response.async_to_raw_response_wrapper(
access_tokens.create,
)


class AccessTokensWithStreamingResponse:
def __init__(self, access_tokens: AccessTokens) -> None:
self._access_tokens = access_tokens

self.create = to_streamed_response_wrapper(
access_tokens.create,
)


class AsyncAccessTokensWithStreamingResponse:
def __init__(self, access_tokens: AsyncAccessTokens) -> None:
self._access_tokens = access_tokens

self.create = async_to_streamed_response_wrapper(
access_tokens.create,
)
8 changes: 8 additions & 0 deletions src/finch/resources/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ async def introspect(

class AccountWithRawResponse:
def __init__(self, account: Account) -> None:
self._account = account

self.disconnect = _legacy_response.to_raw_response_wrapper(
account.disconnect,
)
Expand All @@ -133,6 +135,8 @@ def __init__(self, account: Account) -> None:

class AsyncAccountWithRawResponse:
def __init__(self, account: AsyncAccount) -> None:
self._account = account

self.disconnect = _legacy_response.async_to_raw_response_wrapper(
account.disconnect,
)
Expand All @@ -143,6 +147,8 @@ def __init__(self, account: AsyncAccount) -> None:

class AccountWithStreamingResponse:
def __init__(self, account: Account) -> None:
self._account = account

self.disconnect = to_streamed_response_wrapper(
account.disconnect,
)
Expand All @@ -153,6 +159,8 @@ def __init__(self, account: Account) -> None:

class AsyncAccountWithStreamingResponse:
def __init__(self, account: AsyncAccount) -> None:
self._account = account

self.disconnect = async_to_streamed_response_wrapper(
account.disconnect,
)
Expand Down
24 changes: 20 additions & 4 deletions src/finch/resources/hris/benefits/benefits.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def list_supported_benefits(

class BenefitsWithRawResponse:
def __init__(self, benefits: Benefits) -> None:
self.individuals = IndividualsWithRawResponse(benefits.individuals)
self._benefits = benefits

self.create = _legacy_response.to_raw_response_wrapper(
benefits.create,
Expand All @@ -425,10 +425,14 @@ def __init__(self, benefits: Benefits) -> None:
benefits.list_supported_benefits,
)

@cached_property
def individuals(self) -> IndividualsWithRawResponse:
return IndividualsWithRawResponse(self._benefits.individuals)


class AsyncBenefitsWithRawResponse:
def __init__(self, benefits: AsyncBenefits) -> None:
self.individuals = AsyncIndividualsWithRawResponse(benefits.individuals)
self._benefits = benefits

self.create = _legacy_response.async_to_raw_response_wrapper(
benefits.create,
Expand All @@ -446,10 +450,14 @@ def __init__(self, benefits: AsyncBenefits) -> None:
benefits.list_supported_benefits,
)

@cached_property
def individuals(self) -> AsyncIndividualsWithRawResponse:
return AsyncIndividualsWithRawResponse(self._benefits.individuals)


class BenefitsWithStreamingResponse:
def __init__(self, benefits: Benefits) -> None:
self.individuals = IndividualsWithStreamingResponse(benefits.individuals)
self._benefits = benefits

self.create = to_streamed_response_wrapper(
benefits.create,
Expand All @@ -467,10 +475,14 @@ def __init__(self, benefits: Benefits) -> None:
benefits.list_supported_benefits,
)

@cached_property
def individuals(self) -> IndividualsWithStreamingResponse:
return IndividualsWithStreamingResponse(self._benefits.individuals)


class AsyncBenefitsWithStreamingResponse:
def __init__(self, benefits: AsyncBenefits) -> None:
self.individuals = AsyncIndividualsWithStreamingResponse(benefits.individuals)
self._benefits = benefits

self.create = async_to_streamed_response_wrapper(
benefits.create,
Expand All @@ -487,3 +499,7 @@ def __init__(self, benefits: AsyncBenefits) -> None:
self.list_supported_benefits = async_to_streamed_response_wrapper(
benefits.list_supported_benefits,
)

@cached_property
def individuals(self) -> AsyncIndividualsWithStreamingResponse:
return AsyncIndividualsWithStreamingResponse(self._benefits.individuals)
8 changes: 8 additions & 0 deletions src/finch/resources/hris/benefits/individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ def unenroll_many(

class IndividualsWithRawResponse:
def __init__(self, individuals: Individuals) -> None:
self._individuals = individuals

self.enroll_many = _legacy_response.to_raw_response_wrapper(
individuals.enroll_many,
)
Expand All @@ -414,6 +416,8 @@ def __init__(self, individuals: Individuals) -> None:

class AsyncIndividualsWithRawResponse:
def __init__(self, individuals: AsyncIndividuals) -> None:
self._individuals = individuals

self.enroll_many = _legacy_response.async_to_raw_response_wrapper(
individuals.enroll_many,
)
Expand All @@ -430,6 +434,8 @@ def __init__(self, individuals: AsyncIndividuals) -> None:

class IndividualsWithStreamingResponse:
def __init__(self, individuals: Individuals) -> None:
self._individuals = individuals

self.enroll_many = to_streamed_response_wrapper(
individuals.enroll_many,
)
Expand All @@ -446,6 +452,8 @@ def __init__(self, individuals: Individuals) -> None:

class AsyncIndividualsWithStreamingResponse:
def __init__(self, individuals: AsyncIndividuals) -> None:
self._individuals = individuals

self.enroll_many = async_to_streamed_response_wrapper(
individuals.enroll_many,
)
Expand Down
8 changes: 8 additions & 0 deletions src/finch/resources/hris/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,35 @@ async def retrieve(

class CompanyResourceWithRawResponse:
def __init__(self, company: CompanyResource) -> None:
self._company = company

self.retrieve = _legacy_response.to_raw_response_wrapper(
company.retrieve,
)


class AsyncCompanyResourceWithRawResponse:
def __init__(self, company: AsyncCompanyResource) -> None:
self._company = company

self.retrieve = _legacy_response.async_to_raw_response_wrapper(
company.retrieve,
)


class CompanyResourceWithStreamingResponse:
def __init__(self, company: CompanyResource) -> None:
self._company = company

self.retrieve = to_streamed_response_wrapper(
company.retrieve,
)


class AsyncCompanyResourceWithStreamingResponse:
def __init__(self, company: AsyncCompanyResource) -> None:
self._company = company

self.retrieve = async_to_streamed_response_wrapper(
company.retrieve,
)
8 changes: 8 additions & 0 deletions src/finch/resources/hris/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def list_individuals(

class DirectoryWithRawResponse:
def __init__(self, directory: Directory) -> None:
self._directory = directory

self.list = _legacy_response.to_raw_response_wrapper(
directory.list,
)
Expand All @@ -226,6 +228,8 @@ def __init__(self, directory: Directory) -> None:

class AsyncDirectoryWithRawResponse:
def __init__(self, directory: AsyncDirectory) -> None:
self._directory = directory

self.list = _legacy_response.async_to_raw_response_wrapper(
directory.list,
)
Expand All @@ -238,6 +242,8 @@ def __init__(self, directory: AsyncDirectory) -> None:

class DirectoryWithStreamingResponse:
def __init__(self, directory: Directory) -> None:
self._directory = directory

self.list = to_streamed_response_wrapper(
directory.list,
)
Expand All @@ -250,6 +256,8 @@ def __init__(self, directory: Directory) -> None:

class AsyncDirectoryWithStreamingResponse:
def __init__(self, directory: AsyncDirectory) -> None:
self._directory = directory

self.list = async_to_streamed_response_wrapper(
directory.list,
)
Expand Down
8 changes: 8 additions & 0 deletions src/finch/resources/hris/employments.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,27 +124,35 @@ def retrieve_many(

class EmploymentsWithRawResponse:
def __init__(self, employments: Employments) -> None:
self._employments = employments

self.retrieve_many = _legacy_response.to_raw_response_wrapper(
employments.retrieve_many,
)


class AsyncEmploymentsWithRawResponse:
def __init__(self, employments: AsyncEmployments) -> None:
self._employments = employments

self.retrieve_many = _legacy_response.async_to_raw_response_wrapper(
employments.retrieve_many,
)


class EmploymentsWithStreamingResponse:
def __init__(self, employments: Employments) -> None:
self._employments = employments

self.retrieve_many = to_streamed_response_wrapper(
employments.retrieve_many,
)


class AsyncEmploymentsWithStreamingResponse:
def __init__(self, employments: AsyncEmployments) -> None:
self._employments = employments

self.retrieve_many = async_to_streamed_response_wrapper(
employments.retrieve_many,
)
Loading

0 comments on commit 1f75530

Please sign in to comment.