|
| 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 Any, List, cast |
| 6 | +from typing_extensions import Literal |
| 7 | + |
| 8 | +import httpx |
| 9 | + |
| 10 | +from ... import _legacy_response |
| 11 | +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 12 | +from ..._utils import ( |
| 13 | + maybe_transform, |
| 14 | + async_maybe_transform, |
| 15 | +) |
| 16 | +from ..._compat import cached_property |
| 17 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 18 | +from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper |
| 19 | +from ...types.hris import document_list_params |
| 20 | +from ..._base_client import make_request_options |
| 21 | +from ...types.hris.document_list_response import DocumentListResponse |
| 22 | +from ...types.hris.document_retreive_response import DocumentRetreiveResponse |
| 23 | + |
| 24 | +__all__ = ["Documents", "AsyncDocuments"] |
| 25 | + |
| 26 | + |
| 27 | +class Documents(SyncAPIResource): |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> DocumentsWithRawResponse: |
| 30 | + """ |
| 31 | + This property can be used as a prefix for any HTTP method call to return the |
| 32 | + the raw response object instead of the parsed content. |
| 33 | +
|
| 34 | + For more information, see https://www.github.com/Finch-API/finch-api-python#accessing-raw-response-data-eg-headers |
| 35 | + """ |
| 36 | + return DocumentsWithRawResponse(self) |
| 37 | + |
| 38 | + @cached_property |
| 39 | + def with_streaming_response(self) -> DocumentsWithStreamingResponse: |
| 40 | + """ |
| 41 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 42 | +
|
| 43 | + For more information, see https://www.github.com/Finch-API/finch-api-python#with_streaming_response |
| 44 | + """ |
| 45 | + return DocumentsWithStreamingResponse(self) |
| 46 | + |
| 47 | + def list( |
| 48 | + self, |
| 49 | + *, |
| 50 | + individual_ids: List[str] | NotGiven = NOT_GIVEN, |
| 51 | + limit: int | NotGiven = NOT_GIVEN, |
| 52 | + offset: int | NotGiven = NOT_GIVEN, |
| 53 | + types: List[Literal["w4_2020", "w4_2005"]] | NotGiven = NOT_GIVEN, |
| 54 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 55 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 56 | + extra_headers: Headers | None = None, |
| 57 | + extra_query: Query | None = None, |
| 58 | + extra_body: Body | None = None, |
| 59 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 60 | + ) -> DocumentListResponse: |
| 61 | + """**Beta:** This endpoint is in beta and may change. |
| 62 | +
|
| 63 | +
|
| 64 | + Retrieve a list of company-wide documents. |
| 65 | +
|
| 66 | + Args: |
| 67 | + individual_ids: Comma-delimited list of stable Finch uuids for each individual. If empty, |
| 68 | + defaults to all individuals |
| 69 | +
|
| 70 | + limit: Number of documents to return (defaults to all) |
| 71 | +
|
| 72 | + offset: Index to start from (defaults to 0) |
| 73 | +
|
| 74 | + types: Comma-delimited list of document types to filter on. If empty, defaults to all |
| 75 | + types |
| 76 | +
|
| 77 | + extra_headers: Send extra headers |
| 78 | +
|
| 79 | + extra_query: Add additional query parameters to the request |
| 80 | +
|
| 81 | + extra_body: Add additional JSON properties to the request |
| 82 | +
|
| 83 | + timeout: Override the client-level default timeout for this request, in seconds |
| 84 | + """ |
| 85 | + return self._get( |
| 86 | + "/employer/documents", |
| 87 | + options=make_request_options( |
| 88 | + extra_headers=extra_headers, |
| 89 | + extra_query=extra_query, |
| 90 | + extra_body=extra_body, |
| 91 | + timeout=timeout, |
| 92 | + query=maybe_transform( |
| 93 | + { |
| 94 | + "individual_ids": individual_ids, |
| 95 | + "limit": limit, |
| 96 | + "offset": offset, |
| 97 | + "types": types, |
| 98 | + }, |
| 99 | + document_list_params.DocumentListParams, |
| 100 | + ), |
| 101 | + ), |
| 102 | + cast_to=DocumentListResponse, |
| 103 | + ) |
| 104 | + |
| 105 | + def retreive( |
| 106 | + self, |
| 107 | + document_id: str, |
| 108 | + *, |
| 109 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 110 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 111 | + extra_headers: Headers | None = None, |
| 112 | + extra_query: Query | None = None, |
| 113 | + extra_body: Body | None = None, |
| 114 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 115 | + ) -> DocumentRetreiveResponse: |
| 116 | + """**Beta:** This endpoint is in beta and may change. |
| 117 | +
|
| 118 | +
|
| 119 | + Retrieve details of a specific document by its ID. |
| 120 | +
|
| 121 | + Args: |
| 122 | + extra_headers: Send extra headers |
| 123 | +
|
| 124 | + extra_query: Add additional query parameters to the request |
| 125 | +
|
| 126 | + extra_body: Add additional JSON properties to the request |
| 127 | +
|
| 128 | + timeout: Override the client-level default timeout for this request, in seconds |
| 129 | + """ |
| 130 | + if not document_id: |
| 131 | + raise ValueError(f"Expected a non-empty value for `document_id` but received {document_id!r}") |
| 132 | + return cast( |
| 133 | + DocumentRetreiveResponse, |
| 134 | + self._get( |
| 135 | + f"/employer/documents/{document_id}", |
| 136 | + options=make_request_options( |
| 137 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 138 | + ), |
| 139 | + cast_to=cast( |
| 140 | + Any, DocumentRetreiveResponse |
| 141 | + ), # Union types cannot be passed in as arguments in the type system |
| 142 | + ), |
| 143 | + ) |
| 144 | + |
| 145 | + |
| 146 | +class AsyncDocuments(AsyncAPIResource): |
| 147 | + @cached_property |
| 148 | + def with_raw_response(self) -> AsyncDocumentsWithRawResponse: |
| 149 | + """ |
| 150 | + This property can be used as a prefix for any HTTP method call to return the |
| 151 | + the raw response object instead of the parsed content. |
| 152 | +
|
| 153 | + For more information, see https://www.github.com/Finch-API/finch-api-python#accessing-raw-response-data-eg-headers |
| 154 | + """ |
| 155 | + return AsyncDocumentsWithRawResponse(self) |
| 156 | + |
| 157 | + @cached_property |
| 158 | + def with_streaming_response(self) -> AsyncDocumentsWithStreamingResponse: |
| 159 | + """ |
| 160 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 161 | +
|
| 162 | + For more information, see https://www.github.com/Finch-API/finch-api-python#with_streaming_response |
| 163 | + """ |
| 164 | + return AsyncDocumentsWithStreamingResponse(self) |
| 165 | + |
| 166 | + async def list( |
| 167 | + self, |
| 168 | + *, |
| 169 | + individual_ids: List[str] | NotGiven = NOT_GIVEN, |
| 170 | + limit: int | NotGiven = NOT_GIVEN, |
| 171 | + offset: int | NotGiven = NOT_GIVEN, |
| 172 | + types: List[Literal["w4_2020", "w4_2005"]] | NotGiven = NOT_GIVEN, |
| 173 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 174 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 175 | + extra_headers: Headers | None = None, |
| 176 | + extra_query: Query | None = None, |
| 177 | + extra_body: Body | None = None, |
| 178 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 179 | + ) -> DocumentListResponse: |
| 180 | + """**Beta:** This endpoint is in beta and may change. |
| 181 | +
|
| 182 | +
|
| 183 | + Retrieve a list of company-wide documents. |
| 184 | +
|
| 185 | + Args: |
| 186 | + individual_ids: Comma-delimited list of stable Finch uuids for each individual. If empty, |
| 187 | + defaults to all individuals |
| 188 | +
|
| 189 | + limit: Number of documents to return (defaults to all) |
| 190 | +
|
| 191 | + offset: Index to start from (defaults to 0) |
| 192 | +
|
| 193 | + types: Comma-delimited list of document types to filter on. If empty, defaults to all |
| 194 | + types |
| 195 | +
|
| 196 | + extra_headers: Send extra headers |
| 197 | +
|
| 198 | + extra_query: Add additional query parameters to the request |
| 199 | +
|
| 200 | + extra_body: Add additional JSON properties to the request |
| 201 | +
|
| 202 | + timeout: Override the client-level default timeout for this request, in seconds |
| 203 | + """ |
| 204 | + return await self._get( |
| 205 | + "/employer/documents", |
| 206 | + options=make_request_options( |
| 207 | + extra_headers=extra_headers, |
| 208 | + extra_query=extra_query, |
| 209 | + extra_body=extra_body, |
| 210 | + timeout=timeout, |
| 211 | + query=await async_maybe_transform( |
| 212 | + { |
| 213 | + "individual_ids": individual_ids, |
| 214 | + "limit": limit, |
| 215 | + "offset": offset, |
| 216 | + "types": types, |
| 217 | + }, |
| 218 | + document_list_params.DocumentListParams, |
| 219 | + ), |
| 220 | + ), |
| 221 | + cast_to=DocumentListResponse, |
| 222 | + ) |
| 223 | + |
| 224 | + async def retreive( |
| 225 | + self, |
| 226 | + document_id: str, |
| 227 | + *, |
| 228 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 229 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 230 | + extra_headers: Headers | None = None, |
| 231 | + extra_query: Query | None = None, |
| 232 | + extra_body: Body | None = None, |
| 233 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 234 | + ) -> DocumentRetreiveResponse: |
| 235 | + """**Beta:** This endpoint is in beta and may change. |
| 236 | +
|
| 237 | +
|
| 238 | + Retrieve details of a specific document by its ID. |
| 239 | +
|
| 240 | + Args: |
| 241 | + extra_headers: Send extra headers |
| 242 | +
|
| 243 | + extra_query: Add additional query parameters to the request |
| 244 | +
|
| 245 | + extra_body: Add additional JSON properties to the request |
| 246 | +
|
| 247 | + timeout: Override the client-level default timeout for this request, in seconds |
| 248 | + """ |
| 249 | + if not document_id: |
| 250 | + raise ValueError(f"Expected a non-empty value for `document_id` but received {document_id!r}") |
| 251 | + return cast( |
| 252 | + DocumentRetreiveResponse, |
| 253 | + await self._get( |
| 254 | + f"/employer/documents/{document_id}", |
| 255 | + options=make_request_options( |
| 256 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 257 | + ), |
| 258 | + cast_to=cast( |
| 259 | + Any, DocumentRetreiveResponse |
| 260 | + ), # Union types cannot be passed in as arguments in the type system |
| 261 | + ), |
| 262 | + ) |
| 263 | + |
| 264 | + |
| 265 | +class DocumentsWithRawResponse: |
| 266 | + def __init__(self, documents: Documents) -> None: |
| 267 | + self._documents = documents |
| 268 | + |
| 269 | + self.list = _legacy_response.to_raw_response_wrapper( |
| 270 | + documents.list, |
| 271 | + ) |
| 272 | + self.retreive = _legacy_response.to_raw_response_wrapper( |
| 273 | + documents.retreive, |
| 274 | + ) |
| 275 | + |
| 276 | + |
| 277 | +class AsyncDocumentsWithRawResponse: |
| 278 | + def __init__(self, documents: AsyncDocuments) -> None: |
| 279 | + self._documents = documents |
| 280 | + |
| 281 | + self.list = _legacy_response.async_to_raw_response_wrapper( |
| 282 | + documents.list, |
| 283 | + ) |
| 284 | + self.retreive = _legacy_response.async_to_raw_response_wrapper( |
| 285 | + documents.retreive, |
| 286 | + ) |
| 287 | + |
| 288 | + |
| 289 | +class DocumentsWithStreamingResponse: |
| 290 | + def __init__(self, documents: Documents) -> None: |
| 291 | + self._documents = documents |
| 292 | + |
| 293 | + self.list = to_streamed_response_wrapper( |
| 294 | + documents.list, |
| 295 | + ) |
| 296 | + self.retreive = to_streamed_response_wrapper( |
| 297 | + documents.retreive, |
| 298 | + ) |
| 299 | + |
| 300 | + |
| 301 | +class AsyncDocumentsWithStreamingResponse: |
| 302 | + def __init__(self, documents: AsyncDocuments) -> None: |
| 303 | + self._documents = documents |
| 304 | + |
| 305 | + self.list = async_to_streamed_response_wrapper( |
| 306 | + documents.list, |
| 307 | + ) |
| 308 | + self.retreive = async_to_streamed_response_wrapper( |
| 309 | + documents.retreive, |
| 310 | + ) |
0 commit comments