|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import List |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ... import _legacy_response |
| 10 | +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 11 | +from ..._utils import maybe_transform |
| 12 | +from ..._compat import cached_property |
| 13 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 14 | +from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper |
| 15 | +from ...pagination import SyncSinglePage, AsyncSinglePage |
| 16 | +from ..._base_client import ( |
| 17 | + AsyncPaginator, |
| 18 | + make_request_options, |
| 19 | +) |
| 20 | +from ...types.payroll import pay_group_list_params |
| 21 | +from ...types.payroll.pay_group_list_response import PayGroupListResponse |
| 22 | +from ...types.payroll.pay_group_retrieve_response import PayGroupRetrieveResponse |
| 23 | + |
| 24 | +__all__ = ["PayGroups", "AsyncPayGroups"] |
| 25 | + |
| 26 | + |
| 27 | +class PayGroups(SyncAPIResource): |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> PayGroupsWithRawResponse: |
| 30 | + return PayGroupsWithRawResponse(self) |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def with_streaming_response(self) -> PayGroupsWithStreamingResponse: |
| 34 | + return PayGroupsWithStreamingResponse(self) |
| 35 | + |
| 36 | + def retrieve( |
| 37 | + self, |
| 38 | + pay_group_id: str, |
| 39 | + *, |
| 40 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 41 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 42 | + extra_headers: Headers | None = None, |
| 43 | + extra_query: Query | None = None, |
| 44 | + extra_body: Body | None = None, |
| 45 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 46 | + ) -> PayGroupRetrieveResponse: |
| 47 | + """ |
| 48 | + Read information from a single pay group |
| 49 | +
|
| 50 | + Args: |
| 51 | + extra_headers: Send extra headers |
| 52 | +
|
| 53 | + extra_query: Add additional query parameters to the request |
| 54 | +
|
| 55 | + extra_body: Add additional JSON properties to the request |
| 56 | +
|
| 57 | + timeout: Override the client-level default timeout for this request, in seconds |
| 58 | + """ |
| 59 | + if not pay_group_id: |
| 60 | + raise ValueError(f"Expected a non-empty value for `pay_group_id` but received {pay_group_id!r}") |
| 61 | + return self._get( |
| 62 | + f"/employer/pay-group/{pay_group_id}", |
| 63 | + options=make_request_options( |
| 64 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 65 | + ), |
| 66 | + cast_to=PayGroupRetrieveResponse, |
| 67 | + ) |
| 68 | + |
| 69 | + def list( |
| 70 | + self, |
| 71 | + *, |
| 72 | + individual_id: str | NotGiven = NOT_GIVEN, |
| 73 | + pay_frequencies: List[str] | NotGiven = NOT_GIVEN, |
| 74 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 75 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 76 | + extra_headers: Headers | None = None, |
| 77 | + extra_query: Query | None = None, |
| 78 | + extra_body: Body | None = None, |
| 79 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 80 | + ) -> SyncSinglePage[PayGroupListResponse]: |
| 81 | + """ |
| 82 | + Read company pay groups and frequencies |
| 83 | +
|
| 84 | + Args: |
| 85 | + extra_headers: Send extra headers |
| 86 | +
|
| 87 | + extra_query: Add additional query parameters to the request |
| 88 | +
|
| 89 | + extra_body: Add additional JSON properties to the request |
| 90 | +
|
| 91 | + timeout: Override the client-level default timeout for this request, in seconds |
| 92 | + """ |
| 93 | + return self._get_api_list( |
| 94 | + "/employer/pay-groups", |
| 95 | + page=SyncSinglePage[PayGroupListResponse], |
| 96 | + options=make_request_options( |
| 97 | + extra_headers=extra_headers, |
| 98 | + extra_query=extra_query, |
| 99 | + extra_body=extra_body, |
| 100 | + timeout=timeout, |
| 101 | + query=maybe_transform( |
| 102 | + { |
| 103 | + "individual_id": individual_id, |
| 104 | + "pay_frequencies": pay_frequencies, |
| 105 | + }, |
| 106 | + pay_group_list_params.PayGroupListParams, |
| 107 | + ), |
| 108 | + ), |
| 109 | + model=PayGroupListResponse, |
| 110 | + ) |
| 111 | + |
| 112 | + |
| 113 | +class AsyncPayGroups(AsyncAPIResource): |
| 114 | + @cached_property |
| 115 | + def with_raw_response(self) -> AsyncPayGroupsWithRawResponse: |
| 116 | + return AsyncPayGroupsWithRawResponse(self) |
| 117 | + |
| 118 | + @cached_property |
| 119 | + def with_streaming_response(self) -> AsyncPayGroupsWithStreamingResponse: |
| 120 | + return AsyncPayGroupsWithStreamingResponse(self) |
| 121 | + |
| 122 | + async def retrieve( |
| 123 | + self, |
| 124 | + pay_group_id: str, |
| 125 | + *, |
| 126 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 127 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 128 | + extra_headers: Headers | None = None, |
| 129 | + extra_query: Query | None = None, |
| 130 | + extra_body: Body | None = None, |
| 131 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 132 | + ) -> PayGroupRetrieveResponse: |
| 133 | + """ |
| 134 | + Read information from a single pay group |
| 135 | +
|
| 136 | + Args: |
| 137 | + extra_headers: Send extra headers |
| 138 | +
|
| 139 | + extra_query: Add additional query parameters to the request |
| 140 | +
|
| 141 | + extra_body: Add additional JSON properties to the request |
| 142 | +
|
| 143 | + timeout: Override the client-level default timeout for this request, in seconds |
| 144 | + """ |
| 145 | + if not pay_group_id: |
| 146 | + raise ValueError(f"Expected a non-empty value for `pay_group_id` but received {pay_group_id!r}") |
| 147 | + return await self._get( |
| 148 | + f"/employer/pay-group/{pay_group_id}", |
| 149 | + options=make_request_options( |
| 150 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 151 | + ), |
| 152 | + cast_to=PayGroupRetrieveResponse, |
| 153 | + ) |
| 154 | + |
| 155 | + def list( |
| 156 | + self, |
| 157 | + *, |
| 158 | + individual_id: str | NotGiven = NOT_GIVEN, |
| 159 | + pay_frequencies: List[str] | NotGiven = NOT_GIVEN, |
| 160 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 161 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 162 | + extra_headers: Headers | None = None, |
| 163 | + extra_query: Query | None = None, |
| 164 | + extra_body: Body | None = None, |
| 165 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 166 | + ) -> AsyncPaginator[PayGroupListResponse, AsyncSinglePage[PayGroupListResponse]]: |
| 167 | + """ |
| 168 | + Read company pay groups and frequencies |
| 169 | +
|
| 170 | + Args: |
| 171 | + extra_headers: Send extra headers |
| 172 | +
|
| 173 | + extra_query: Add additional query parameters to the request |
| 174 | +
|
| 175 | + extra_body: Add additional JSON properties to the request |
| 176 | +
|
| 177 | + timeout: Override the client-level default timeout for this request, in seconds |
| 178 | + """ |
| 179 | + return self._get_api_list( |
| 180 | + "/employer/pay-groups", |
| 181 | + page=AsyncSinglePage[PayGroupListResponse], |
| 182 | + options=make_request_options( |
| 183 | + extra_headers=extra_headers, |
| 184 | + extra_query=extra_query, |
| 185 | + extra_body=extra_body, |
| 186 | + timeout=timeout, |
| 187 | + query=maybe_transform( |
| 188 | + { |
| 189 | + "individual_id": individual_id, |
| 190 | + "pay_frequencies": pay_frequencies, |
| 191 | + }, |
| 192 | + pay_group_list_params.PayGroupListParams, |
| 193 | + ), |
| 194 | + ), |
| 195 | + model=PayGroupListResponse, |
| 196 | + ) |
| 197 | + |
| 198 | + |
| 199 | +class PayGroupsWithRawResponse: |
| 200 | + def __init__(self, pay_groups: PayGroups) -> None: |
| 201 | + self._pay_groups = pay_groups |
| 202 | + |
| 203 | + self.retrieve = _legacy_response.to_raw_response_wrapper( |
| 204 | + pay_groups.retrieve, |
| 205 | + ) |
| 206 | + self.list = _legacy_response.to_raw_response_wrapper( |
| 207 | + pay_groups.list, |
| 208 | + ) |
| 209 | + |
| 210 | + |
| 211 | +class AsyncPayGroupsWithRawResponse: |
| 212 | + def __init__(self, pay_groups: AsyncPayGroups) -> None: |
| 213 | + self._pay_groups = pay_groups |
| 214 | + |
| 215 | + self.retrieve = _legacy_response.async_to_raw_response_wrapper( |
| 216 | + pay_groups.retrieve, |
| 217 | + ) |
| 218 | + self.list = _legacy_response.async_to_raw_response_wrapper( |
| 219 | + pay_groups.list, |
| 220 | + ) |
| 221 | + |
| 222 | + |
| 223 | +class PayGroupsWithStreamingResponse: |
| 224 | + def __init__(self, pay_groups: PayGroups) -> None: |
| 225 | + self._pay_groups = pay_groups |
| 226 | + |
| 227 | + self.retrieve = to_streamed_response_wrapper( |
| 228 | + pay_groups.retrieve, |
| 229 | + ) |
| 230 | + self.list = to_streamed_response_wrapper( |
| 231 | + pay_groups.list, |
| 232 | + ) |
| 233 | + |
| 234 | + |
| 235 | +class AsyncPayGroupsWithStreamingResponse: |
| 236 | + def __init__(self, pay_groups: AsyncPayGroups) -> None: |
| 237 | + self._pay_groups = pay_groups |
| 238 | + |
| 239 | + self.retrieve = async_to_streamed_response_wrapper( |
| 240 | + pay_groups.retrieve, |
| 241 | + ) |
| 242 | + self.list = async_to_streamed_response_wrapper( |
| 243 | + pay_groups.list, |
| 244 | + ) |
0 commit comments