|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import httpx |
| 6 | + |
| 7 | +from ..types import industry_retrieve_naics_params |
| 8 | +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given |
| 9 | +from .._utils import maybe_transform, async_maybe_transform |
| 10 | +from .._compat import cached_property |
| 11 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 12 | +from .._response import ( |
| 13 | + to_raw_response_wrapper, |
| 14 | + to_streamed_response_wrapper, |
| 15 | + async_to_raw_response_wrapper, |
| 16 | + async_to_streamed_response_wrapper, |
| 17 | +) |
| 18 | +from .._base_client import make_request_options |
| 19 | +from ..types.industry_retrieve_naics_response import IndustryRetrieveNaicsResponse |
| 20 | + |
| 21 | +__all__ = ["IndustryResource", "AsyncIndustryResource"] |
| 22 | + |
| 23 | + |
| 24 | +class IndustryResource(SyncAPIResource): |
| 25 | + @cached_property |
| 26 | + def with_raw_response(self) -> IndustryResourceWithRawResponse: |
| 27 | + """ |
| 28 | + This property can be used as a prefix for any HTTP method call to return |
| 29 | + the raw response object instead of the parsed content. |
| 30 | +
|
| 31 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers |
| 32 | + """ |
| 33 | + return IndustryResourceWithRawResponse(self) |
| 34 | + |
| 35 | + @cached_property |
| 36 | + def with_streaming_response(self) -> IndustryResourceWithStreamingResponse: |
| 37 | + """ |
| 38 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 39 | +
|
| 40 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#with_streaming_response |
| 41 | + """ |
| 42 | + return IndustryResourceWithStreamingResponse(self) |
| 43 | + |
| 44 | + def retrieve_naics( |
| 45 | + self, |
| 46 | + *, |
| 47 | + input: str, |
| 48 | + max_results: int | Omit = omit, |
| 49 | + min_results: int | Omit = omit, |
| 50 | + timeout_ms: int | Omit = omit, |
| 51 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 52 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 53 | + extra_headers: Headers | None = None, |
| 54 | + extra_query: Query | None = None, |
| 55 | + extra_body: Body | None = None, |
| 56 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 57 | + ) -> IndustryRetrieveNaicsResponse: |
| 58 | + """ |
| 59 | + Classify any brand into 2022 NAICS industry codes from its domain or name. |
| 60 | +
|
| 61 | + Args: |
| 62 | + input: Brand domain or title to retrieve NAICS code for. If a valid domain is provided, |
| 63 | + it will be used for classification, otherwise, we will search for the brand |
| 64 | + using the provided title. |
| 65 | +
|
| 66 | + max_results: Maximum number of NAICS codes to return. Must be between 1 and 10. Defaults |
| 67 | + to 5. |
| 68 | +
|
| 69 | + min_results: Minimum number of NAICS codes to return. Must be at least 1. Defaults to 1. |
| 70 | +
|
| 71 | + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer |
| 72 | + than this value, it will be aborted with a 408 status code. Maximum allowed |
| 73 | + value is 300000ms (5 minutes). |
| 74 | +
|
| 75 | + extra_headers: Send extra headers |
| 76 | +
|
| 77 | + extra_query: Add additional query parameters to the request |
| 78 | +
|
| 79 | + extra_body: Add additional JSON properties to the request |
| 80 | +
|
| 81 | + timeout: Override the client-level default timeout for this request, in seconds |
| 82 | + """ |
| 83 | + return self._get( |
| 84 | + "/web/naics", |
| 85 | + options=make_request_options( |
| 86 | + extra_headers=extra_headers, |
| 87 | + extra_query=extra_query, |
| 88 | + extra_body=extra_body, |
| 89 | + timeout=timeout, |
| 90 | + query=maybe_transform( |
| 91 | + { |
| 92 | + "input": input, |
| 93 | + "max_results": max_results, |
| 94 | + "min_results": min_results, |
| 95 | + "timeout_ms": timeout_ms, |
| 96 | + }, |
| 97 | + industry_retrieve_naics_params.IndustryRetrieveNaicsParams, |
| 98 | + ), |
| 99 | + ), |
| 100 | + cast_to=IndustryRetrieveNaicsResponse, |
| 101 | + ) |
| 102 | + |
| 103 | + |
| 104 | +class AsyncIndustryResource(AsyncAPIResource): |
| 105 | + @cached_property |
| 106 | + def with_raw_response(self) -> AsyncIndustryResourceWithRawResponse: |
| 107 | + """ |
| 108 | + This property can be used as a prefix for any HTTP method call to return |
| 109 | + the raw response object instead of the parsed content. |
| 110 | +
|
| 111 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers |
| 112 | + """ |
| 113 | + return AsyncIndustryResourceWithRawResponse(self) |
| 114 | + |
| 115 | + @cached_property |
| 116 | + def with_streaming_response(self) -> AsyncIndustryResourceWithStreamingResponse: |
| 117 | + """ |
| 118 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 119 | +
|
| 120 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#with_streaming_response |
| 121 | + """ |
| 122 | + return AsyncIndustryResourceWithStreamingResponse(self) |
| 123 | + |
| 124 | + async def retrieve_naics( |
| 125 | + self, |
| 126 | + *, |
| 127 | + input: str, |
| 128 | + max_results: int | Omit = omit, |
| 129 | + min_results: int | Omit = omit, |
| 130 | + timeout_ms: int | Omit = omit, |
| 131 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 132 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 133 | + extra_headers: Headers | None = None, |
| 134 | + extra_query: Query | None = None, |
| 135 | + extra_body: Body | None = None, |
| 136 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 137 | + ) -> IndustryRetrieveNaicsResponse: |
| 138 | + """ |
| 139 | + Classify any brand into 2022 NAICS industry codes from its domain or name. |
| 140 | +
|
| 141 | + Args: |
| 142 | + input: Brand domain or title to retrieve NAICS code for. If a valid domain is provided, |
| 143 | + it will be used for classification, otherwise, we will search for the brand |
| 144 | + using the provided title. |
| 145 | +
|
| 146 | + max_results: Maximum number of NAICS codes to return. Must be between 1 and 10. Defaults |
| 147 | + to 5. |
| 148 | +
|
| 149 | + min_results: Minimum number of NAICS codes to return. Must be at least 1. Defaults to 1. |
| 150 | +
|
| 151 | + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer |
| 152 | + than this value, it will be aborted with a 408 status code. Maximum allowed |
| 153 | + value is 300000ms (5 minutes). |
| 154 | +
|
| 155 | + extra_headers: Send extra headers |
| 156 | +
|
| 157 | + extra_query: Add additional query parameters to the request |
| 158 | +
|
| 159 | + extra_body: Add additional JSON properties to the request |
| 160 | +
|
| 161 | + timeout: Override the client-level default timeout for this request, in seconds |
| 162 | + """ |
| 163 | + return await self._get( |
| 164 | + "/web/naics", |
| 165 | + options=make_request_options( |
| 166 | + extra_headers=extra_headers, |
| 167 | + extra_query=extra_query, |
| 168 | + extra_body=extra_body, |
| 169 | + timeout=timeout, |
| 170 | + query=await async_maybe_transform( |
| 171 | + { |
| 172 | + "input": input, |
| 173 | + "max_results": max_results, |
| 174 | + "min_results": min_results, |
| 175 | + "timeout_ms": timeout_ms, |
| 176 | + }, |
| 177 | + industry_retrieve_naics_params.IndustryRetrieveNaicsParams, |
| 178 | + ), |
| 179 | + ), |
| 180 | + cast_to=IndustryRetrieveNaicsResponse, |
| 181 | + ) |
| 182 | + |
| 183 | + |
| 184 | +class IndustryResourceWithRawResponse: |
| 185 | + def __init__(self, industry: IndustryResource) -> None: |
| 186 | + self._industry = industry |
| 187 | + |
| 188 | + self.retrieve_naics = to_raw_response_wrapper( |
| 189 | + industry.retrieve_naics, |
| 190 | + ) |
| 191 | + |
| 192 | + |
| 193 | +class AsyncIndustryResourceWithRawResponse: |
| 194 | + def __init__(self, industry: AsyncIndustryResource) -> None: |
| 195 | + self._industry = industry |
| 196 | + |
| 197 | + self.retrieve_naics = async_to_raw_response_wrapper( |
| 198 | + industry.retrieve_naics, |
| 199 | + ) |
| 200 | + |
| 201 | + |
| 202 | +class IndustryResourceWithStreamingResponse: |
| 203 | + def __init__(self, industry: IndustryResource) -> None: |
| 204 | + self._industry = industry |
| 205 | + |
| 206 | + self.retrieve_naics = to_streamed_response_wrapper( |
| 207 | + industry.retrieve_naics, |
| 208 | + ) |
| 209 | + |
| 210 | + |
| 211 | +class AsyncIndustryResourceWithStreamingResponse: |
| 212 | + def __init__(self, industry: AsyncIndustryResource) -> None: |
| 213 | + self._industry = industry |
| 214 | + |
| 215 | + self.retrieve_naics = async_to_streamed_response_wrapper( |
| 216 | + industry.retrieve_naics, |
| 217 | + ) |
0 commit comments