diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 97d8dbba..aebbc8bc 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.100.0" + ".": "0.101.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index b4ca4228..4f6855e4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 166 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-aa089e65735b8884f8cb391b39b9a0b295819e438bf976c98cc6150628ca5488.yml -openapi_spec_hash: 719876533d1496e9192c7a734a78c736 -config_hash: e9a46eb8acb9dc2c236f3e1958a1c4dd +configured_endpoints: 168 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-529662462c00af160f74568fe26dbe576cf1fdc9f427e11bb1939bd8acdcb43f.yml +openapi_spec_hash: a98631dfc66716d41ada4ddb199f7028 +config_hash: 2d501901f343d00775037fcec4121983 diff --git a/CHANGELOG.md b/CHANGELOG.md index b7e62177..8e80fdc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.101.0 (2025-08-04) + +Full Changelog: [v0.100.0...v0.101.0](https://github.com/lithic-com/lithic-python/compare/v0.100.0...v0.101.0) + +### Features + +* **api:** adds new Account Activity API ([62a2b97](https://github.com/lithic-com/lithic-python/commit/62a2b970195c5a3969187e20921d9b5c859d91e8)) +* **client:** support file upload requests ([97fa938](https://github.com/lithic-com/lithic-python/commit/97fa9388daaf5147aeeaeb1911ca1847c149ff3a)) + ## 0.100.0 (2025-07-28) Full Changelog: [v0.99.0...v0.100.0](https://github.com/lithic-com/lithic-python/compare/v0.99.0...v0.100.0) diff --git a/api.md b/api.md index 57316bcc..c6fb2d1d 100644 --- a/api.md +++ b/api.md @@ -766,3 +766,16 @@ Methods: - client.network_programs.retrieve(network_program_token) -> NetworkProgram - client.network_programs.list(\*\*params) -> SyncSinglePage[NetworkProgram] + +# AccountActivity + +Types: + +```python +from lithic.types import AccountActivityListResponse, AccountActivityRetrieveTransactionResponse +``` + +Methods: + +- client.account_activity.list(\*\*params) -> SyncCursorPage[AccountActivityListResponse] +- client.account_activity.retrieve_transaction(transaction_token) -> AccountActivityRetrieveTransactionResponse diff --git a/pyproject.toml b/pyproject.toml index 42d829b1..e2e16fca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lithic" -version = "0.100.0" +version = "0.101.0" description = "The official Python library for the lithic API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/lithic/_base_client.py b/src/lithic/_base_client.py index fd80c4f6..50679a45 100644 --- a/src/lithic/_base_client.py +++ b/src/lithic/_base_client.py @@ -533,7 +533,10 @@ def _build_request( is_body_allowed = options.method.lower() != "get" if is_body_allowed: - kwargs["json"] = json_data if is_given(json_data) else None + if isinstance(json_data, bytes): + kwargs["content"] = json_data + else: + kwargs["json"] = json_data if is_given(json_data) else None kwargs["files"] = files else: headers.pop("Content-Type", None) diff --git a/src/lithic/_client.py b/src/lithic/_client.py index f847af26..f440a529 100644 --- a/src/lithic/_client.py +++ b/src/lithic/_client.py @@ -56,6 +56,7 @@ funding_events, account_holders, credit_products, + account_activity, digital_card_art, network_programs, external_payments, @@ -80,6 +81,7 @@ from .resources.funding_events import FundingEvents, AsyncFundingEvents from .resources.account_holders import AccountHolders, AsyncAccountHolders from .resources.reports.reports import Reports, AsyncReports + from .resources.account_activity import AccountActivity, AsyncAccountActivity from .resources.digital_card_art import DigitalCardArtResource, AsyncDigitalCardArtResource from .resources.network_programs import NetworkPrograms, AsyncNetworkPrograms from .resources.external_payments import ExternalPayments, AsyncExternalPayments @@ -368,6 +370,12 @@ def network_programs(self) -> NetworkPrograms: return NetworkPrograms(self) + @cached_property + def account_activity(self) -> AccountActivity: + from .resources.account_activity import AccountActivity + + return AccountActivity(self) + @cached_property def with_raw_response(self) -> LithicWithRawResponse: return LithicWithRawResponse(self) @@ -754,6 +762,12 @@ def network_programs(self) -> AsyncNetworkPrograms: return AsyncNetworkPrograms(self) + @cached_property + def account_activity(self) -> AsyncAccountActivity: + from .resources.account_activity import AsyncAccountActivity + + return AsyncAccountActivity(self) + @cached_property def webhooks(self) -> webhooks.AsyncWebhooks: from .resources.webhooks import AsyncWebhooks @@ -1069,6 +1083,12 @@ def network_programs(self) -> network_programs.NetworkProgramsWithRawResponse: return NetworkProgramsWithRawResponse(self._client.network_programs) + @cached_property + def account_activity(self) -> account_activity.AccountActivityWithRawResponse: + from .resources.account_activity import AccountActivityWithRawResponse + + return AccountActivityWithRawResponse(self._client.account_activity) + class AsyncLithicWithRawResponse: _client: AsyncLithic @@ -1242,6 +1262,12 @@ def network_programs(self) -> network_programs.AsyncNetworkProgramsWithRawRespon return AsyncNetworkProgramsWithRawResponse(self._client.network_programs) + @cached_property + def account_activity(self) -> account_activity.AsyncAccountActivityWithRawResponse: + from .resources.account_activity import AsyncAccountActivityWithRawResponse + + return AsyncAccountActivityWithRawResponse(self._client.account_activity) + class LithicWithStreamedResponse: _client: Lithic @@ -1415,6 +1441,12 @@ def network_programs(self) -> network_programs.NetworkProgramsWithStreamingRespo return NetworkProgramsWithStreamingResponse(self._client.network_programs) + @cached_property + def account_activity(self) -> account_activity.AccountActivityWithStreamingResponse: + from .resources.account_activity import AccountActivityWithStreamingResponse + + return AccountActivityWithStreamingResponse(self._client.account_activity) + class AsyncLithicWithStreamedResponse: _client: AsyncLithic @@ -1588,6 +1620,12 @@ def network_programs(self) -> network_programs.AsyncNetworkProgramsWithStreaming return AsyncNetworkProgramsWithStreamingResponse(self._client.network_programs) + @cached_property + def account_activity(self) -> account_activity.AsyncAccountActivityWithStreamingResponse: + from .resources.account_activity import AsyncAccountActivityWithStreamingResponse + + return AsyncAccountActivityWithStreamingResponse(self._client.account_activity) + Client = Lithic diff --git a/src/lithic/_files.py b/src/lithic/_files.py index 715cc207..cc14c14f 100644 --- a/src/lithic/_files.py +++ b/src/lithic/_files.py @@ -69,12 +69,12 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], _read_file_content(file[1]), *file[2:]) + return (file[0], read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -def _read_file_content(file: FileContent) -> HttpxFileContent: +def read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return pathlib.Path(file).read_bytes() return file @@ -111,12 +111,12 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], await _async_read_file_content(file[1]), *file[2:]) + return (file[0], await async_read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -async def _async_read_file_content(file: FileContent) -> HttpxFileContent: +async def async_read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return await anyio.Path(file).read_bytes() diff --git a/src/lithic/_version.py b/src/lithic/_version.py index c16a3142..8fd6a8f9 100644 --- a/src/lithic/_version.py +++ b/src/lithic/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "lithic" -__version__ = "0.100.0" # x-release-please-version +__version__ = "0.101.0" # x-release-please-version diff --git a/src/lithic/resources/__init__.py b/src/lithic/resources/__init__.py index 8037eda6..1d7a2e76 100644 --- a/src/lithic/resources/__init__.py +++ b/src/lithic/resources/__init__.py @@ -137,6 +137,14 @@ CreditProductsWithStreamingResponse, AsyncCreditProductsWithStreamingResponse, ) +from .account_activity import ( + AccountActivity, + AsyncAccountActivity, + AccountActivityWithRawResponse, + AsyncAccountActivityWithRawResponse, + AccountActivityWithStreamingResponse, + AsyncAccountActivityWithStreamingResponse, +) from .digital_card_art import ( DigitalCardArtResource, AsyncDigitalCardArtResource, @@ -383,4 +391,10 @@ "AsyncNetworkProgramsWithRawResponse", "NetworkProgramsWithStreamingResponse", "AsyncNetworkProgramsWithStreamingResponse", + "AccountActivity", + "AsyncAccountActivity", + "AccountActivityWithRawResponse", + "AsyncAccountActivityWithRawResponse", + "AccountActivityWithStreamingResponse", + "AsyncAccountActivityWithStreamingResponse", ] diff --git a/src/lithic/resources/account_activity.py b/src/lithic/resources/account_activity.py new file mode 100644 index 00000000..287924c1 --- /dev/null +++ b/src/lithic/resources/account_activity.py @@ -0,0 +1,391 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, List, Union, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from .. import _legacy_response +from ..types import account_activity_list_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper +from ..pagination import SyncCursorPage, AsyncCursorPage +from .._base_client import AsyncPaginator, make_request_options +from ..types.account_activity_list_response import AccountActivityListResponse +from ..types.account_activity_retrieve_transaction_response import AccountActivityRetrieveTransactionResponse + +__all__ = ["AccountActivity", "AsyncAccountActivity"] + + +class AccountActivity(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AccountActivityWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/lithic-com/lithic-python#accessing-raw-response-data-eg-headers + """ + return AccountActivityWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AccountActivityWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/lithic-com/lithic-python#with_streaming_response + """ + return AccountActivityWithStreamingResponse(self) + + def list( + self, + *, + begin: Union[str, datetime] | NotGiven = NOT_GIVEN, + business_account_token: str | NotGiven = NOT_GIVEN, + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + | NotGiven = NOT_GIVEN, + end: Union[str, datetime] | NotGiven = NOT_GIVEN, + ending_before: str | NotGiven = NOT_GIVEN, + financial_account_token: str | NotGiven = NOT_GIVEN, + page_size: int | NotGiven = NOT_GIVEN, + result: List[Literal["APPROVED", "DECLINED"]] | NotGiven = NOT_GIVEN, + starting_after: str | NotGiven = NOT_GIVEN, + status: List[Literal["DECLINED", "EXPIRED", "PENDING", "SETTLED", "VOIDED", "RETURNED", "REVERSED"]] + | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncCursorPage[AccountActivityListResponse]: + """ + Retrieve a list of transactions across all public accounts. + + Args: + begin: Date string in RFC 3339 format. Only entries created after the specified time + will be included. UTC time zone. + + business_account_token: Filter by business account token + + category: Filter by transaction category + + end: Date string in RFC 3339 format. Only entries created before the specified time + will be included. UTC time zone. + + ending_before: A cursor representing an item's token before which a page of results should end. + Used to retrieve the previous page of results before this item. + + financial_account_token: Filter by financial account token + + page_size: Page size (for pagination). + + result: Filter by transaction result + + starting_after: A cursor representing an item's token after which a page of results should + begin. Used to retrieve the next page of results after this item. + + status: Filter by transaction status + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/v1/account_activity", + page=SyncCursorPage[AccountActivityListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "begin": begin, + "business_account_token": business_account_token, + "category": category, + "end": end, + "ending_before": ending_before, + "financial_account_token": financial_account_token, + "page_size": page_size, + "result": result, + "starting_after": starting_after, + "status": status, + }, + account_activity_list_params.AccountActivityListParams, + ), + ), + model=cast( + Any, AccountActivityListResponse + ), # Union types cannot be passed in as arguments in the type system + ) + + def retrieve_transaction( + self, + transaction_token: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AccountActivityRetrieveTransactionResponse: + """ + Retrieve a single transaction + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not transaction_token: + raise ValueError(f"Expected a non-empty value for `transaction_token` but received {transaction_token!r}") + return cast( + AccountActivityRetrieveTransactionResponse, + self._get( + f"/v1/account_activity/{transaction_token}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast( + Any, AccountActivityRetrieveTransactionResponse + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AsyncAccountActivity(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAccountActivityWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/lithic-com/lithic-python#accessing-raw-response-data-eg-headers + """ + return AsyncAccountActivityWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAccountActivityWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/lithic-com/lithic-python#with_streaming_response + """ + return AsyncAccountActivityWithStreamingResponse(self) + + def list( + self, + *, + begin: Union[str, datetime] | NotGiven = NOT_GIVEN, + business_account_token: str | NotGiven = NOT_GIVEN, + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + | NotGiven = NOT_GIVEN, + end: Union[str, datetime] | NotGiven = NOT_GIVEN, + ending_before: str | NotGiven = NOT_GIVEN, + financial_account_token: str | NotGiven = NOT_GIVEN, + page_size: int | NotGiven = NOT_GIVEN, + result: List[Literal["APPROVED", "DECLINED"]] | NotGiven = NOT_GIVEN, + starting_after: str | NotGiven = NOT_GIVEN, + status: List[Literal["DECLINED", "EXPIRED", "PENDING", "SETTLED", "VOIDED", "RETURNED", "REVERSED"]] + | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[AccountActivityListResponse, AsyncCursorPage[AccountActivityListResponse]]: + """ + Retrieve a list of transactions across all public accounts. + + Args: + begin: Date string in RFC 3339 format. Only entries created after the specified time + will be included. UTC time zone. + + business_account_token: Filter by business account token + + category: Filter by transaction category + + end: Date string in RFC 3339 format. Only entries created before the specified time + will be included. UTC time zone. + + ending_before: A cursor representing an item's token before which a page of results should end. + Used to retrieve the previous page of results before this item. + + financial_account_token: Filter by financial account token + + page_size: Page size (for pagination). + + result: Filter by transaction result + + starting_after: A cursor representing an item's token after which a page of results should + begin. Used to retrieve the next page of results after this item. + + status: Filter by transaction status + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/v1/account_activity", + page=AsyncCursorPage[AccountActivityListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "begin": begin, + "business_account_token": business_account_token, + "category": category, + "end": end, + "ending_before": ending_before, + "financial_account_token": financial_account_token, + "page_size": page_size, + "result": result, + "starting_after": starting_after, + "status": status, + }, + account_activity_list_params.AccountActivityListParams, + ), + ), + model=cast( + Any, AccountActivityListResponse + ), # Union types cannot be passed in as arguments in the type system + ) + + async def retrieve_transaction( + self, + transaction_token: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AccountActivityRetrieveTransactionResponse: + """ + Retrieve a single transaction + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not transaction_token: + raise ValueError(f"Expected a non-empty value for `transaction_token` but received {transaction_token!r}") + return cast( + AccountActivityRetrieveTransactionResponse, + await self._get( + f"/v1/account_activity/{transaction_token}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast( + Any, AccountActivityRetrieveTransactionResponse + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AccountActivityWithRawResponse: + def __init__(self, account_activity: AccountActivity) -> None: + self._account_activity = account_activity + + self.list = _legacy_response.to_raw_response_wrapper( + account_activity.list, + ) + self.retrieve_transaction = _legacy_response.to_raw_response_wrapper( + account_activity.retrieve_transaction, + ) + + +class AsyncAccountActivityWithRawResponse: + def __init__(self, account_activity: AsyncAccountActivity) -> None: + self._account_activity = account_activity + + self.list = _legacy_response.async_to_raw_response_wrapper( + account_activity.list, + ) + self.retrieve_transaction = _legacy_response.async_to_raw_response_wrapper( + account_activity.retrieve_transaction, + ) + + +class AccountActivityWithStreamingResponse: + def __init__(self, account_activity: AccountActivity) -> None: + self._account_activity = account_activity + + self.list = to_streamed_response_wrapper( + account_activity.list, + ) + self.retrieve_transaction = to_streamed_response_wrapper( + account_activity.retrieve_transaction, + ) + + +class AsyncAccountActivityWithStreamingResponse: + def __init__(self, account_activity: AsyncAccountActivity) -> None: + self._account_activity = account_activity + + self.list = async_to_streamed_response_wrapper( + account_activity.list, + ) + self.retrieve_transaction = async_to_streamed_response_wrapper( + account_activity.retrieve_transaction, + ) diff --git a/src/lithic/types/__init__.py b/src/lithic/types/__init__.py index 9b641f87..295b2fe5 100644 --- a/src/lithic/types/__init__.py +++ b/src/lithic/types/__init__.py @@ -88,6 +88,7 @@ from .card_web_provision_response import CardWebProvisionResponse as CardWebProvisionResponse from .funding_event_list_response import FundingEventListResponse as FundingEventListResponse from .network_program_list_params import NetworkProgramListParams as NetworkProgramListParams +from .account_activity_list_params import AccountActivityListParams as AccountActivityListParams from .account_holder_create_params import AccountHolderCreateParams as AccountHolderCreateParams from .account_holder_update_params import AccountHolderUpdateParams as AccountHolderUpdateParams from .book_transfer_reverse_params import BookTransferReverseParams as BookTransferReverseParams @@ -99,6 +100,7 @@ from .dispute_list_evidences_params import DisputeListEvidencesParams as DisputeListEvidencesParams from .external_bank_account_address import ExternalBankAccountAddress as ExternalBankAccountAddress from .financial_account_list_params import FinancialAccountListParams as FinancialAccountListParams +from .account_activity_list_response import AccountActivityListResponse as AccountActivityListResponse from .account_holder_create_response import AccountHolderCreateResponse as AccountHolderCreateResponse from .account_holder_update_response import AccountHolderUpdateResponse as AccountHolderUpdateResponse from .external_payment_cancel_params import ExternalPaymentCancelParams as ExternalPaymentCancelParams @@ -192,6 +194,9 @@ from .transaction_simulate_return_reversal_response import ( TransactionSimulateReturnReversalResponse as TransactionSimulateReturnReversalResponse, ) +from .account_activity_retrieve_transaction_response import ( + AccountActivityRetrieveTransactionResponse as AccountActivityRetrieveTransactionResponse, +) from .tokenization_decisioning_rotate_secret_response import ( TokenizationDecisioningRotateSecretResponse as TokenizationDecisioningRotateSecretResponse, ) diff --git a/src/lithic/types/account_activity_list_params.py b/src/lithic/types/account_activity_list_params.py new file mode 100644 index 00000000..6de22fcb --- /dev/null +++ b/src/lithic/types/account_activity_list_params.py @@ -0,0 +1,70 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["AccountActivityListParams"] + + +class AccountActivityListParams(TypedDict, total=False): + begin: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """Date string in RFC 3339 format. + + Only entries created after the specified time will be included. UTC time zone. + """ + + business_account_token: str + """Filter by business account token""" + + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + """Filter by transaction category""" + + end: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """Date string in RFC 3339 format. + + Only entries created before the specified time will be included. UTC time zone. + """ + + ending_before: str + """A cursor representing an item's token before which a page of results should end. + + Used to retrieve the previous page of results before this item. + """ + + financial_account_token: str + """Filter by financial account token""" + + page_size: int + """Page size (for pagination).""" + + result: List[Literal["APPROVED", "DECLINED"]] + """Filter by transaction result""" + + starting_after: str + """A cursor representing an item's token after which a page of results should + begin. + + Used to retrieve the next page of results after this item. + """ + + status: List[Literal["DECLINED", "EXPIRED", "PENDING", "SETTLED", "VOIDED", "RETURNED", "REVERSED"]] + """Filter by transaction status""" diff --git a/src/lithic/types/account_activity_list_response.py b/src/lithic/types/account_activity_list_response.py new file mode 100644 index 00000000..7c083dc6 --- /dev/null +++ b/src/lithic/types/account_activity_list_response.py @@ -0,0 +1,312 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import date, datetime +from typing_extensions import Literal, TypeAlias + +from .._models import BaseModel +from .transaction import Transaction +from .external_payment import ExternalPayment +from .external_resource import ExternalResource +from .management_operation_transaction import ManagementOperationTransaction + +__all__ = [ + "AccountActivityListResponse", + "FinancialTransaction", + "BookTransferTransaction", + "BookTransferTransactionTransactionSeries", + "CardTransaction", + "PaymentTransaction", + "PaymentTransactionMethodAttributes", + "PaymentTransactionMethodAttributesACHMethodAttributes", + "PaymentTransactionMethodAttributesWireMethodAttributes", + "PaymentTransactionRelatedAccountTokens", +] + + +class FinancialTransaction(BaseModel): + token: str + """Unique identifier for the transaction""" + + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + """Transaction category""" + + created: datetime + """ISO 8601 timestamp of when the transaction was created""" + + currency: str + """Currency of the transaction, represented in ISO 4217 format""" + + descriptor: str + """Transaction descriptor""" + + events: List[object] + """List of transaction events""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + financial_account_token: str + """Financial account token associated with the transaction""" + + pending_amount: int + """Pending amount in cents""" + + result: Literal["APPROVED", "DECLINED"] + """Transaction result""" + + settled_amount: int + """Settled amount in cents""" + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] + """The status of the transaction""" + + updated: datetime + """ISO 8601 timestamp of when the transaction was last updated""" + + +class BookTransferTransactionTransactionSeries(BaseModel): + related_transaction_event_token: Optional[str] = None + + related_transaction_token: Optional[str] = None + + type: str + + +class BookTransferTransaction(BaseModel): + token: str + """Unique identifier for the transaction""" + + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + + created: datetime + """ISO 8601 timestamp of when the transaction was created""" + + currency: str + """Currency of the transaction in ISO 4217 format""" + + events: List[object] + """List of events associated with this book transfer""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + from_financial_account_token: str + """Source account token""" + + pending_amount: int + """The pending amount of the transaction in cents""" + + result: Literal["APPROVED", "DECLINED"] + + settled_amount: int + """The settled amount of the transaction in cents""" + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] + """The status of the transaction""" + + to_financial_account_token: str + """Destination account token""" + + updated: datetime + """ISO 8601 timestamp of when the transaction was last updated""" + + external_id: Optional[str] = None + """External identifier for the transaction""" + + external_resource: Optional[ExternalResource] = None + """External resource associated with the management operation""" + + transaction_series: Optional[BookTransferTransactionTransactionSeries] = None + + +class CardTransaction(Transaction): + token: str # type: ignore + """Unique identifier for the transaction""" + + created: datetime # type: ignore + """ISO 8601 timestamp of when the transaction was created""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] # type: ignore + """The status of the transaction""" + + updated: datetime # type: ignore + """ISO 8601 timestamp of when the transaction was last updated""" + + +class PaymentTransactionMethodAttributesACHMethodAttributes(BaseModel): + sec_code: Literal["CCD", "PPD", "WEB", "TEL", "CIE", "CTX"] + """SEC code for ACH transaction""" + + addenda: Optional[str] = None + """Addenda information""" + + company_id: Optional[str] = None + """Company ID for the ACH transaction""" + + receipt_routing_number: Optional[str] = None + """Receipt routing number""" + + retries: Optional[int] = None + """Number of retries attempted""" + + return_reason_code: Optional[str] = None + """Return reason code if the transaction was returned""" + + trace_numbers: Optional[List[str]] = None + """Trace numbers for the ACH transaction""" + + +class PaymentTransactionMethodAttributesWireMethodAttributes(BaseModel): + wire_transfer_type: Literal["FEDWIRE", "SWIFT"] + """Type of wire transfer""" + + external_bank_name: Optional[str] = None + """External bank name""" + + external_bank_routing_number: Optional[str] = None + """External bank routing number""" + + external_individual_name: Optional[str] = None + """External individual name""" + + lithic_bank_name: Optional[str] = None + """Lithic bank name""" + + lithic_bank_routing_number: Optional[str] = None + """Lithic bank routing number""" + + lithic_individual_name: Optional[str] = None + """Lithic individual name""" + + previous_transfer: Optional[str] = None + """UUID of previous transfer if this is a retry""" + + +PaymentTransactionMethodAttributes: TypeAlias = Union[ + PaymentTransactionMethodAttributesACHMethodAttributes, PaymentTransactionMethodAttributesWireMethodAttributes +] + + +class PaymentTransactionRelatedAccountTokens(BaseModel): + account_token: Optional[str] = None + """Globally unique identifier for the account""" + + business_account_token: Optional[str] = None + """Globally unique identifier for the business account""" + + +class PaymentTransaction(BaseModel): + token: str + """Unique identifier for the transaction""" + + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + """Transaction category""" + + created: datetime + """ISO 8601 timestamp of when the transaction was created""" + + descriptor: str + """Transaction descriptor""" + + direction: Literal["CREDIT", "DEBIT"] + """Transfer direction""" + + events: List[object] + """List of transaction events""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + financial_account_token: str + """Financial account token""" + + method: Literal["ACH_NEXT_DAY", "ACH_SAME_DAY", "WIRE"] + """Transfer method""" + + method_attributes: PaymentTransactionMethodAttributes + """Method-specific attributes""" + + pending_amount: int + """Pending amount in cents""" + + related_account_tokens: PaymentTransactionRelatedAccountTokens + """Related account tokens for the transaction""" + + result: Literal["APPROVED", "DECLINED"] + """Transaction result""" + + settled_amount: int + """Settled amount in cents""" + + source: Literal["LITHIC", "EXTERNAL", "CUSTOMER"] + """Transaction source""" + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] + """The status of the transaction""" + + updated: datetime + """ISO 8601 timestamp of when the transaction was last updated""" + + currency: Optional[str] = None + """Currency of the transaction in ISO 4217 format""" + + expected_release_date: Optional[date] = None + """Expected release date for the transaction""" + + external_bank_account_token: Optional[str] = None + """External bank account token""" + + user_defined_id: Optional[str] = None + """User-defined identifier""" + + +AccountActivityListResponse: TypeAlias = Union[ + FinancialTransaction, + BookTransferTransaction, + CardTransaction, + PaymentTransaction, + ExternalPayment, + ManagementOperationTransaction, +] diff --git a/src/lithic/types/account_activity_retrieve_transaction_response.py b/src/lithic/types/account_activity_retrieve_transaction_response.py new file mode 100644 index 00000000..6982fafa --- /dev/null +++ b/src/lithic/types/account_activity_retrieve_transaction_response.py @@ -0,0 +1,312 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import date, datetime +from typing_extensions import Literal, TypeAlias + +from .._models import BaseModel +from .transaction import Transaction +from .external_payment import ExternalPayment +from .external_resource import ExternalResource +from .management_operation_transaction import ManagementOperationTransaction + +__all__ = [ + "AccountActivityRetrieveTransactionResponse", + "FinancialTransaction", + "BookTransferTransaction", + "BookTransferTransactionTransactionSeries", + "CardTransaction", + "PaymentTransaction", + "PaymentTransactionMethodAttributes", + "PaymentTransactionMethodAttributesACHMethodAttributes", + "PaymentTransactionMethodAttributesWireMethodAttributes", + "PaymentTransactionRelatedAccountTokens", +] + + +class FinancialTransaction(BaseModel): + token: str + """Unique identifier for the transaction""" + + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + """Transaction category""" + + created: datetime + """ISO 8601 timestamp of when the transaction was created""" + + currency: str + """Currency of the transaction, represented in ISO 4217 format""" + + descriptor: str + """Transaction descriptor""" + + events: List[object] + """List of transaction events""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + financial_account_token: str + """Financial account token associated with the transaction""" + + pending_amount: int + """Pending amount in cents""" + + result: Literal["APPROVED", "DECLINED"] + """Transaction result""" + + settled_amount: int + """Settled amount in cents""" + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] + """The status of the transaction""" + + updated: datetime + """ISO 8601 timestamp of when the transaction was last updated""" + + +class BookTransferTransactionTransactionSeries(BaseModel): + related_transaction_event_token: Optional[str] = None + + related_transaction_token: Optional[str] = None + + type: str + + +class BookTransferTransaction(BaseModel): + token: str + """Unique identifier for the transaction""" + + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + + created: datetime + """ISO 8601 timestamp of when the transaction was created""" + + currency: str + """Currency of the transaction in ISO 4217 format""" + + events: List[object] + """List of events associated with this book transfer""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + from_financial_account_token: str + """Source account token""" + + pending_amount: int + """The pending amount of the transaction in cents""" + + result: Literal["APPROVED", "DECLINED"] + + settled_amount: int + """The settled amount of the transaction in cents""" + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] + """The status of the transaction""" + + to_financial_account_token: str + """Destination account token""" + + updated: datetime + """ISO 8601 timestamp of when the transaction was last updated""" + + external_id: Optional[str] = None + """External identifier for the transaction""" + + external_resource: Optional[ExternalResource] = None + """External resource associated with the management operation""" + + transaction_series: Optional[BookTransferTransactionTransactionSeries] = None + + +class CardTransaction(Transaction): + token: str # type: ignore + """Unique identifier for the transaction""" + + created: datetime # type: ignore + """ISO 8601 timestamp of when the transaction was created""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] # type: ignore + """The status of the transaction""" + + updated: datetime # type: ignore + """ISO 8601 timestamp of when the transaction was last updated""" + + +class PaymentTransactionMethodAttributesACHMethodAttributes(BaseModel): + sec_code: Literal["CCD", "PPD", "WEB", "TEL", "CIE", "CTX"] + """SEC code for ACH transaction""" + + addenda: Optional[str] = None + """Addenda information""" + + company_id: Optional[str] = None + """Company ID for the ACH transaction""" + + receipt_routing_number: Optional[str] = None + """Receipt routing number""" + + retries: Optional[int] = None + """Number of retries attempted""" + + return_reason_code: Optional[str] = None + """Return reason code if the transaction was returned""" + + trace_numbers: Optional[List[str]] = None + """Trace numbers for the ACH transaction""" + + +class PaymentTransactionMethodAttributesWireMethodAttributes(BaseModel): + wire_transfer_type: Literal["FEDWIRE", "SWIFT"] + """Type of wire transfer""" + + external_bank_name: Optional[str] = None + """External bank name""" + + external_bank_routing_number: Optional[str] = None + """External bank routing number""" + + external_individual_name: Optional[str] = None + """External individual name""" + + lithic_bank_name: Optional[str] = None + """Lithic bank name""" + + lithic_bank_routing_number: Optional[str] = None + """Lithic bank routing number""" + + lithic_individual_name: Optional[str] = None + """Lithic individual name""" + + previous_transfer: Optional[str] = None + """UUID of previous transfer if this is a retry""" + + +PaymentTransactionMethodAttributes: TypeAlias = Union[ + PaymentTransactionMethodAttributesACHMethodAttributes, PaymentTransactionMethodAttributesWireMethodAttributes +] + + +class PaymentTransactionRelatedAccountTokens(BaseModel): + account_token: Optional[str] = None + """Globally unique identifier for the account""" + + business_account_token: Optional[str] = None + """Globally unique identifier for the business account""" + + +class PaymentTransaction(BaseModel): + token: str + """Unique identifier for the transaction""" + + category: Literal[ + "ACH", + "BALANCE_OR_FUNDING", + "CARD", + "EXTERNAL_ACH", + "EXTERNAL_CHECK", + "EXTERNAL_TRANSFER", + "EXTERNAL_WIRE", + "MANAGEMENT_ADJUSTMENT", + "MANAGEMENT_DISPUTE", + "MANAGEMENT_FEE", + "MANAGEMENT_REWARD", + "MANAGEMENT_DISBURSEMENT", + "PROGRAM_FUNDING", + ] + """Transaction category""" + + created: datetime + """ISO 8601 timestamp of when the transaction was created""" + + descriptor: str + """Transaction descriptor""" + + direction: Literal["CREDIT", "DEBIT"] + """Transfer direction""" + + events: List[object] + """List of transaction events""" + + family: Literal["CARD", "PAYMENT", "TRANSFER", "INTERNAL", "EXTERNAL_PAYMENT", "MANAGEMENT_OPERATION"] + + financial_account_token: str + """Financial account token""" + + method: Literal["ACH_NEXT_DAY", "ACH_SAME_DAY", "WIRE"] + """Transfer method""" + + method_attributes: PaymentTransactionMethodAttributes + """Method-specific attributes""" + + pending_amount: int + """Pending amount in cents""" + + related_account_tokens: PaymentTransactionRelatedAccountTokens + """Related account tokens for the transaction""" + + result: Literal["APPROVED", "DECLINED"] + """Transaction result""" + + settled_amount: int + """Settled amount in cents""" + + source: Literal["LITHIC", "EXTERNAL", "CUSTOMER"] + """Transaction source""" + + status: Literal["PENDING", "SETTLED", "DECLINED", "REVERSED", "CANCELED"] + """The status of the transaction""" + + updated: datetime + """ISO 8601 timestamp of when the transaction was last updated""" + + currency: Optional[str] = None + """Currency of the transaction in ISO 4217 format""" + + expected_release_date: Optional[date] = None + """Expected release date for the transaction""" + + external_bank_account_token: Optional[str] = None + """External bank account token""" + + user_defined_id: Optional[str] = None + """User-defined identifier""" + + +AccountActivityRetrieveTransactionResponse: TypeAlias = Union[ + FinancialTransaction, + BookTransferTransaction, + CardTransaction, + PaymentTransaction, + ExternalPayment, + ManagementOperationTransaction, +] diff --git a/src/lithic/types/book_transfer_response.py b/src/lithic/types/book_transfer_response.py index 49fb5663..9c119275 100644 --- a/src/lithic/types/book_transfer_response.py +++ b/src/lithic/types/book_transfer_response.py @@ -1,12 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List +from typing import List, Optional from datetime import datetime from typing_extensions import Literal from .._models import BaseModel +from .external_resource import ExternalResource -__all__ = ["BookTransferResponse", "Event"] +__all__ = ["BookTransferResponse", "Event", "TransactionSeries"] class Event(BaseModel): @@ -41,6 +42,14 @@ class Event(BaseModel): """Type of the book transfer""" +class TransactionSeries(BaseModel): + related_transaction_event_token: Optional[str] = None + + related_transaction_token: Optional[str] = None + + type: str + + class BookTransferResponse(BaseModel): token: str """Customer-provided token that will serve as an idempotency token. @@ -63,6 +72,9 @@ class BookTransferResponse(BaseModel): events: List[Event] """A list of all financial events that have modified this transfer.""" + external_resource: Optional[ExternalResource] = None + """External resource associated with the management operation""" + from_financial_account_token: str """ Globally unique identifier for the financial account or card that will send the @@ -101,5 +113,8 @@ class BookTransferResponse(BaseModel): the funds. Accepted type dependent on the program's use case. """ + transaction_series: Optional[TransactionSeries] = None + """A series of transactions that are grouped together.""" + updated: datetime """Date and time when the financial transaction was last updated. UTC time zone.""" diff --git a/src/lithic/types/external_payment.py b/src/lithic/types/external_payment.py index 15567ce0..98f2f952 100644 --- a/src/lithic/types/external_payment.py +++ b/src/lithic/types/external_payment.py @@ -16,7 +16,7 @@ class Event(BaseModel): created: datetime - detailed_results: List[Literal["APPROVED"]] + detailed_results: List[Literal["APPROVED", "INSUFFICIENT_FUNDS"]] effective_date: date diff --git a/src/lithic/types/management_operation_transaction.py b/src/lithic/types/management_operation_transaction.py index 2a46cb16..797983d1 100644 --- a/src/lithic/types/management_operation_transaction.py +++ b/src/lithic/types/management_operation_transaction.py @@ -17,7 +17,7 @@ class Event(BaseModel): created: datetime - detailed_results: List[Literal["APPROVED"]] + detailed_results: List[Literal["APPROVED", "INSUFFICIENT_FUNDS"]] effective_date: date diff --git a/src/lithic/types/payment.py b/src/lithic/types/payment.py index 644537e5..e985d2cf 100644 --- a/src/lithic/types/payment.py +++ b/src/lithic/types/payment.py @@ -6,7 +6,7 @@ from .._models import BaseModel -__all__ = ["Payment", "Event", "MethodAttributes"] +__all__ = ["Payment", "Event", "MethodAttributes", "RelatedAccountTokens"] class Event(BaseModel): @@ -94,6 +94,14 @@ class MethodAttributes(BaseModel): addenda: Optional[str] = None +class RelatedAccountTokens(BaseModel): + account_token: Optional[str] = None + """Globally unique identifier for the account""" + + business_account_token: Optional[str] = None + """Globally unique identifier for the business account""" + + class Payment(BaseModel): token: str """Globally unique identifier.""" @@ -132,6 +140,9 @@ class Payment(BaseModel): value of this field will go to zero over time once the payment is settled. """ + related_account_tokens: RelatedAccountTokens + """Account tokens related to a payment transaction""" + result: Literal["APPROVED", "DECLINED"] """ APPROVED payments were successful while DECLINED payments were declined by diff --git a/tests/api_resources/test_account_activity.py b/tests/api_resources/test_account_activity.py new file mode 100644 index 00000000..3ab3d621 --- /dev/null +++ b/tests/api_resources/test_account_activity.py @@ -0,0 +1,187 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from lithic import Lithic, AsyncLithic +from tests.utils import assert_matches_type +from lithic.types import ( + AccountActivityListResponse, + AccountActivityRetrieveTransactionResponse, +) +from lithic._utils import parse_datetime +from lithic.pagination import SyncCursorPage, AsyncCursorPage + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAccountActivity: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Lithic) -> None: + account_activity = client.account_activity.list() + assert_matches_type(SyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Lithic) -> None: + account_activity = client.account_activity.list( + begin=parse_datetime("2019-12-27T18:11:19.117Z"), + business_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + category="ACH", + end=parse_datetime("2019-12-27T18:11:19.117Z"), + ending_before="ending_before", + financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + page_size=1, + result=["APPROVED"], + starting_after="starting_after", + status=["DECLINED"], + ) + assert_matches_type(SyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Lithic) -> None: + response = client.account_activity.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_activity = response.parse() + assert_matches_type(SyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Lithic) -> None: + with client.account_activity.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_activity = response.parse() + assert_matches_type(SyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_retrieve_transaction(self, client: Lithic) -> None: + account_activity = client.account_activity.retrieve_transaction( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(AccountActivityRetrieveTransactionResponse, account_activity, path=["response"]) + + @parametrize + def test_raw_response_retrieve_transaction(self, client: Lithic) -> None: + response = client.account_activity.with_raw_response.retrieve_transaction( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_activity = response.parse() + assert_matches_type(AccountActivityRetrieveTransactionResponse, account_activity, path=["response"]) + + @parametrize + def test_streaming_response_retrieve_transaction(self, client: Lithic) -> None: + with client.account_activity.with_streaming_response.retrieve_transaction( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_activity = response.parse() + assert_matches_type(AccountActivityRetrieveTransactionResponse, account_activity, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve_transaction(self, client: Lithic) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `transaction_token` but received ''"): + client.account_activity.with_raw_response.retrieve_transaction( + "", + ) + + +class TestAsyncAccountActivity: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncLithic) -> None: + account_activity = await async_client.account_activity.list() + assert_matches_type(AsyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncLithic) -> None: + account_activity = await async_client.account_activity.list( + begin=parse_datetime("2019-12-27T18:11:19.117Z"), + business_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + category="ACH", + end=parse_datetime("2019-12-27T18:11:19.117Z"), + ending_before="ending_before", + financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + page_size=1, + result=["APPROVED"], + starting_after="starting_after", + status=["DECLINED"], + ) + assert_matches_type(AsyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncLithic) -> None: + response = await async_client.account_activity.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_activity = response.parse() + assert_matches_type(AsyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncLithic) -> None: + async with async_client.account_activity.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_activity = await response.parse() + assert_matches_type(AsyncCursorPage[AccountActivityListResponse], account_activity, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_retrieve_transaction(self, async_client: AsyncLithic) -> None: + account_activity = await async_client.account_activity.retrieve_transaction( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(AccountActivityRetrieveTransactionResponse, account_activity, path=["response"]) + + @parametrize + async def test_raw_response_retrieve_transaction(self, async_client: AsyncLithic) -> None: + response = await async_client.account_activity.with_raw_response.retrieve_transaction( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_activity = response.parse() + assert_matches_type(AccountActivityRetrieveTransactionResponse, account_activity, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve_transaction(self, async_client: AsyncLithic) -> None: + async with async_client.account_activity.with_streaming_response.retrieve_transaction( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_activity = await response.parse() + assert_matches_type(AccountActivityRetrieveTransactionResponse, account_activity, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve_transaction(self, async_client: AsyncLithic) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `transaction_token` but received ''"): + await async_client.account_activity.with_raw_response.retrieve_transaction( + "", + )