|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing_extensions import Literal |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 10 | +from ....._utils import maybe_transform, async_maybe_transform |
| 11 | +from ....._compat import cached_property |
| 12 | +from ....._resource import SyncAPIResource, AsyncAPIResource |
| 13 | +from ....._response import ( |
| 14 | + to_raw_response_wrapper, |
| 15 | + to_streamed_response_wrapper, |
| 16 | + async_to_raw_response_wrapper, |
| 17 | + async_to_streamed_response_wrapper, |
| 18 | +) |
| 19 | +from ....._base_client import make_request_options |
| 20 | +from .....types.onchain.networks.tokens import holders_chart_get_params |
| 21 | +from .....types.onchain.networks.tokens.holders_chart_get_response import HoldersChartGetResponse |
| 22 | + |
| 23 | +__all__ = ["HoldersChartResource", "AsyncHoldersChartResource"] |
| 24 | + |
| 25 | + |
| 26 | +class HoldersChartResource(SyncAPIResource): |
| 27 | + @cached_property |
| 28 | + def with_raw_response(self) -> HoldersChartResourceWithRawResponse: |
| 29 | + """ |
| 30 | + This property can be used as a prefix for any HTTP method call to return |
| 31 | + the raw response object instead of the parsed content. |
| 32 | +
|
| 33 | + For more information, see https://www.github.com/coingecko/coingecko-python#accessing-raw-response-data-eg-headers |
| 34 | + """ |
| 35 | + return HoldersChartResourceWithRawResponse(self) |
| 36 | + |
| 37 | + @cached_property |
| 38 | + def with_streaming_response(self) -> HoldersChartResourceWithStreamingResponse: |
| 39 | + """ |
| 40 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 41 | +
|
| 42 | + For more information, see https://www.github.com/coingecko/coingecko-python#with_streaming_response |
| 43 | + """ |
| 44 | + return HoldersChartResourceWithStreamingResponse(self) |
| 45 | + |
| 46 | + def get( |
| 47 | + self, |
| 48 | + token_address: str, |
| 49 | + *, |
| 50 | + network: str, |
| 51 | + days: Literal["7", "30", "max"] | NotGiven = NOT_GIVEN, |
| 52 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 53 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 54 | + extra_headers: Headers | None = None, |
| 55 | + extra_query: Query | None = None, |
| 56 | + extra_body: Body | None = None, |
| 57 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 58 | + ) -> HoldersChartGetResponse: |
| 59 | + """ |
| 60 | + This endpoint allows you to **get the historical token holders chart based on |
| 61 | + the provided token contract address on a network** |
| 62 | +
|
| 63 | + Args: |
| 64 | + days: number of days to return the historical token holders chart Default value: 7 |
| 65 | +
|
| 66 | + extra_headers: Send extra headers |
| 67 | +
|
| 68 | + extra_query: Add additional query parameters to the request |
| 69 | +
|
| 70 | + extra_body: Add additional JSON properties to the request |
| 71 | +
|
| 72 | + timeout: Override the client-level default timeout for this request, in seconds |
| 73 | + """ |
| 74 | + if not network: |
| 75 | + raise ValueError(f"Expected a non-empty value for `network` but received {network!r}") |
| 76 | + if not token_address: |
| 77 | + raise ValueError(f"Expected a non-empty value for `token_address` but received {token_address!r}") |
| 78 | + return self._get( |
| 79 | + f"/onchain/networks/{network}/tokens/{token_address}/holders_chart", |
| 80 | + options=make_request_options( |
| 81 | + extra_headers=extra_headers, |
| 82 | + extra_query=extra_query, |
| 83 | + extra_body=extra_body, |
| 84 | + timeout=timeout, |
| 85 | + query=maybe_transform({"days": days}, holders_chart_get_params.HoldersChartGetParams), |
| 86 | + ), |
| 87 | + cast_to=HoldersChartGetResponse, |
| 88 | + ) |
| 89 | + |
| 90 | + |
| 91 | +class AsyncHoldersChartResource(AsyncAPIResource): |
| 92 | + @cached_property |
| 93 | + def with_raw_response(self) -> AsyncHoldersChartResourceWithRawResponse: |
| 94 | + """ |
| 95 | + This property can be used as a prefix for any HTTP method call to return |
| 96 | + the raw response object instead of the parsed content. |
| 97 | +
|
| 98 | + For more information, see https://www.github.com/coingecko/coingecko-python#accessing-raw-response-data-eg-headers |
| 99 | + """ |
| 100 | + return AsyncHoldersChartResourceWithRawResponse(self) |
| 101 | + |
| 102 | + @cached_property |
| 103 | + def with_streaming_response(self) -> AsyncHoldersChartResourceWithStreamingResponse: |
| 104 | + """ |
| 105 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 106 | +
|
| 107 | + For more information, see https://www.github.com/coingecko/coingecko-python#with_streaming_response |
| 108 | + """ |
| 109 | + return AsyncHoldersChartResourceWithStreamingResponse(self) |
| 110 | + |
| 111 | + async def get( |
| 112 | + self, |
| 113 | + token_address: str, |
| 114 | + *, |
| 115 | + network: str, |
| 116 | + days: Literal["7", "30", "max"] | NotGiven = NOT_GIVEN, |
| 117 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 118 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 119 | + extra_headers: Headers | None = None, |
| 120 | + extra_query: Query | None = None, |
| 121 | + extra_body: Body | None = None, |
| 122 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 123 | + ) -> HoldersChartGetResponse: |
| 124 | + """ |
| 125 | + This endpoint allows you to **get the historical token holders chart based on |
| 126 | + the provided token contract address on a network** |
| 127 | +
|
| 128 | + Args: |
| 129 | + days: number of days to return the historical token holders chart Default value: 7 |
| 130 | +
|
| 131 | + extra_headers: Send extra headers |
| 132 | +
|
| 133 | + extra_query: Add additional query parameters to the request |
| 134 | +
|
| 135 | + extra_body: Add additional JSON properties to the request |
| 136 | +
|
| 137 | + timeout: Override the client-level default timeout for this request, in seconds |
| 138 | + """ |
| 139 | + if not network: |
| 140 | + raise ValueError(f"Expected a non-empty value for `network` but received {network!r}") |
| 141 | + if not token_address: |
| 142 | + raise ValueError(f"Expected a non-empty value for `token_address` but received {token_address!r}") |
| 143 | + return await self._get( |
| 144 | + f"/onchain/networks/{network}/tokens/{token_address}/holders_chart", |
| 145 | + options=make_request_options( |
| 146 | + extra_headers=extra_headers, |
| 147 | + extra_query=extra_query, |
| 148 | + extra_body=extra_body, |
| 149 | + timeout=timeout, |
| 150 | + query=await async_maybe_transform({"days": days}, holders_chart_get_params.HoldersChartGetParams), |
| 151 | + ), |
| 152 | + cast_to=HoldersChartGetResponse, |
| 153 | + ) |
| 154 | + |
| 155 | + |
| 156 | +class HoldersChartResourceWithRawResponse: |
| 157 | + def __init__(self, holders_chart: HoldersChartResource) -> None: |
| 158 | + self._holders_chart = holders_chart |
| 159 | + |
| 160 | + self.get = to_raw_response_wrapper( |
| 161 | + holders_chart.get, |
| 162 | + ) |
| 163 | + |
| 164 | + |
| 165 | +class AsyncHoldersChartResourceWithRawResponse: |
| 166 | + def __init__(self, holders_chart: AsyncHoldersChartResource) -> None: |
| 167 | + self._holders_chart = holders_chart |
| 168 | + |
| 169 | + self.get = async_to_raw_response_wrapper( |
| 170 | + holders_chart.get, |
| 171 | + ) |
| 172 | + |
| 173 | + |
| 174 | +class HoldersChartResourceWithStreamingResponse: |
| 175 | + def __init__(self, holders_chart: HoldersChartResource) -> None: |
| 176 | + self._holders_chart = holders_chart |
| 177 | + |
| 178 | + self.get = to_streamed_response_wrapper( |
| 179 | + holders_chart.get, |
| 180 | + ) |
| 181 | + |
| 182 | + |
| 183 | +class AsyncHoldersChartResourceWithStreamingResponse: |
| 184 | + def __init__(self, holders_chart: AsyncHoldersChartResource) -> None: |
| 185 | + self._holders_chart = holders_chart |
| 186 | + |
| 187 | + self.get = async_to_streamed_response_wrapper( |
| 188 | + holders_chart.get, |
| 189 | + ) |
0 commit comments