|
| 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, cast |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..._types import Body, Query, Headers, NotGiven, not_given |
| 10 | +from ..._utils import path_template |
| 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.x.account_connection_attempt_retrieve_response import AccountConnectionAttemptRetrieveResponse |
| 21 | + |
| 22 | +__all__ = ["AccountConnectionAttemptsResource", "AsyncAccountConnectionAttemptsResource"] |
| 23 | + |
| 24 | + |
| 25 | +class AccountConnectionAttemptsResource(SyncAPIResource): |
| 26 | + """Connected X account management""" |
| 27 | + |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> AccountConnectionAttemptsResourceWithRawResponse: |
| 30 | + """ |
| 31 | + This property can be used as a prefix for any HTTP method call to return |
| 32 | + the raw response object instead of the parsed content. |
| 33 | +
|
| 34 | + For more information, see https://www.github.com/Xquik-dev/x-twitter-scraper-python#accessing-raw-response-data-eg-headers |
| 35 | + """ |
| 36 | + return AccountConnectionAttemptsResourceWithRawResponse(self) |
| 37 | + |
| 38 | + @cached_property |
| 39 | + def with_streaming_response(self) -> AccountConnectionAttemptsResourceWithStreamingResponse: |
| 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/Xquik-dev/x-twitter-scraper-python#with_streaming_response |
| 44 | + """ |
| 45 | + return AccountConnectionAttemptsResourceWithStreamingResponse(self) |
| 46 | + |
| 47 | + def retrieve( |
| 48 | + self, |
| 49 | + id: str, |
| 50 | + *, |
| 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 | + ) -> AccountConnectionAttemptRetrieveResponse: |
| 58 | + """ |
| 59 | + Get X account connection status |
| 60 | +
|
| 61 | + Args: |
| 62 | + extra_headers: Send extra headers |
| 63 | +
|
| 64 | + extra_query: Add additional query parameters to the request |
| 65 | +
|
| 66 | + extra_body: Add additional JSON properties to the request |
| 67 | +
|
| 68 | + timeout: Override the client-level default timeout for this request, in seconds |
| 69 | + """ |
| 70 | + if not id: |
| 71 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 72 | + return cast( |
| 73 | + AccountConnectionAttemptRetrieveResponse, |
| 74 | + self._get( |
| 75 | + path_template("/x/account-connection-attempts/{id}", id=id), |
| 76 | + options=make_request_options( |
| 77 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 78 | + ), |
| 79 | + cast_to=cast( |
| 80 | + Any, AccountConnectionAttemptRetrieveResponse |
| 81 | + ), # Union types cannot be passed in as arguments in the type system |
| 82 | + ), |
| 83 | + ) |
| 84 | + |
| 85 | + |
| 86 | +class AsyncAccountConnectionAttemptsResource(AsyncAPIResource): |
| 87 | + """Connected X account management""" |
| 88 | + |
| 89 | + @cached_property |
| 90 | + def with_raw_response(self) -> AsyncAccountConnectionAttemptsResourceWithRawResponse: |
| 91 | + """ |
| 92 | + This property can be used as a prefix for any HTTP method call to return |
| 93 | + the raw response object instead of the parsed content. |
| 94 | +
|
| 95 | + For more information, see https://www.github.com/Xquik-dev/x-twitter-scraper-python#accessing-raw-response-data-eg-headers |
| 96 | + """ |
| 97 | + return AsyncAccountConnectionAttemptsResourceWithRawResponse(self) |
| 98 | + |
| 99 | + @cached_property |
| 100 | + def with_streaming_response(self) -> AsyncAccountConnectionAttemptsResourceWithStreamingResponse: |
| 101 | + """ |
| 102 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 103 | +
|
| 104 | + For more information, see https://www.github.com/Xquik-dev/x-twitter-scraper-python#with_streaming_response |
| 105 | + """ |
| 106 | + return AsyncAccountConnectionAttemptsResourceWithStreamingResponse(self) |
| 107 | + |
| 108 | + async def retrieve( |
| 109 | + self, |
| 110 | + id: str, |
| 111 | + *, |
| 112 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 113 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 114 | + extra_headers: Headers | None = None, |
| 115 | + extra_query: Query | None = None, |
| 116 | + extra_body: Body | None = None, |
| 117 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 118 | + ) -> AccountConnectionAttemptRetrieveResponse: |
| 119 | + """ |
| 120 | + Get X account connection status |
| 121 | +
|
| 122 | + Args: |
| 123 | + extra_headers: Send extra headers |
| 124 | +
|
| 125 | + extra_query: Add additional query parameters to the request |
| 126 | +
|
| 127 | + extra_body: Add additional JSON properties to the request |
| 128 | +
|
| 129 | + timeout: Override the client-level default timeout for this request, in seconds |
| 130 | + """ |
| 131 | + if not id: |
| 132 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 133 | + return cast( |
| 134 | + AccountConnectionAttemptRetrieveResponse, |
| 135 | + await self._get( |
| 136 | + path_template("/x/account-connection-attempts/{id}", id=id), |
| 137 | + options=make_request_options( |
| 138 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 139 | + ), |
| 140 | + cast_to=cast( |
| 141 | + Any, AccountConnectionAttemptRetrieveResponse |
| 142 | + ), # Union types cannot be passed in as arguments in the type system |
| 143 | + ), |
| 144 | + ) |
| 145 | + |
| 146 | + |
| 147 | +class AccountConnectionAttemptsResourceWithRawResponse: |
| 148 | + def __init__(self, account_connection_attempts: AccountConnectionAttemptsResource) -> None: |
| 149 | + self._account_connection_attempts = account_connection_attempts |
| 150 | + |
| 151 | + self.retrieve = to_raw_response_wrapper( |
| 152 | + account_connection_attempts.retrieve, |
| 153 | + ) |
| 154 | + |
| 155 | + |
| 156 | +class AsyncAccountConnectionAttemptsResourceWithRawResponse: |
| 157 | + def __init__(self, account_connection_attempts: AsyncAccountConnectionAttemptsResource) -> None: |
| 158 | + self._account_connection_attempts = account_connection_attempts |
| 159 | + |
| 160 | + self.retrieve = async_to_raw_response_wrapper( |
| 161 | + account_connection_attempts.retrieve, |
| 162 | + ) |
| 163 | + |
| 164 | + |
| 165 | +class AccountConnectionAttemptsResourceWithStreamingResponse: |
| 166 | + def __init__(self, account_connection_attempts: AccountConnectionAttemptsResource) -> None: |
| 167 | + self._account_connection_attempts = account_connection_attempts |
| 168 | + |
| 169 | + self.retrieve = to_streamed_response_wrapper( |
| 170 | + account_connection_attempts.retrieve, |
| 171 | + ) |
| 172 | + |
| 173 | + |
| 174 | +class AsyncAccountConnectionAttemptsResourceWithStreamingResponse: |
| 175 | + def __init__(self, account_connection_attempts: AsyncAccountConnectionAttemptsResource) -> None: |
| 176 | + self._account_connection_attempts = account_connection_attempts |
| 177 | + |
| 178 | + self.retrieve = async_to_streamed_response_wrapper( |
| 179 | + account_connection_attempts.retrieve, |
| 180 | + ) |
0 commit comments