|
| 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 .. import _legacy_response |
| 8 | +from ..types import OwnerType, blockchain_recipient_create_params |
| 9 | +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given |
| 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 to_streamed_response_wrapper, async_to_streamed_response_wrapper |
| 14 | +from .._base_client import make_request_options |
| 15 | +from ..types.owner_type import OwnerType |
| 16 | +from ..types.blockchain_recipient import BlockchainRecipient |
| 17 | + |
| 18 | +__all__ = ["BlockchainRecipients", "AsyncBlockchainRecipients"] |
| 19 | + |
| 20 | + |
| 21 | +class BlockchainRecipients(SyncAPIResource): |
| 22 | + @cached_property |
| 23 | + def with_raw_response(self) -> BlockchainRecipientsWithRawResponse: |
| 24 | + """ |
| 25 | + This property can be used as a prefix for any HTTP method call to return |
| 26 | + the raw response object instead of the parsed content. |
| 27 | +
|
| 28 | + For more information, see https://www.github.com/lithic-com/lithic-python#accessing-raw-response-data-eg-headers |
| 29 | + """ |
| 30 | + return BlockchainRecipientsWithRawResponse(self) |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def with_streaming_response(self) -> BlockchainRecipientsWithStreamingResponse: |
| 34 | + """ |
| 35 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 36 | +
|
| 37 | + For more information, see https://www.github.com/lithic-com/lithic-python#with_streaming_response |
| 38 | + """ |
| 39 | + return BlockchainRecipientsWithStreamingResponse(self) |
| 40 | + |
| 41 | + def create( |
| 42 | + self, |
| 43 | + *, |
| 44 | + account_token: str, |
| 45 | + address: str, |
| 46 | + chain: str, |
| 47 | + owner: str, |
| 48 | + owner_type: OwnerType, |
| 49 | + address_tag: str | Omit = omit, |
| 50 | + name: str | 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 | + ) -> BlockchainRecipient: |
| 58 | + """ |
| 59 | + Register a blockchain address as a withdrawal destination for a financial |
| 60 | + account |
| 61 | +
|
| 62 | + The recipient is created with a `PENDING` verification state and cannot receive |
| 63 | + a payout until screening of the address completes. Registering an address that |
| 64 | + is already registered to the same financial account returns the existing |
| 65 | + recipient and its current verification state, rather than creating a second one |
| 66 | +
|
| 67 | + Args: |
| 68 | + account_token: The financial account the blockchain recipient belongs to |
| 69 | +
|
| 70 | + address: The blockchain address funds will be withdrawn to |
| 71 | +
|
| 72 | + chain: The blockchain network that the address belongs to |
| 73 | +
|
| 74 | + owner: Legal name of the business or individual who owns the blockchain address |
| 75 | +
|
| 76 | + owner_type: Owner Type |
| 77 | +
|
| 78 | + address_tag: An optional tag or memo used by some chains to identify the destination of a |
| 79 | + transfer within a shared address |
| 80 | +
|
| 81 | + name: The nickname for this blockchain recipient |
| 82 | +
|
| 83 | + extra_headers: Send extra headers |
| 84 | +
|
| 85 | + extra_query: Add additional query parameters to the request |
| 86 | +
|
| 87 | + extra_body: Add additional JSON properties to the request |
| 88 | +
|
| 89 | + timeout: Override the client-level default timeout for this request, in seconds |
| 90 | + """ |
| 91 | + return self._post( |
| 92 | + "/v1/blockchain_recipients", |
| 93 | + body=maybe_transform( |
| 94 | + { |
| 95 | + "account_token": account_token, |
| 96 | + "address": address, |
| 97 | + "chain": chain, |
| 98 | + "owner": owner, |
| 99 | + "owner_type": owner_type, |
| 100 | + "address_tag": address_tag, |
| 101 | + "name": name, |
| 102 | + }, |
| 103 | + blockchain_recipient_create_params.BlockchainRecipientCreateParams, |
| 104 | + ), |
| 105 | + options=make_request_options( |
| 106 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 107 | + ), |
| 108 | + cast_to=BlockchainRecipient, |
| 109 | + ) |
| 110 | + |
| 111 | + |
| 112 | +class AsyncBlockchainRecipients(AsyncAPIResource): |
| 113 | + @cached_property |
| 114 | + def with_raw_response(self) -> AsyncBlockchainRecipientsWithRawResponse: |
| 115 | + """ |
| 116 | + This property can be used as a prefix for any HTTP method call to return |
| 117 | + the raw response object instead of the parsed content. |
| 118 | +
|
| 119 | + For more information, see https://www.github.com/lithic-com/lithic-python#accessing-raw-response-data-eg-headers |
| 120 | + """ |
| 121 | + return AsyncBlockchainRecipientsWithRawResponse(self) |
| 122 | + |
| 123 | + @cached_property |
| 124 | + def with_streaming_response(self) -> AsyncBlockchainRecipientsWithStreamingResponse: |
| 125 | + """ |
| 126 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 127 | +
|
| 128 | + For more information, see https://www.github.com/lithic-com/lithic-python#with_streaming_response |
| 129 | + """ |
| 130 | + return AsyncBlockchainRecipientsWithStreamingResponse(self) |
| 131 | + |
| 132 | + async def create( |
| 133 | + self, |
| 134 | + *, |
| 135 | + account_token: str, |
| 136 | + address: str, |
| 137 | + chain: str, |
| 138 | + owner: str, |
| 139 | + owner_type: OwnerType, |
| 140 | + address_tag: str | Omit = omit, |
| 141 | + name: str | Omit = omit, |
| 142 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 143 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 144 | + extra_headers: Headers | None = None, |
| 145 | + extra_query: Query | None = None, |
| 146 | + extra_body: Body | None = None, |
| 147 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 148 | + ) -> BlockchainRecipient: |
| 149 | + """ |
| 150 | + Register a blockchain address as a withdrawal destination for a financial |
| 151 | + account |
| 152 | +
|
| 153 | + The recipient is created with a `PENDING` verification state and cannot receive |
| 154 | + a payout until screening of the address completes. Registering an address that |
| 155 | + is already registered to the same financial account returns the existing |
| 156 | + recipient and its current verification state, rather than creating a second one |
| 157 | +
|
| 158 | + Args: |
| 159 | + account_token: The financial account the blockchain recipient belongs to |
| 160 | +
|
| 161 | + address: The blockchain address funds will be withdrawn to |
| 162 | +
|
| 163 | + chain: The blockchain network that the address belongs to |
| 164 | +
|
| 165 | + owner: Legal name of the business or individual who owns the blockchain address |
| 166 | +
|
| 167 | + owner_type: Owner Type |
| 168 | +
|
| 169 | + address_tag: An optional tag or memo used by some chains to identify the destination of a |
| 170 | + transfer within a shared address |
| 171 | +
|
| 172 | + name: The nickname for this blockchain recipient |
| 173 | +
|
| 174 | + extra_headers: Send extra headers |
| 175 | +
|
| 176 | + extra_query: Add additional query parameters to the request |
| 177 | +
|
| 178 | + extra_body: Add additional JSON properties to the request |
| 179 | +
|
| 180 | + timeout: Override the client-level default timeout for this request, in seconds |
| 181 | + """ |
| 182 | + return await self._post( |
| 183 | + "/v1/blockchain_recipients", |
| 184 | + body=await async_maybe_transform( |
| 185 | + { |
| 186 | + "account_token": account_token, |
| 187 | + "address": address, |
| 188 | + "chain": chain, |
| 189 | + "owner": owner, |
| 190 | + "owner_type": owner_type, |
| 191 | + "address_tag": address_tag, |
| 192 | + "name": name, |
| 193 | + }, |
| 194 | + blockchain_recipient_create_params.BlockchainRecipientCreateParams, |
| 195 | + ), |
| 196 | + options=make_request_options( |
| 197 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 198 | + ), |
| 199 | + cast_to=BlockchainRecipient, |
| 200 | + ) |
| 201 | + |
| 202 | + |
| 203 | +class BlockchainRecipientsWithRawResponse: |
| 204 | + def __init__(self, blockchain_recipients: BlockchainRecipients) -> None: |
| 205 | + self._blockchain_recipients = blockchain_recipients |
| 206 | + |
| 207 | + self.create = _legacy_response.to_raw_response_wrapper( |
| 208 | + blockchain_recipients.create, |
| 209 | + ) |
| 210 | + |
| 211 | + |
| 212 | +class AsyncBlockchainRecipientsWithRawResponse: |
| 213 | + def __init__(self, blockchain_recipients: AsyncBlockchainRecipients) -> None: |
| 214 | + self._blockchain_recipients = blockchain_recipients |
| 215 | + |
| 216 | + self.create = _legacy_response.async_to_raw_response_wrapper( |
| 217 | + blockchain_recipients.create, |
| 218 | + ) |
| 219 | + |
| 220 | + |
| 221 | +class BlockchainRecipientsWithStreamingResponse: |
| 222 | + def __init__(self, blockchain_recipients: BlockchainRecipients) -> None: |
| 223 | + self._blockchain_recipients = blockchain_recipients |
| 224 | + |
| 225 | + self.create = to_streamed_response_wrapper( |
| 226 | + blockchain_recipients.create, |
| 227 | + ) |
| 228 | + |
| 229 | + |
| 230 | +class AsyncBlockchainRecipientsWithStreamingResponse: |
| 231 | + def __init__(self, blockchain_recipients: AsyncBlockchainRecipients) -> None: |
| 232 | + self._blockchain_recipients = blockchain_recipients |
| 233 | + |
| 234 | + self.create = async_to_streamed_response_wrapper( |
| 235 | + blockchain_recipients.create, |
| 236 | + ) |
0 commit comments