|
| 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 .. import _legacy_response |
| 10 | +from ..types import card_authorization_challenge_response_params |
| 11 | +from .._types import Body, Query, Headers, NoneType, NotGiven, not_given |
| 12 | +from .._utils import path_template, maybe_transform, async_maybe_transform |
| 13 | +from .._compat import cached_property |
| 14 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 15 | +from .._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper |
| 16 | +from .._base_client import make_request_options |
| 17 | + |
| 18 | +__all__ = ["CardAuthorizations", "AsyncCardAuthorizations"] |
| 19 | + |
| 20 | + |
| 21 | +class CardAuthorizations(SyncAPIResource): |
| 22 | + @cached_property |
| 23 | + def with_raw_response(self) -> CardAuthorizationsWithRawResponse: |
| 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 CardAuthorizationsWithRawResponse(self) |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def with_streaming_response(self) -> CardAuthorizationsWithStreamingResponse: |
| 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 CardAuthorizationsWithStreamingResponse(self) |
| 40 | + |
| 41 | + def challenge_response( |
| 42 | + self, |
| 43 | + event_token: str, |
| 44 | + *, |
| 45 | + response: Literal["APPROVE", "DECLINE"], |
| 46 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 47 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 48 | + extra_headers: Headers | None = None, |
| 49 | + extra_query: Query | None = None, |
| 50 | + extra_body: Body | None = None, |
| 51 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 52 | + ) -> None: |
| 53 | + """Card program's response to Authorization Challenge. |
| 54 | +
|
| 55 | + Programs that have |
| 56 | + Authorization Challenges configured as Out of Band receive a |
| 57 | + [card_authorization.challenge](https://docs.lithic.com/reference/post_card-authorization-challenge) |
| 58 | + webhook when an authorization attempt triggers a challenge. The card program |
| 59 | + should respond using this endpoint after the cardholder completes the challenge. |
| 60 | +
|
| 61 | + Args: |
| 62 | + response: Whether the cardholder has approved or declined the issued challenge |
| 63 | +
|
| 64 | + extra_headers: Send extra headers |
| 65 | +
|
| 66 | + extra_query: Add additional query parameters to the request |
| 67 | +
|
| 68 | + extra_body: Add additional JSON properties to the request |
| 69 | +
|
| 70 | + timeout: Override the client-level default timeout for this request, in seconds |
| 71 | + """ |
| 72 | + if not event_token: |
| 73 | + raise ValueError(f"Expected a non-empty value for `event_token` but received {event_token!r}") |
| 74 | + return self._post( |
| 75 | + path_template("/v1/card_authorizations/{event_token}/challenge_response", event_token=event_token), |
| 76 | + body=maybe_transform( |
| 77 | + {"response": response}, |
| 78 | + card_authorization_challenge_response_params.CardAuthorizationChallengeResponseParams, |
| 79 | + ), |
| 80 | + options=make_request_options( |
| 81 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 82 | + ), |
| 83 | + cast_to=NoneType, |
| 84 | + ) |
| 85 | + |
| 86 | + |
| 87 | +class AsyncCardAuthorizations(AsyncAPIResource): |
| 88 | + @cached_property |
| 89 | + def with_raw_response(self) -> AsyncCardAuthorizationsWithRawResponse: |
| 90 | + """ |
| 91 | + This property can be used as a prefix for any HTTP method call to return |
| 92 | + the raw response object instead of the parsed content. |
| 93 | +
|
| 94 | + For more information, see https://www.github.com/lithic-com/lithic-python#accessing-raw-response-data-eg-headers |
| 95 | + """ |
| 96 | + return AsyncCardAuthorizationsWithRawResponse(self) |
| 97 | + |
| 98 | + @cached_property |
| 99 | + def with_streaming_response(self) -> AsyncCardAuthorizationsWithStreamingResponse: |
| 100 | + """ |
| 101 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 102 | +
|
| 103 | + For more information, see https://www.github.com/lithic-com/lithic-python#with_streaming_response |
| 104 | + """ |
| 105 | + return AsyncCardAuthorizationsWithStreamingResponse(self) |
| 106 | + |
| 107 | + async def challenge_response( |
| 108 | + self, |
| 109 | + event_token: str, |
| 110 | + *, |
| 111 | + response: Literal["APPROVE", "DECLINE"], |
| 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 | + ) -> None: |
| 119 | + """Card program's response to Authorization Challenge. |
| 120 | +
|
| 121 | + Programs that have |
| 122 | + Authorization Challenges configured as Out of Band receive a |
| 123 | + [card_authorization.challenge](https://docs.lithic.com/reference/post_card-authorization-challenge) |
| 124 | + webhook when an authorization attempt triggers a challenge. The card program |
| 125 | + should respond using this endpoint after the cardholder completes the challenge. |
| 126 | +
|
| 127 | + Args: |
| 128 | + response: Whether the cardholder has approved or declined the issued challenge |
| 129 | +
|
| 130 | + extra_headers: Send extra headers |
| 131 | +
|
| 132 | + extra_query: Add additional query parameters to the request |
| 133 | +
|
| 134 | + extra_body: Add additional JSON properties to the request |
| 135 | +
|
| 136 | + timeout: Override the client-level default timeout for this request, in seconds |
| 137 | + """ |
| 138 | + if not event_token: |
| 139 | + raise ValueError(f"Expected a non-empty value for `event_token` but received {event_token!r}") |
| 140 | + return await self._post( |
| 141 | + path_template("/v1/card_authorizations/{event_token}/challenge_response", event_token=event_token), |
| 142 | + body=await async_maybe_transform( |
| 143 | + {"response": response}, |
| 144 | + card_authorization_challenge_response_params.CardAuthorizationChallengeResponseParams, |
| 145 | + ), |
| 146 | + options=make_request_options( |
| 147 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 148 | + ), |
| 149 | + cast_to=NoneType, |
| 150 | + ) |
| 151 | + |
| 152 | + |
| 153 | +class CardAuthorizationsWithRawResponse: |
| 154 | + def __init__(self, card_authorizations: CardAuthorizations) -> None: |
| 155 | + self._card_authorizations = card_authorizations |
| 156 | + |
| 157 | + self.challenge_response = _legacy_response.to_raw_response_wrapper( |
| 158 | + card_authorizations.challenge_response, |
| 159 | + ) |
| 160 | + |
| 161 | + |
| 162 | +class AsyncCardAuthorizationsWithRawResponse: |
| 163 | + def __init__(self, card_authorizations: AsyncCardAuthorizations) -> None: |
| 164 | + self._card_authorizations = card_authorizations |
| 165 | + |
| 166 | + self.challenge_response = _legacy_response.async_to_raw_response_wrapper( |
| 167 | + card_authorizations.challenge_response, |
| 168 | + ) |
| 169 | + |
| 170 | + |
| 171 | +class CardAuthorizationsWithStreamingResponse: |
| 172 | + def __init__(self, card_authorizations: CardAuthorizations) -> None: |
| 173 | + self._card_authorizations = card_authorizations |
| 174 | + |
| 175 | + self.challenge_response = to_streamed_response_wrapper( |
| 176 | + card_authorizations.challenge_response, |
| 177 | + ) |
| 178 | + |
| 179 | + |
| 180 | +class AsyncCardAuthorizationsWithStreamingResponse: |
| 181 | + def __init__(self, card_authorizations: AsyncCardAuthorizations) -> None: |
| 182 | + self._card_authorizations = card_authorizations |
| 183 | + |
| 184 | + self.challenge_response = async_to_streamed_response_wrapper( |
| 185 | + card_authorizations.challenge_response, |
| 186 | + ) |
0 commit comments