|
| 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 .id import ( |
| 8 | + IDResource, |
| 9 | + AsyncIDResource, |
| 10 | + IDResourceWithRawResponse, |
| 11 | + AsyncIDResourceWithRawResponse, |
| 12 | + IDResourceWithStreamingResponse, |
| 13 | + AsyncIDResourceWithStreamingResponse, |
| 14 | +) |
| 15 | +from .phone import ( |
| 16 | + PhoneResource, |
| 17 | + AsyncPhoneResource, |
| 18 | + PhoneResourceWithRawResponse, |
| 19 | + AsyncPhoneResourceWithRawResponse, |
| 20 | + PhoneResourceWithStreamingResponse, |
| 21 | + AsyncPhoneResourceWithStreamingResponse, |
| 22 | +) |
| 23 | +from ...types import contact_list_params |
| 24 | +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 25 | +from ..._utils import ( |
| 26 | + maybe_transform, |
| 27 | + async_maybe_transform, |
| 28 | +) |
| 29 | +from ..._compat import cached_property |
| 30 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 31 | +from ..._response import ( |
| 32 | + to_raw_response_wrapper, |
| 33 | + to_streamed_response_wrapper, |
| 34 | + async_to_raw_response_wrapper, |
| 35 | + async_to_streamed_response_wrapper, |
| 36 | +) |
| 37 | +from ..._base_client import make_request_options |
| 38 | + |
| 39 | +__all__ = ["ContactsResource", "AsyncContactsResource"] |
| 40 | + |
| 41 | + |
| 42 | +class ContactsResource(SyncAPIResource): |
| 43 | + @cached_property |
| 44 | + def id(self) -> IDResource: |
| 45 | + return IDResource(self._client) |
| 46 | + |
| 47 | + @cached_property |
| 48 | + def phone(self) -> PhoneResource: |
| 49 | + return PhoneResource(self._client) |
| 50 | + |
| 51 | + @cached_property |
| 52 | + def with_raw_response(self) -> ContactsResourceWithRawResponse: |
| 53 | + """ |
| 54 | + This property can be used as a prefix for any HTTP method call to return the |
| 55 | + the raw response object instead of the parsed content. |
| 56 | +
|
| 57 | + For more information, see https://www.github.com/stainless-sdks/sent-python#accessing-raw-response-data-eg-headers |
| 58 | + """ |
| 59 | + return ContactsResourceWithRawResponse(self) |
| 60 | + |
| 61 | + @cached_property |
| 62 | + def with_streaming_response(self) -> ContactsResourceWithStreamingResponse: |
| 63 | + """ |
| 64 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 65 | +
|
| 66 | + For more information, see https://www.github.com/stainless-sdks/sent-python#with_streaming_response |
| 67 | + """ |
| 68 | + return ContactsResourceWithStreamingResponse(self) |
| 69 | + |
| 70 | + def list( |
| 71 | + self, |
| 72 | + *, |
| 73 | + customer_id: str, |
| 74 | + page: int, |
| 75 | + page_size: int, |
| 76 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 77 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 78 | + extra_headers: Headers | None = None, |
| 79 | + extra_query: Query | None = None, |
| 80 | + extra_body: Body | None = None, |
| 81 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 82 | + ) -> object: |
| 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( |
| 94 | + "/contacts", |
| 95 | + options=make_request_options( |
| 96 | + extra_headers=extra_headers, |
| 97 | + extra_query=extra_query, |
| 98 | + extra_body=extra_body, |
| 99 | + timeout=timeout, |
| 100 | + query=maybe_transform( |
| 101 | + { |
| 102 | + "customer_id": customer_id, |
| 103 | + "page": page, |
| 104 | + "page_size": page_size, |
| 105 | + }, |
| 106 | + contact_list_params.ContactListParams, |
| 107 | + ), |
| 108 | + ), |
| 109 | + cast_to=object, |
| 110 | + ) |
| 111 | + |
| 112 | + |
| 113 | +class AsyncContactsResource(AsyncAPIResource): |
| 114 | + @cached_property |
| 115 | + def id(self) -> AsyncIDResource: |
| 116 | + return AsyncIDResource(self._client) |
| 117 | + |
| 118 | + @cached_property |
| 119 | + def phone(self) -> AsyncPhoneResource: |
| 120 | + return AsyncPhoneResource(self._client) |
| 121 | + |
| 122 | + @cached_property |
| 123 | + def with_raw_response(self) -> AsyncContactsResourceWithRawResponse: |
| 124 | + """ |
| 125 | + This property can be used as a prefix for any HTTP method call to return the |
| 126 | + the raw response object instead of the parsed content. |
| 127 | +
|
| 128 | + For more information, see https://www.github.com/stainless-sdks/sent-python#accessing-raw-response-data-eg-headers |
| 129 | + """ |
| 130 | + return AsyncContactsResourceWithRawResponse(self) |
| 131 | + |
| 132 | + @cached_property |
| 133 | + def with_streaming_response(self) -> AsyncContactsResourceWithStreamingResponse: |
| 134 | + """ |
| 135 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 136 | +
|
| 137 | + For more information, see https://www.github.com/stainless-sdks/sent-python#with_streaming_response |
| 138 | + """ |
| 139 | + return AsyncContactsResourceWithStreamingResponse(self) |
| 140 | + |
| 141 | + async def list( |
| 142 | + self, |
| 143 | + *, |
| 144 | + customer_id: str, |
| 145 | + page: int, |
| 146 | + page_size: int, |
| 147 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 148 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 149 | + extra_headers: Headers | None = None, |
| 150 | + extra_query: Query | None = None, |
| 151 | + extra_body: Body | None = None, |
| 152 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 153 | + ) -> object: |
| 154 | + """ |
| 155 | + Args: |
| 156 | + extra_headers: Send extra headers |
| 157 | +
|
| 158 | + extra_query: Add additional query parameters to the request |
| 159 | +
|
| 160 | + extra_body: Add additional JSON properties to the request |
| 161 | +
|
| 162 | + timeout: Override the client-level default timeout for this request, in seconds |
| 163 | + """ |
| 164 | + return await self._get( |
| 165 | + "/contacts", |
| 166 | + options=make_request_options( |
| 167 | + extra_headers=extra_headers, |
| 168 | + extra_query=extra_query, |
| 169 | + extra_body=extra_body, |
| 170 | + timeout=timeout, |
| 171 | + query=await async_maybe_transform( |
| 172 | + { |
| 173 | + "customer_id": customer_id, |
| 174 | + "page": page, |
| 175 | + "page_size": page_size, |
| 176 | + }, |
| 177 | + contact_list_params.ContactListParams, |
| 178 | + ), |
| 179 | + ), |
| 180 | + cast_to=object, |
| 181 | + ) |
| 182 | + |
| 183 | + |
| 184 | +class ContactsResourceWithRawResponse: |
| 185 | + def __init__(self, contacts: ContactsResource) -> None: |
| 186 | + self._contacts = contacts |
| 187 | + |
| 188 | + self.list = to_raw_response_wrapper( |
| 189 | + contacts.list, |
| 190 | + ) |
| 191 | + |
| 192 | + @cached_property |
| 193 | + def id(self) -> IDResourceWithRawResponse: |
| 194 | + return IDResourceWithRawResponse(self._contacts.id) |
| 195 | + |
| 196 | + @cached_property |
| 197 | + def phone(self) -> PhoneResourceWithRawResponse: |
| 198 | + return PhoneResourceWithRawResponse(self._contacts.phone) |
| 199 | + |
| 200 | + |
| 201 | +class AsyncContactsResourceWithRawResponse: |
| 202 | + def __init__(self, contacts: AsyncContactsResource) -> None: |
| 203 | + self._contacts = contacts |
| 204 | + |
| 205 | + self.list = async_to_raw_response_wrapper( |
| 206 | + contacts.list, |
| 207 | + ) |
| 208 | + |
| 209 | + @cached_property |
| 210 | + def id(self) -> AsyncIDResourceWithRawResponse: |
| 211 | + return AsyncIDResourceWithRawResponse(self._contacts.id) |
| 212 | + |
| 213 | + @cached_property |
| 214 | + def phone(self) -> AsyncPhoneResourceWithRawResponse: |
| 215 | + return AsyncPhoneResourceWithRawResponse(self._contacts.phone) |
| 216 | + |
| 217 | + |
| 218 | +class ContactsResourceWithStreamingResponse: |
| 219 | + def __init__(self, contacts: ContactsResource) -> None: |
| 220 | + self._contacts = contacts |
| 221 | + |
| 222 | + self.list = to_streamed_response_wrapper( |
| 223 | + contacts.list, |
| 224 | + ) |
| 225 | + |
| 226 | + @cached_property |
| 227 | + def id(self) -> IDResourceWithStreamingResponse: |
| 228 | + return IDResourceWithStreamingResponse(self._contacts.id) |
| 229 | + |
| 230 | + @cached_property |
| 231 | + def phone(self) -> PhoneResourceWithStreamingResponse: |
| 232 | + return PhoneResourceWithStreamingResponse(self._contacts.phone) |
| 233 | + |
| 234 | + |
| 235 | +class AsyncContactsResourceWithStreamingResponse: |
| 236 | + def __init__(self, contacts: AsyncContactsResource) -> None: |
| 237 | + self._contacts = contacts |
| 238 | + |
| 239 | + self.list = async_to_streamed_response_wrapper( |
| 240 | + contacts.list, |
| 241 | + ) |
| 242 | + |
| 243 | + @cached_property |
| 244 | + def id(self) -> AsyncIDResourceWithStreamingResponse: |
| 245 | + return AsyncIDResourceWithStreamingResponse(self._contacts.id) |
| 246 | + |
| 247 | + @cached_property |
| 248 | + def phone(self) -> AsyncPhoneResourceWithStreamingResponse: |
| 249 | + return AsyncPhoneResourceWithStreamingResponse(self._contacts.phone) |
0 commit comments