diff --git a/README.md b/README.md index 9c4e801e..ab7b8ea4 100644 --- a/README.md +++ b/README.md @@ -293,6 +293,26 @@ if response.my_field is None: print('Got json like {"my_field": null}.') ``` +### Accessing raw response data (e.g. headers) + +The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call. + +```py +from modern_treasury import ModernTreasury + +client = ModernTreasury() +response = client.external_accounts.with_raw_response.create( + counterparty_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", +) + +print(response.headers.get('X-My-Header')) + +external_account = response.parse() # get the object that `external_accounts.create()` would have returned +print(external_account.id) +``` + +These methods return an [`APIResponse`](https://github.com/Modern-Treasury/modern-treasury-python/src/modern_treasury/_response.py) object. + ### Configuring the HTTP client You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including: diff --git a/pyproject.toml b/pyproject.toml index 65b9dc9f..eba2406f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,6 @@ format = { chain = [ typecheck = { chain = [ "typecheck:pyright", - "typecheck:verify-types", "typecheck:mypy" ]} "typecheck:pyright" = "pyright" diff --git a/src/modern_treasury/_base_client.py b/src/modern_treasury/_base_client.py index 38b9a2ec..6e4be17a 100644 --- a/src/modern_treasury/_base_client.py +++ b/src/modern_treasury/_base_client.py @@ -29,7 +29,7 @@ overload, ) from functools import lru_cache -from typing_extensions import Literal, get_args, override, get_origin +from typing_extensions import Literal, override import anyio import httpx @@ -49,11 +49,11 @@ ModelT, Headers, Timeout, - NoneType, NotGiven, ResponseT, Transport, AnyMapping, + PostParser, ProxiesTypes, RequestFiles, AsyncTransport, @@ -63,20 +63,16 @@ ) from ._utils import is_dict, is_given, is_mapping from ._compat import model_copy, model_dump -from ._models import ( - BaseModel, - GenericModel, - FinalRequestOptions, - validate_type, - construct_type, +from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type +from ._response import APIResponse +from ._constants import ( + DEFAULT_LIMITS, + DEFAULT_TIMEOUT, + DEFAULT_MAX_RETRIES, + RAW_RESPONSE_HEADER, ) from ._streaming import Stream, AsyncStream -from ._exceptions import ( - APIStatusError, - APITimeoutError, - APIConnectionError, - APIResponseValidationError, -) +from ._exceptions import APIStatusError, APITimeoutError, APIConnectionError log: logging.Logger = logging.getLogger(__name__) @@ -101,19 +97,6 @@ HTTPX_DEFAULT_TIMEOUT = Timeout(5.0) -# default timeout is 1 minute -DEFAULT_TIMEOUT = Timeout(timeout=60.0, connect=5.0) -DEFAULT_MAX_RETRIES = 2 -DEFAULT_LIMITS = Limits(max_connections=100, max_keepalive_connections=20) - - -class MissingStreamClassError(TypeError): - def __init__(self) -> None: - super().__init__( - "The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `modern_treasury._streaming` for reference", - ) - - class PageInfo: """Stores the necesary information to build the request to retrieve the next page. @@ -182,6 +165,7 @@ def _params_from_url(self, url: URL) -> httpx.QueryParams: def _info_to_options(self, info: PageInfo) -> FinalRequestOptions: options = model_copy(self._options) + options._strip_raw_response_header() if not isinstance(info.params, NotGiven): options.params = {**options.params, **info.params} @@ -260,13 +244,17 @@ def __await__(self) -> Generator[Any, None, AsyncPageT]: return self._get_page().__await__() async def _get_page(self) -> AsyncPageT: - page = await self._client.request(self._page_cls, self._options) - page._set_private_attributes( # pyright: ignore[reportPrivateUsage] - model=self._model, - options=self._options, - client=self._client, - ) - return page + def _parser(resp: AsyncPageT) -> AsyncPageT: + resp._set_private_attributes( + model=self._model, + options=self._options, + client=self._client, + ) + return resp + + self._options.post_parser = _parser + + return await self._client.request(self._page_cls, self._options) async def __aiter__(self) -> AsyncIterator[ModelT]: # https://github.com/microsoft/pyright/issues/3464 @@ -317,9 +305,10 @@ async def get_next_page(self: AsyncPageT) -> AsyncPageT: _HttpxClientT = TypeVar("_HttpxClientT", bound=Union[httpx.Client, httpx.AsyncClient]) +_DefaultStreamT = TypeVar("_DefaultStreamT", bound=Union[Stream[Any], AsyncStream[Any]]) -class BaseClient(Generic[_HttpxClientT]): +class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]): _client: _HttpxClientT _version: str _base_url: URL @@ -330,6 +319,7 @@ class BaseClient(Generic[_HttpxClientT]): _transport: Transport | AsyncTransport | None _strict_response_validation: bool _idempotency_header: str | None + _default_stream_cls: type[_DefaultStreamT] | None = None def __init__( self, @@ -504,80 +494,28 @@ def _serialize_multipartform(self, data: Mapping[object, object]) -> dict[str, o serialized[key] = value return serialized - def _extract_stream_chunk_type(self, stream_cls: type) -> type: - args = get_args(stream_cls) - if not args: - raise TypeError( - f"Expected stream_cls to have been given a generic type argument, e.g. Stream[Foo] but received {stream_cls}", - ) - return cast(type, args[0]) - def _process_response( self, *, cast_to: Type[ResponseT], - options: FinalRequestOptions, # noqa: ARG002 + options: FinalRequestOptions, response: httpx.Response, + stream: bool, + stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, ) -> ResponseT: - if cast_to is NoneType: - return cast(ResponseT, None) - - if cast_to == str: - return cast(ResponseT, response.text) - - origin = get_origin(cast_to) or cast_to - - if inspect.isclass(origin) and issubclass(origin, httpx.Response): - # Because of the invariance of our ResponseT TypeVar, users can subclass httpx.Response - # and pass that class to our request functions. We cannot change the variance to be either - # covariant or contravariant as that makes our usage of ResponseT illegal. We could construct - # the response class ourselves but that is something that should be supported directly in httpx - # as it would be easy to incorrectly construct the Response object due to the multitude of arguments. - if cast_to != httpx.Response: - raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`") - return cast(ResponseT, response) - - # The check here is necessary as we are subverting the the type system - # with casts as the relationship between TypeVars and Types are very strict - # which means we must return *exactly* what was input or transform it in a - # way that retains the TypeVar state. As we cannot do that in this function - # then we have to resort to using `cast`. At the time of writing, we know this - # to be safe as we have handled all the types that could be bound to the - # `ResponseT` TypeVar, however if that TypeVar is ever updated in the future, then - # this function would become unsafe but a type checker would not report an error. - if ( - cast_to is not UnknownResponse - and not origin is list - and not origin is dict - and not origin is Union - and not issubclass(origin, BaseModel) - ): - raise RuntimeError( - f"Invalid state, expected {cast_to} to be a subclass type of {BaseModel}, {dict}, {list} or {Union}." - ) - - # split is required to handle cases where additional information is included - # in the response, e.g. application/json; charset=utf-8 - content_type, *_ = response.headers.get("content-type").split(";") - if content_type != "application/json": - if self._strict_response_validation: - raise APIResponseValidationError( - response=response, - message=f"Expected Content-Type response header to be `application/json` but received `{content_type}` instead.", - body=response.text, - ) - - # If the API responds with content that isn't JSON then we just return - # the (decoded) text without performing any parsing so that you can still - # handle the response however you need to. - return response.text # type: ignore + api_response = APIResponse( + raw=response, + client=self, + cast_to=cast_to, + stream=stream, + stream_cls=stream_cls, + options=options, + ) - data = response.json() + if response.request.headers.get(RAW_RESPONSE_HEADER) == "true": + return cast(ResponseT, api_response) - try: - return self._process_response_data(data=data, cast_to=cast_to, response=response) - except pydantic.ValidationError as err: - raise APIResponseValidationError(response=response, body=data) from err + return api_response.parse() def _process_response_data( self, @@ -734,7 +672,7 @@ def _idempotency_key(self) -> str: return f"stainless-python-retry-{uuid.uuid4()}" -class SyncAPIClient(BaseClient[httpx.Client]): +class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]): _client: httpx.Client _has_custom_http_client: bool _default_stream_cls: type[Stream[Any]] | None = None @@ -930,23 +868,32 @@ def _request( raise self._make_status_error_from_response(err.response) from None except httpx.TimeoutException as err: if retries > 0: - return self._retry_request(options, cast_to, retries, stream=stream, stream_cls=stream_cls) + return self._retry_request( + options, + cast_to, + retries, + stream=stream, + stream_cls=stream_cls, + ) raise APITimeoutError(request=request) from err except Exception as err: if retries > 0: - return self._retry_request(options, cast_to, retries, stream=stream, stream_cls=stream_cls) + return self._retry_request( + options, + cast_to, + retries, + stream=stream, + stream_cls=stream_cls, + ) raise APIConnectionError(request=request) from err - if stream: - if stream_cls: - return stream_cls(cast_to=self._extract_stream_chunk_type(stream_cls), response=response, client=self) - - stream_cls = cast("type[_StreamT] | None", self._default_stream_cls) - if stream_cls is None: - raise MissingStreamClassError() - return stream_cls(cast_to=cast_to, response=response, client=self) - - return self._process_response(cast_to=cast_to, options=options, response=response) + return self._process_response( + cast_to=cast_to, + options=options, + response=response, + stream=stream, + stream_cls=stream_cls, + ) def _retry_request( self, @@ -980,13 +927,17 @@ def _request_api_list( page: Type[SyncPageT], options: FinalRequestOptions, ) -> SyncPageT: - resp = self.request(page, options, stream=False) - resp._set_private_attributes( # pyright: ignore[reportPrivateUsage] - client=self, - model=model, - options=options, - ) - return resp + def _parser(resp: SyncPageT) -> SyncPageT: + resp._set_private_attributes( + client=self, + model=model, + options=options, + ) + return resp + + options.post_parser = _parser + + return self.request(page, options, stream=False) @overload def get( @@ -1144,7 +1095,7 @@ def get_api_list( return self._request_api_list(model, page, opts) -class AsyncAPIClient(BaseClient[httpx.AsyncClient]): +class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]): _client: httpx.AsyncClient _has_custom_http_client: bool _default_stream_cls: type[AsyncStream[Any]] | None = None @@ -1354,16 +1305,13 @@ async def _request( return await self._retry_request(options, cast_to, retries, stream=stream, stream_cls=stream_cls) raise APIConnectionError(request=request) from err - if stream: - if stream_cls: - return stream_cls(cast_to=self._extract_stream_chunk_type(stream_cls), response=response, client=self) - - stream_cls = cast("type[_AsyncStreamT] | None", self._default_stream_cls) - if stream_cls is None: - raise MissingStreamClassError() - return stream_cls(cast_to=cast_to, response=response, client=self) - - return self._process_response(cast_to=cast_to, options=options, response=response) + return self._process_response( + cast_to=cast_to, + options=options, + response=response, + stream=stream, + stream_cls=stream_cls, + ) async def _retry_request( self, @@ -1560,6 +1508,7 @@ def make_request_options( extra_body: Body | None = None, idempotency_key: str | None = None, timeout: float | None | NotGiven = NOT_GIVEN, + post_parser: PostParser | NotGiven = NOT_GIVEN, ) -> RequestOptions: """Create a dict of type RequestOptions without keys of NotGiven values.""" options: RequestOptions = {} @@ -1581,6 +1530,10 @@ def make_request_options( if idempotency_key is not None: options["idempotency_key"] = idempotency_key + if is_given(post_parser): + # internal + options["post_parser"] = post_parser # type: ignore + return options diff --git a/src/modern_treasury/_client.py b/src/modern_treasury/_client.py index 16816a3b..a5004cea 100644 --- a/src/modern_treasury/_client.py +++ b/src/modern_treasury/_client.py @@ -27,6 +27,7 @@ ) from ._utils import is_given from ._version import __version__ +from ._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ._streaming import Stream as Stream from ._streaming import AsyncStream as AsyncStream from ._exceptions import APIStatusError, ModernTreasuryError @@ -84,6 +85,7 @@ class ModernTreasury(SyncAPIClient): paper_items: resources.PaperItems webhooks: resources.Webhooks virtual_accounts: resources.VirtualAccounts + with_raw_response: ModernTreasuryWithRawResponse # client options api_key: str @@ -197,6 +199,7 @@ def __init__( self.paper_items = resources.PaperItems(self) self.webhooks = resources.Webhooks(self) self.virtual_accounts = resources.VirtualAccounts(self) + self.with_raw_response = ModernTreasuryWithRawResponse(self) @property @override @@ -384,6 +387,7 @@ class AsyncModernTreasury(AsyncAPIClient): paper_items: resources.AsyncPaperItems webhooks: resources.AsyncWebhooks virtual_accounts: resources.AsyncVirtualAccounts + with_raw_response: AsyncModernTreasuryWithRawResponse # client options api_key: str @@ -497,6 +501,7 @@ def __init__( self.paper_items = resources.AsyncPaperItems(self) self.webhooks = resources.AsyncWebhooks(self) self.virtual_accounts = resources.AsyncVirtualAccounts(self) + self.with_raw_response = AsyncModernTreasuryWithRawResponse(self) @property @override @@ -654,6 +659,100 @@ def _make_status_error( return APIStatusError(err_msg, response=response, body=body) +class ModernTreasuryWithRawResponse: + def __init__(self, client: ModernTreasury) -> None: + self.connections = resources.ConnectionsWithRawResponse(client.connections) + self.counterparties = resources.CounterpartiesWithRawResponse(client.counterparties) + self.events = resources.EventsWithRawResponse(client.events) + self.expected_payments = resources.ExpectedPaymentsWithRawResponse(client.expected_payments) + self.external_accounts = resources.ExternalAccountsWithRawResponse(client.external_accounts) + self.incoming_payment_details = resources.IncomingPaymentDetailsWithRawResponse(client.incoming_payment_details) + self.invoices = resources.InvoicesWithRawResponse(client.invoices) + self.documents = resources.DocumentsWithRawResponse(client.documents) + self.account_collection_flows = resources.AccountCollectionFlowsWithRawResponse(client.account_collection_flows) + self.account_details = resources.AccountDetailsWithRawResponse(client.account_details) + self.routing_details = resources.RoutingDetailsWithRawResponse(client.routing_details) + self.internal_accounts = resources.InternalAccountsWithRawResponse(client.internal_accounts) + self.ledgers = resources.LedgersWithRawResponse(client.ledgers) + self.ledgerable_events = resources.LedgerableEventsWithRawResponse(client.ledgerable_events) + self.ledger_account_categories = resources.LedgerAccountCategoriesWithRawResponse( + client.ledger_account_categories + ) + self.ledger_accounts = resources.LedgerAccountsWithRawResponse(client.ledger_accounts) + self.ledger_account_balance_monitors = resources.LedgerAccountBalanceMonitorsWithRawResponse( + client.ledger_account_balance_monitors + ) + self.ledger_account_payouts = resources.LedgerAccountPayoutsWithRawResponse(client.ledger_account_payouts) + self.ledger_account_statements = resources.LedgerAccountStatementsWithRawResponse( + client.ledger_account_statements + ) + self.ledger_entries = resources.LedgerEntriesWithRawResponse(client.ledger_entries) + self.ledger_event_handlers = resources.LedgerEventHandlersWithRawResponse(client.ledger_event_handlers) + self.ledger_transactions = resources.LedgerTransactionsWithRawResponse(client.ledger_transactions) + self.line_items = resources.LineItemsWithRawResponse(client.line_items) + self.payment_flows = resources.PaymentFlowsWithRawResponse(client.payment_flows) + self.payment_orders = resources.PaymentOrdersWithRawResponse(client.payment_orders) + self.payment_references = resources.PaymentReferencesWithRawResponse(client.payment_references) + self.returns = resources.ReturnsWithRawResponse(client.returns) + self.transactions = resources.TransactionsWithRawResponse(client.transactions) + self.validations = resources.ValidationsWithRawResponse(client.validations) + self.paper_items = resources.PaperItemsWithRawResponse(client.paper_items) + self.virtual_accounts = resources.VirtualAccountsWithRawResponse(client.virtual_accounts) + + self.ping = to_raw_response_wrapper( + client.ping, + ) + + +class AsyncModernTreasuryWithRawResponse: + def __init__(self, client: AsyncModernTreasury) -> None: + self.connections = resources.AsyncConnectionsWithRawResponse(client.connections) + self.counterparties = resources.AsyncCounterpartiesWithRawResponse(client.counterparties) + self.events = resources.AsyncEventsWithRawResponse(client.events) + self.expected_payments = resources.AsyncExpectedPaymentsWithRawResponse(client.expected_payments) + self.external_accounts = resources.AsyncExternalAccountsWithRawResponse(client.external_accounts) + self.incoming_payment_details = resources.AsyncIncomingPaymentDetailsWithRawResponse( + client.incoming_payment_details + ) + self.invoices = resources.AsyncInvoicesWithRawResponse(client.invoices) + self.documents = resources.AsyncDocumentsWithRawResponse(client.documents) + self.account_collection_flows = resources.AsyncAccountCollectionFlowsWithRawResponse( + client.account_collection_flows + ) + self.account_details = resources.AsyncAccountDetailsWithRawResponse(client.account_details) + self.routing_details = resources.AsyncRoutingDetailsWithRawResponse(client.routing_details) + self.internal_accounts = resources.AsyncInternalAccountsWithRawResponse(client.internal_accounts) + self.ledgers = resources.AsyncLedgersWithRawResponse(client.ledgers) + self.ledgerable_events = resources.AsyncLedgerableEventsWithRawResponse(client.ledgerable_events) + self.ledger_account_categories = resources.AsyncLedgerAccountCategoriesWithRawResponse( + client.ledger_account_categories + ) + self.ledger_accounts = resources.AsyncLedgerAccountsWithRawResponse(client.ledger_accounts) + self.ledger_account_balance_monitors = resources.AsyncLedgerAccountBalanceMonitorsWithRawResponse( + client.ledger_account_balance_monitors + ) + self.ledger_account_payouts = resources.AsyncLedgerAccountPayoutsWithRawResponse(client.ledger_account_payouts) + self.ledger_account_statements = resources.AsyncLedgerAccountStatementsWithRawResponse( + client.ledger_account_statements + ) + self.ledger_entries = resources.AsyncLedgerEntriesWithRawResponse(client.ledger_entries) + self.ledger_event_handlers = resources.AsyncLedgerEventHandlersWithRawResponse(client.ledger_event_handlers) + self.ledger_transactions = resources.AsyncLedgerTransactionsWithRawResponse(client.ledger_transactions) + self.line_items = resources.AsyncLineItemsWithRawResponse(client.line_items) + self.payment_flows = resources.AsyncPaymentFlowsWithRawResponse(client.payment_flows) + self.payment_orders = resources.AsyncPaymentOrdersWithRawResponse(client.payment_orders) + self.payment_references = resources.AsyncPaymentReferencesWithRawResponse(client.payment_references) + self.returns = resources.AsyncReturnsWithRawResponse(client.returns) + self.transactions = resources.AsyncTransactionsWithRawResponse(client.transactions) + self.validations = resources.AsyncValidationsWithRawResponse(client.validations) + self.paper_items = resources.AsyncPaperItemsWithRawResponse(client.paper_items) + self.virtual_accounts = resources.AsyncVirtualAccountsWithRawResponse(client.virtual_accounts) + + self.ping = async_to_raw_response_wrapper( + client.ping, + ) + + Client = ModernTreasury AsyncClient = AsyncModernTreasury diff --git a/src/modern_treasury/_constants.py b/src/modern_treasury/_constants.py new file mode 100644 index 00000000..0c3f31df --- /dev/null +++ b/src/modern_treasury/_constants.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. + +import httpx + +RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response" + +# default timeout is 1 minute +DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0) +DEFAULT_MAX_RETRIES = 2 +DEFAULT_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20) diff --git a/src/modern_treasury/_models.py b/src/modern_treasury/_models.py index 7b0772e4..40245ac9 100644 --- a/src/modern_treasury/_models.py +++ b/src/modern_treasury/_models.py @@ -1,7 +1,7 @@ from __future__ import annotations import inspect -from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, cast +from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast from datetime import date, datetime from typing_extensions import ( Unpack, @@ -30,7 +30,14 @@ AnyMapping, HttpxRequestFiles, ) -from ._utils import is_list, is_mapping, parse_date, parse_datetime, strip_not_given +from ._utils import ( + is_list, + is_given, + is_mapping, + parse_date, + parse_datetime, + strip_not_given, +) from ._compat import PYDANTIC_V2, ConfigDict from ._compat import GenericModel as BaseGenericModel from ._compat import ( @@ -43,6 +50,7 @@ get_model_fields, field_get_default, ) +from ._constants import RAW_RESPONSE_HEADER __all__ = ["BaseModel", "GenericModel"] @@ -401,6 +409,7 @@ class FinalRequestOptions(pydantic.BaseModel): timeout: Union[float, Timeout, None, NotGiven] = NotGiven() files: Union[HttpxRequestFiles, None] = None idempotency_key: Union[str, None] = None + post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven() # It should be noted that we cannot use `json` here as that would override # a BaseModel method in an incompatible fashion. @@ -419,6 +428,14 @@ def get_max_retries(self, max_retries: int) -> int: return max_retries return self.max_retries + def _strip_raw_response_header(self) -> None: + if not is_given(self.headers): + return + + if self.headers.get(RAW_RESPONSE_HEADER): + self.headers = {**self.headers} + self.headers.pop(RAW_RESPONSE_HEADER) + # override the `construct` method so that we can run custom transformations. # this is necessary as we don't want to do any actual runtime type checking # (which means we can't use validators) but we do want to ensure that `NotGiven` diff --git a/src/modern_treasury/_response.py b/src/modern_treasury/_response.py new file mode 100644 index 00000000..04f4e997 --- /dev/null +++ b/src/modern_treasury/_response.py @@ -0,0 +1,249 @@ +from __future__ import annotations + +import inspect +import datetime +import functools +from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast +from typing_extensions import Awaitable, ParamSpec, get_args, override, get_origin + +import httpx +import pydantic + +from ._types import NoneType, UnknownResponse +from ._utils import is_given +from ._models import BaseModel +from ._constants import RAW_RESPONSE_HEADER +from ._exceptions import APIResponseValidationError + +if TYPE_CHECKING: + from ._models import FinalRequestOptions + from ._base_client import Stream, BaseClient, AsyncStream + + +P = ParamSpec("P") +R = TypeVar("R") + + +class APIResponse(Generic[R]): + _cast_to: type[R] + _client: BaseClient[Any, Any] + _parsed: R | None + _stream: bool + _stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None + _options: FinalRequestOptions + + http_response: httpx.Response + + def __init__( + self, + *, + raw: httpx.Response, + cast_to: type[R], + client: BaseClient[Any, Any], + stream: bool, + stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, + options: FinalRequestOptions, + ) -> None: + self._cast_to = cast_to + self._client = client + self._parsed = None + self._stream = stream + self._stream_cls = stream_cls + self._options = options + self.http_response = raw + + def parse(self) -> R: + if self._parsed is not None: + return self._parsed + + parsed = self._parse() + if is_given(self._options.post_parser): + parsed = self._options.post_parser(parsed) + + self._parsed = parsed + return parsed + + @property + def headers(self) -> httpx.Headers: + return self.http_response.headers + + @property + def http_request(self) -> httpx.Request: + return self.http_response.request + + @property + def status_code(self) -> int: + return self.http_response.status_code + + @property + def url(self) -> httpx.URL: + return self.http_response.url + + @property + def method(self) -> str: + return self.http_request.method + + @property + def content(self) -> bytes: + return self.http_response.content + + @property + def text(self) -> str: + return self.http_response.text + + @property + def http_version(self) -> str: + return self.http_response.http_version + + @property + def elapsed(self) -> datetime.timedelta: + """The time taken for the complete request/response cycle to complete.""" + return self.http_response.elapsed + + def _parse(self) -> R: + if self._stream: + if self._stream_cls: + return cast( + R, + self._stream_cls( + cast_to=_extract_stream_chunk_type(self._stream_cls), + response=self.http_response, + client=cast(Any, self._client), + ), + ) + + stream_cls = cast("type[Stream[Any]] | type[AsyncStream[Any]] | None", self._client._default_stream_cls) + if stream_cls is None: + raise MissingStreamClassError() + + return cast( + R, + stream_cls( + cast_to=self._cast_to, + response=self.http_response, + client=cast(Any, self._client), + ), + ) + + cast_to = self._cast_to + if cast_to is NoneType: + return cast(R, None) + + response = self.http_response + if cast_to == str: + return cast(R, response.text) + + origin = get_origin(cast_to) or cast_to + + if origin == APIResponse: + raise RuntimeError("Unexpected state - cast_to is `APIResponse`") + + if inspect.isclass(origin) and issubclass(origin, httpx.Response): + # Because of the invariance of our ResponseT TypeVar, users can subclass httpx.Response + # and pass that class to our request functions. We cannot change the variance to be either + # covariant or contravariant as that makes our usage of ResponseT illegal. We could construct + # the response class ourselves but that is something that should be supported directly in httpx + # as it would be easy to incorrectly construct the Response object due to the multitude of arguments. + if cast_to != httpx.Response: + raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`") + return cast(R, response) + + # The check here is necessary as we are subverting the the type system + # with casts as the relationship between TypeVars and Types are very strict + # which means we must return *exactly* what was input or transform it in a + # way that retains the TypeVar state. As we cannot do that in this function + # then we have to resort to using `cast`. At the time of writing, we know this + # to be safe as we have handled all the types that could be bound to the + # `ResponseT` TypeVar, however if that TypeVar is ever updated in the future, then + # this function would become unsafe but a type checker would not report an error. + if ( + cast_to is not UnknownResponse + and not origin is list + and not origin is dict + and not origin is Union + and not issubclass(origin, BaseModel) + ): + raise RuntimeError( + f"Invalid state, expected {cast_to} to be a subclass type of {BaseModel}, {dict}, {list} or {Union}." + ) + + # split is required to handle cases where additional information is included + # in the response, e.g. application/json; charset=utf-8 + content_type, *_ = response.headers.get("content-type").split(";") + if content_type != "application/json": + if self._client._strict_response_validation: + raise APIResponseValidationError( + response=response, + message=f"Expected Content-Type response header to be `application/json` but received `{content_type}` instead.", + body=response.text, + ) + + # If the API responds with content that isn't JSON then we just return + # the (decoded) text without performing any parsing so that you can still + # handle the response however you need to. + return response.text # type: ignore + + data = response.json() + + try: + return self._client._process_response_data( + data=data, + cast_to=cast_to, # type: ignore + response=response, + ) + except pydantic.ValidationError as err: + raise APIResponseValidationError(response=response, body=data) from err + + @override + def __repr__(self) -> str: + return f"" + + +class MissingStreamClassError(TypeError): + def __init__(self) -> None: + super().__init__( + "The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `modern_treasury._streaming` for reference", + ) + + +def _extract_stream_chunk_type(stream_cls: type) -> type: + args = get_args(stream_cls) + if not args: + raise TypeError( + f"Expected stream_cls to have been given a generic type argument, e.g. Stream[Foo] but received {stream_cls}", + ) + return cast(type, args[0]) + + +def to_raw_response_wrapper(func: Callable[P, R]) -> Callable[P, APIResponse[R]]: + """Higher order function that takes one of our bound API methods and wraps it + to support returning the raw `APIResponse` object directly. + """ + + @functools.wraps(func) + def wrapped(*args: P.args, **kwargs: P.kwargs) -> APIResponse[R]: + extra_headers = {**(cast(Any, kwargs.get("extra_headers")) or {})} + extra_headers[RAW_RESPONSE_HEADER] = "true" + + kwargs["extra_headers"] = extra_headers + + return cast(APIResponse[R], func(*args, **kwargs)) + + return wrapped + + +def async_to_raw_response_wrapper(func: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[APIResponse[R]]]: + """Higher order function that takes one of our bound API methods and wraps it + to support returning the raw `APIResponse` object directly. + """ + + @functools.wraps(func) + async def wrapped(*args: P.args, **kwargs: P.kwargs) -> APIResponse[R]: + extra_headers = {**(cast(Any, kwargs.get("extra_headers")) or {})} + extra_headers[RAW_RESPONSE_HEADER] = "true" + + kwargs["extra_headers"] = extra_headers + + return cast(APIResponse[R], await func(*args, **kwargs)) + + return wrapped diff --git a/src/modern_treasury/_types.py b/src/modern_treasury/_types.py index 409a970f..b3205081 100644 --- a/src/modern_treasury/_types.py +++ b/src/modern_treasury/_types.py @@ -12,6 +12,7 @@ Union, Mapping, TypeVar, + Callable, Optional, Sequence, ) @@ -188,3 +189,5 @@ def get(self, __key: str) -> str | None: # Note: copied from Pydantic # https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49 IncEx: TypeAlias = "set[int] | set[str] | dict[int, Any] | dict[str, Any] | None" + +PostParser = Callable[[Any], Any] diff --git a/src/modern_treasury/resources/__init__.py b/src/modern_treasury/resources/__init__.py index 9cc97e50..69d5a3b7 100644 --- a/src/modern_treasury/resources/__init__.py +++ b/src/modern_treasury/resources/__init__.py @@ -1,116 +1,318 @@ # File generated from our OpenAPI spec by Stainless. -from .events import Events, AsyncEvents -from .ledgers import Ledgers, AsyncLedgers -from .returns import Returns, AsyncReturns -from .invoices import Invoices, AsyncInvoices +from .events import ( + Events, + AsyncEvents, + EventsWithRawResponse, + AsyncEventsWithRawResponse, +) +from .ledgers import ( + Ledgers, + AsyncLedgers, + LedgersWithRawResponse, + AsyncLedgersWithRawResponse, +) +from .returns import ( + Returns, + AsyncReturns, + ReturnsWithRawResponse, + AsyncReturnsWithRawResponse, +) +from .invoices import ( + Invoices, + AsyncInvoices, + InvoicesWithRawResponse, + AsyncInvoicesWithRawResponse, +) from .webhooks import Webhooks, AsyncWebhooks -from .documents import Documents, AsyncDocuments -from .line_items import LineItems, AsyncLineItems -from .connections import Connections, AsyncConnections -from .paper_items import PaperItems, AsyncPaperItems -from .validations import Validations, AsyncValidations -from .transactions import Transactions, AsyncTransactions -from .payment_flows import PaymentFlows, AsyncPaymentFlows -from .counterparties import Counterparties, AsyncCounterparties -from .ledger_entries import LedgerEntries, AsyncLedgerEntries -from .payment_orders import PaymentOrders, AsyncPaymentOrders -from .account_details import AccountDetails, AsyncAccountDetails -from .ledger_accounts import LedgerAccounts, AsyncLedgerAccounts -from .routing_details import RoutingDetails, AsyncRoutingDetails -from .virtual_accounts import VirtualAccounts, AsyncVirtualAccounts -from .expected_payments import ExpectedPayments, AsyncExpectedPayments -from .external_accounts import ExternalAccounts, AsyncExternalAccounts -from .internal_accounts import InternalAccounts, AsyncInternalAccounts -from .ledgerable_events import LedgerableEvents, AsyncLedgerableEvents -from .payment_references import PaymentReferences, AsyncPaymentReferences -from .ledger_transactions import LedgerTransactions, AsyncLedgerTransactions -from .ledger_event_handlers import LedgerEventHandlers, AsyncLedgerEventHandlers -from .ledger_account_payouts import LedgerAccountPayouts, AsyncLedgerAccountPayouts +from .documents import ( + Documents, + AsyncDocuments, + DocumentsWithRawResponse, + AsyncDocumentsWithRawResponse, +) +from .line_items import ( + LineItems, + AsyncLineItems, + LineItemsWithRawResponse, + AsyncLineItemsWithRawResponse, +) +from .connections import ( + Connections, + AsyncConnections, + ConnectionsWithRawResponse, + AsyncConnectionsWithRawResponse, +) +from .paper_items import ( + PaperItems, + AsyncPaperItems, + PaperItemsWithRawResponse, + AsyncPaperItemsWithRawResponse, +) +from .validations import ( + Validations, + AsyncValidations, + ValidationsWithRawResponse, + AsyncValidationsWithRawResponse, +) +from .transactions import ( + Transactions, + AsyncTransactions, + TransactionsWithRawResponse, + AsyncTransactionsWithRawResponse, +) +from .payment_flows import ( + PaymentFlows, + AsyncPaymentFlows, + PaymentFlowsWithRawResponse, + AsyncPaymentFlowsWithRawResponse, +) +from .counterparties import ( + Counterparties, + AsyncCounterparties, + CounterpartiesWithRawResponse, + AsyncCounterpartiesWithRawResponse, +) +from .ledger_entries import ( + LedgerEntries, + AsyncLedgerEntries, + LedgerEntriesWithRawResponse, + AsyncLedgerEntriesWithRawResponse, +) +from .payment_orders import ( + PaymentOrders, + AsyncPaymentOrders, + PaymentOrdersWithRawResponse, + AsyncPaymentOrdersWithRawResponse, +) +from .account_details import ( + AccountDetails, + AsyncAccountDetails, + AccountDetailsWithRawResponse, + AsyncAccountDetailsWithRawResponse, +) +from .ledger_accounts import ( + LedgerAccounts, + AsyncLedgerAccounts, + LedgerAccountsWithRawResponse, + AsyncLedgerAccountsWithRawResponse, +) +from .routing_details import ( + RoutingDetails, + AsyncRoutingDetails, + RoutingDetailsWithRawResponse, + AsyncRoutingDetailsWithRawResponse, +) +from .virtual_accounts import ( + VirtualAccounts, + AsyncVirtualAccounts, + VirtualAccountsWithRawResponse, + AsyncVirtualAccountsWithRawResponse, +) +from .expected_payments import ( + ExpectedPayments, + AsyncExpectedPayments, + ExpectedPaymentsWithRawResponse, + AsyncExpectedPaymentsWithRawResponse, +) +from .external_accounts import ( + ExternalAccounts, + AsyncExternalAccounts, + ExternalAccountsWithRawResponse, + AsyncExternalAccountsWithRawResponse, +) +from .internal_accounts import ( + InternalAccounts, + AsyncInternalAccounts, + InternalAccountsWithRawResponse, + AsyncInternalAccountsWithRawResponse, +) +from .ledgerable_events import ( + LedgerableEvents, + AsyncLedgerableEvents, + LedgerableEventsWithRawResponse, + AsyncLedgerableEventsWithRawResponse, +) +from .payment_references import ( + PaymentReferences, + AsyncPaymentReferences, + PaymentReferencesWithRawResponse, + AsyncPaymentReferencesWithRawResponse, +) +from .ledger_transactions import ( + LedgerTransactions, + AsyncLedgerTransactions, + LedgerTransactionsWithRawResponse, + AsyncLedgerTransactionsWithRawResponse, +) +from .ledger_event_handlers import ( + LedgerEventHandlers, + AsyncLedgerEventHandlers, + LedgerEventHandlersWithRawResponse, + AsyncLedgerEventHandlersWithRawResponse, +) +from .ledger_account_payouts import ( + LedgerAccountPayouts, + AsyncLedgerAccountPayouts, + LedgerAccountPayoutsWithRawResponse, + AsyncLedgerAccountPayoutsWithRawResponse, +) from .account_collection_flows import ( AccountCollectionFlows, AsyncAccountCollectionFlows, + AccountCollectionFlowsWithRawResponse, + AsyncAccountCollectionFlowsWithRawResponse, ) from .incoming_payment_details import ( IncomingPaymentDetails, AsyncIncomingPaymentDetails, + IncomingPaymentDetailsWithRawResponse, + AsyncIncomingPaymentDetailsWithRawResponse, ) from .ledger_account_categories import ( LedgerAccountCategories, AsyncLedgerAccountCategories, + LedgerAccountCategoriesWithRawResponse, + AsyncLedgerAccountCategoriesWithRawResponse, ) from .ledger_account_statements import ( LedgerAccountStatements, AsyncLedgerAccountStatements, + LedgerAccountStatementsWithRawResponse, + AsyncLedgerAccountStatementsWithRawResponse, ) from .ledger_account_balance_monitors import ( LedgerAccountBalanceMonitors, AsyncLedgerAccountBalanceMonitors, + LedgerAccountBalanceMonitorsWithRawResponse, + AsyncLedgerAccountBalanceMonitorsWithRawResponse, ) __all__ = [ "Connections", "AsyncConnections", + "ConnectionsWithRawResponse", + "AsyncConnectionsWithRawResponse", "Counterparties", "AsyncCounterparties", + "CounterpartiesWithRawResponse", + "AsyncCounterpartiesWithRawResponse", "Events", "AsyncEvents", + "EventsWithRawResponse", + "AsyncEventsWithRawResponse", "ExpectedPayments", "AsyncExpectedPayments", + "ExpectedPaymentsWithRawResponse", + "AsyncExpectedPaymentsWithRawResponse", "ExternalAccounts", "AsyncExternalAccounts", + "ExternalAccountsWithRawResponse", + "AsyncExternalAccountsWithRawResponse", "IncomingPaymentDetails", "AsyncIncomingPaymentDetails", + "IncomingPaymentDetailsWithRawResponse", + "AsyncIncomingPaymentDetailsWithRawResponse", "Invoices", "AsyncInvoices", + "InvoicesWithRawResponse", + "AsyncInvoicesWithRawResponse", "Documents", "AsyncDocuments", + "DocumentsWithRawResponse", + "AsyncDocumentsWithRawResponse", "AccountCollectionFlows", "AsyncAccountCollectionFlows", + "AccountCollectionFlowsWithRawResponse", + "AsyncAccountCollectionFlowsWithRawResponse", "AccountDetails", "AsyncAccountDetails", + "AccountDetailsWithRawResponse", + "AsyncAccountDetailsWithRawResponse", "RoutingDetails", "AsyncRoutingDetails", + "RoutingDetailsWithRawResponse", + "AsyncRoutingDetailsWithRawResponse", "InternalAccounts", "AsyncInternalAccounts", + "InternalAccountsWithRawResponse", + "AsyncInternalAccountsWithRawResponse", "Ledgers", "AsyncLedgers", + "LedgersWithRawResponse", + "AsyncLedgersWithRawResponse", "LedgerableEvents", "AsyncLedgerableEvents", + "LedgerableEventsWithRawResponse", + "AsyncLedgerableEventsWithRawResponse", "LedgerAccountCategories", "AsyncLedgerAccountCategories", + "LedgerAccountCategoriesWithRawResponse", + "AsyncLedgerAccountCategoriesWithRawResponse", "LedgerAccounts", "AsyncLedgerAccounts", + "LedgerAccountsWithRawResponse", + "AsyncLedgerAccountsWithRawResponse", "LedgerAccountBalanceMonitors", "AsyncLedgerAccountBalanceMonitors", + "LedgerAccountBalanceMonitorsWithRawResponse", + "AsyncLedgerAccountBalanceMonitorsWithRawResponse", "LedgerAccountPayouts", "AsyncLedgerAccountPayouts", + "LedgerAccountPayoutsWithRawResponse", + "AsyncLedgerAccountPayoutsWithRawResponse", "LedgerAccountStatements", "AsyncLedgerAccountStatements", + "LedgerAccountStatementsWithRawResponse", + "AsyncLedgerAccountStatementsWithRawResponse", "LedgerEntries", "AsyncLedgerEntries", + "LedgerEntriesWithRawResponse", + "AsyncLedgerEntriesWithRawResponse", "LedgerEventHandlers", "AsyncLedgerEventHandlers", + "LedgerEventHandlersWithRawResponse", + "AsyncLedgerEventHandlersWithRawResponse", "LedgerTransactions", "AsyncLedgerTransactions", + "LedgerTransactionsWithRawResponse", + "AsyncLedgerTransactionsWithRawResponse", "LineItems", "AsyncLineItems", + "LineItemsWithRawResponse", + "AsyncLineItemsWithRawResponse", "PaymentFlows", "AsyncPaymentFlows", + "PaymentFlowsWithRawResponse", + "AsyncPaymentFlowsWithRawResponse", "PaymentOrders", "AsyncPaymentOrders", + "PaymentOrdersWithRawResponse", + "AsyncPaymentOrdersWithRawResponse", "PaymentReferences", "AsyncPaymentReferences", + "PaymentReferencesWithRawResponse", + "AsyncPaymentReferencesWithRawResponse", "Returns", "AsyncReturns", + "ReturnsWithRawResponse", + "AsyncReturnsWithRawResponse", "Transactions", "AsyncTransactions", + "TransactionsWithRawResponse", + "AsyncTransactionsWithRawResponse", "Validations", "AsyncValidations", + "ValidationsWithRawResponse", + "AsyncValidationsWithRawResponse", "PaperItems", "AsyncPaperItems", + "PaperItemsWithRawResponse", + "AsyncPaperItemsWithRawResponse", "Webhooks", "AsyncWebhooks", "VirtualAccounts", "AsyncVirtualAccounts", + "VirtualAccountsWithRawResponse", + "AsyncVirtualAccountsWithRawResponse", ] diff --git a/src/modern_treasury/resources/account_collection_flows.py b/src/modern_treasury/resources/account_collection_flows.py index 326a4767..c56f3775 100644 --- a/src/modern_treasury/resources/account_collection_flows.py +++ b/src/modern_treasury/resources/account_collection_flows.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Optional +from typing import TYPE_CHECKING, List, Optional from typing_extensions import Literal from ..types import ( @@ -14,13 +14,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["AccountCollectionFlows", "AsyncAccountCollectionFlows"] class AccountCollectionFlows(SyncAPIResource): + with_raw_response: AccountCollectionFlowsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AccountCollectionFlowsWithRawResponse(self) + def create( self, *, @@ -223,6 +233,12 @@ def list( class AsyncAccountCollectionFlows(AsyncAPIResource): + with_raw_response: AsyncAccountCollectionFlowsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncAccountCollectionFlowsWithRawResponse(self) + async def create( self, *, @@ -422,3 +438,35 @@ def list( ), model=AccountCollectionFlow, ) + + +class AccountCollectionFlowsWithRawResponse: + def __init__(self, account_collection_flows: AccountCollectionFlows) -> None: + self.create = to_raw_response_wrapper( + account_collection_flows.create, + ) + self.retrieve = to_raw_response_wrapper( + account_collection_flows.retrieve, + ) + self.update = to_raw_response_wrapper( + account_collection_flows.update, + ) + self.list = to_raw_response_wrapper( + account_collection_flows.list, + ) + + +class AsyncAccountCollectionFlowsWithRawResponse: + def __init__(self, account_collection_flows: AsyncAccountCollectionFlows) -> None: + self.create = async_to_raw_response_wrapper( + account_collection_flows.create, + ) + self.retrieve = async_to_raw_response_wrapper( + account_collection_flows.retrieve, + ) + self.update = async_to_raw_response_wrapper( + account_collection_flows.update, + ) + self.list = async_to_raw_response_wrapper( + account_collection_flows.list, + ) diff --git a/src/modern_treasury/resources/account_details.py b/src/modern_treasury/resources/account_details.py index fe7c2aef..135adc92 100644 --- a/src/modern_treasury/resources/account_details.py +++ b/src/modern_treasury/resources/account_details.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import TYPE_CHECKING, Optional from typing_extensions import Literal from ..types import ( @@ -13,14 +13,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import AccountsType +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["AccountDetails", "AsyncAccountDetails"] class AccountDetails(SyncAPIResource): + with_raw_response: AccountDetailsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AccountDetailsWithRawResponse(self) + def create( self, account_id: str, @@ -195,6 +205,12 @@ def delete( class AsyncAccountDetails(AsyncAPIResource): + with_raw_response: AsyncAccountDetailsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncAccountDetailsWithRawResponse(self) + async def create( self, account_id: str, @@ -366,3 +382,35 @@ async def delete( ), cast_to=NoneType, ) + + +class AccountDetailsWithRawResponse: + def __init__(self, account_details: AccountDetails) -> None: + self.create = to_raw_response_wrapper( + account_details.create, + ) + self.retrieve = to_raw_response_wrapper( + account_details.retrieve, + ) + self.list = to_raw_response_wrapper( + account_details.list, + ) + self.delete = to_raw_response_wrapper( + account_details.delete, + ) + + +class AsyncAccountDetailsWithRawResponse: + def __init__(self, account_details: AsyncAccountDetails) -> None: + self.create = async_to_raw_response_wrapper( + account_details.create, + ) + self.retrieve = async_to_raw_response_wrapper( + account_details.retrieve, + ) + self.list = async_to_raw_response_wrapper( + account_details.list, + ) + self.delete = async_to_raw_response_wrapper( + account_details.delete, + ) diff --git a/src/modern_treasury/resources/connections.py b/src/modern_treasury/resources/connections.py index 5a6cf047..a654f07e 100644 --- a/src/modern_treasury/resources/connections.py +++ b/src/modern_treasury/resources/connections.py @@ -2,19 +2,29 @@ from __future__ import annotations -from typing import Optional +from typing import TYPE_CHECKING, Optional from ..types import Connection, connection_list_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Connections", "AsyncConnections"] class Connections(SyncAPIResource): + with_raw_response: ConnectionsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = ConnectionsWithRawResponse(self) + def list( self, *, @@ -68,6 +78,12 @@ def list( class AsyncConnections(AsyncAPIResource): + with_raw_response: AsyncConnectionsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncConnectionsWithRawResponse(self) + def list( self, *, @@ -118,3 +134,17 @@ def list( ), model=Connection, ) + + +class ConnectionsWithRawResponse: + def __init__(self, connections: Connections) -> None: + self.list = to_raw_response_wrapper( + connections.list, + ) + + +class AsyncConnectionsWithRawResponse: + def __init__(self, connections: AsyncConnections) -> None: + self.list = async_to_raw_response_wrapper( + connections.list, + ) diff --git a/src/modern_treasury/resources/counterparties.py b/src/modern_treasury/resources/counterparties.py index e04b01d6..02d8a269 100644 --- a/src/modern_treasury/resources/counterparties.py +++ b/src/modern_treasury/resources/counterparties.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Union, Optional +from typing import TYPE_CHECKING, Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal @@ -17,14 +17,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import TransactionDirection +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Counterparties", "AsyncCounterparties"] class Counterparties(SyncAPIResource): + with_raw_response: CounterpartiesWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = CounterpartiesWithRawResponse(self) + def create( self, *, @@ -406,6 +416,12 @@ def collect_account( class AsyncCounterparties(AsyncAPIResource): + with_raw_response: AsyncCounterpartiesWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncCounterpartiesWithRawResponse(self) + async def create( self, *, @@ -784,3 +800,47 @@ async def collect_account( ), cast_to=CounterpartyCollectAccountResponse, ) + + +class CounterpartiesWithRawResponse: + def __init__(self, counterparties: Counterparties) -> None: + self.create = to_raw_response_wrapper( + counterparties.create, + ) + self.retrieve = to_raw_response_wrapper( + counterparties.retrieve, + ) + self.update = to_raw_response_wrapper( + counterparties.update, + ) + self.list = to_raw_response_wrapper( + counterparties.list, + ) + self.delete = to_raw_response_wrapper( + counterparties.delete, + ) + self.collect_account = to_raw_response_wrapper( + counterparties.collect_account, + ) + + +class AsyncCounterpartiesWithRawResponse: + def __init__(self, counterparties: AsyncCounterparties) -> None: + self.create = async_to_raw_response_wrapper( + counterparties.create, + ) + self.retrieve = async_to_raw_response_wrapper( + counterparties.retrieve, + ) + self.update = async_to_raw_response_wrapper( + counterparties.update, + ) + self.list = async_to_raw_response_wrapper( + counterparties.list, + ) + self.delete = async_to_raw_response_wrapper( + counterparties.delete, + ) + self.collect_account = async_to_raw_response_wrapper( + counterparties.collect_account, + ) diff --git a/src/modern_treasury/resources/documents.py b/src/modern_treasury/resources/documents.py index 7f415247..7d06b2e7 100644 --- a/src/modern_treasury/resources/documents.py +++ b/src/modern_treasury/resources/documents.py @@ -2,20 +2,30 @@ from __future__ import annotations -from typing import Mapping, Optional, cast +from typing import TYPE_CHECKING, Mapping, Optional, cast from typing_extensions import Literal from ..types import Document, document_list_params, document_create_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes from .._utils import extract_files, maybe_transform, deepcopy_minimal from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Documents", "AsyncDocuments"] class Documents(SyncAPIResource): + with_raw_response: DocumentsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = DocumentsWithRawResponse(self) + def create( self, *, @@ -191,6 +201,12 @@ def list( class AsyncDocuments(AsyncAPIResource): + with_raw_response: AsyncDocumentsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncDocumentsWithRawResponse(self) + async def create( self, *, @@ -363,3 +379,29 @@ def list( ), model=Document, ) + + +class DocumentsWithRawResponse: + def __init__(self, documents: Documents) -> None: + self.create = to_raw_response_wrapper( + documents.create, + ) + self.retrieve = to_raw_response_wrapper( + documents.retrieve, + ) + self.list = to_raw_response_wrapper( + documents.list, + ) + + +class AsyncDocumentsWithRawResponse: + def __init__(self, documents: AsyncDocuments) -> None: + self.create = async_to_raw_response_wrapper( + documents.create, + ) + self.retrieve = async_to_raw_response_wrapper( + documents.retrieve, + ) + self.list = async_to_raw_response_wrapper( + documents.list, + ) diff --git a/src/modern_treasury/resources/events.py b/src/modern_treasury/resources/events.py index 4d740632..e81142cb 100644 --- a/src/modern_treasury/resources/events.py +++ b/src/modern_treasury/resources/events.py @@ -2,20 +2,30 @@ from __future__ import annotations -from typing import Union, Optional +from typing import TYPE_CHECKING, Union, Optional from datetime import datetime from ..types import Event, event_list_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Events", "AsyncEvents"] class Events(SyncAPIResource): + with_raw_response: EventsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = EventsWithRawResponse(self) + def retrieve( self, id: str, @@ -106,6 +116,12 @@ def list( class AsyncEvents(AsyncAPIResource): + with_raw_response: AsyncEventsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncEventsWithRawResponse(self) + async def retrieve( self, id: str, @@ -193,3 +209,23 @@ def list( ), model=Event, ) + + +class EventsWithRawResponse: + def __init__(self, events: Events) -> None: + self.retrieve = to_raw_response_wrapper( + events.retrieve, + ) + self.list = to_raw_response_wrapper( + events.list, + ) + + +class AsyncEventsWithRawResponse: + def __init__(self, events: AsyncEvents) -> None: + self.retrieve = async_to_raw_response_wrapper( + events.retrieve, + ) + self.list = async_to_raw_response_wrapper( + events.list, + ) diff --git a/src/modern_treasury/resources/expected_payments.py b/src/modern_treasury/resources/expected_payments.py index 1727fce4..198c2d0e 100644 --- a/src/modern_treasury/resources/expected_payments.py +++ b/src/modern_treasury/resources/expected_payments.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Union, Optional +from typing import TYPE_CHECKING, Dict, List, Union, Optional from datetime import date, datetime from typing_extensions import Literal @@ -16,14 +16,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import Currency, TransactionDirection +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["ExpectedPayments", "AsyncExpectedPayments"] class ExpectedPayments(SyncAPIResource): + with_raw_response: ExpectedPaymentsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = ExpectedPaymentsWithRawResponse(self) + def create( self, *, @@ -434,6 +444,12 @@ def delete( class AsyncExpectedPayments(AsyncAPIResource): + with_raw_response: AsyncExpectedPaymentsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncExpectedPaymentsWithRawResponse(self) + async def create( self, *, @@ -841,3 +857,41 @@ async def delete( ), cast_to=ExpectedPayment, ) + + +class ExpectedPaymentsWithRawResponse: + def __init__(self, expected_payments: ExpectedPayments) -> None: + self.create = to_raw_response_wrapper( + expected_payments.create, + ) + self.retrieve = to_raw_response_wrapper( + expected_payments.retrieve, + ) + self.update = to_raw_response_wrapper( + expected_payments.update, + ) + self.list = to_raw_response_wrapper( + expected_payments.list, + ) + self.delete = to_raw_response_wrapper( + expected_payments.delete, + ) + + +class AsyncExpectedPaymentsWithRawResponse: + def __init__(self, expected_payments: AsyncExpectedPayments) -> None: + self.create = async_to_raw_response_wrapper( + expected_payments.create, + ) + self.retrieve = async_to_raw_response_wrapper( + expected_payments.retrieve, + ) + self.update = async_to_raw_response_wrapper( + expected_payments.update, + ) + self.list = async_to_raw_response_wrapper( + expected_payments.list, + ) + self.delete = async_to_raw_response_wrapper( + expected_payments.delete, + ) diff --git a/src/modern_treasury/resources/external_accounts.py b/src/modern_treasury/resources/external_accounts.py index df3cb5f0..debb1e19 100644 --- a/src/modern_treasury/resources/external_accounts.py +++ b/src/modern_treasury/resources/external_accounts.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Optional +from typing import TYPE_CHECKING, Dict, List, Optional from typing_extensions import Literal from ..types import ( @@ -17,14 +17,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import Currency +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["ExternalAccounts", "AsyncExternalAccounts"] class ExternalAccounts(SyncAPIResource): + with_raw_response: ExternalAccountsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = ExternalAccountsWithRawResponse(self) + def create( self, *, @@ -436,6 +446,12 @@ def verify( class AsyncExternalAccounts(AsyncAPIResource): + with_raw_response: AsyncExternalAccountsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncExternalAccountsWithRawResponse(self) + async def create( self, *, @@ -844,3 +860,53 @@ async def verify( ), cast_to=ExternalAccount, ) + + +class ExternalAccountsWithRawResponse: + def __init__(self, external_accounts: ExternalAccounts) -> None: + self.create = to_raw_response_wrapper( + external_accounts.create, + ) + self.retrieve = to_raw_response_wrapper( + external_accounts.retrieve, + ) + self.update = to_raw_response_wrapper( + external_accounts.update, + ) + self.list = to_raw_response_wrapper( + external_accounts.list, + ) + self.delete = to_raw_response_wrapper( + external_accounts.delete, + ) + self.complete_verification = to_raw_response_wrapper( + external_accounts.complete_verification, + ) + self.verify = to_raw_response_wrapper( + external_accounts.verify, + ) + + +class AsyncExternalAccountsWithRawResponse: + def __init__(self, external_accounts: AsyncExternalAccounts) -> None: + self.create = async_to_raw_response_wrapper( + external_accounts.create, + ) + self.retrieve = async_to_raw_response_wrapper( + external_accounts.retrieve, + ) + self.update = async_to_raw_response_wrapper( + external_accounts.update, + ) + self.list = async_to_raw_response_wrapper( + external_accounts.list, + ) + self.delete = async_to_raw_response_wrapper( + external_accounts.delete, + ) + self.complete_verification = async_to_raw_response_wrapper( + external_accounts.complete_verification, + ) + self.verify = async_to_raw_response_wrapper( + external_accounts.verify, + ) diff --git a/src/modern_treasury/resources/incoming_payment_details.py b/src/modern_treasury/resources/incoming_payment_details.py index d7a54e0b..75efe1e6 100644 --- a/src/modern_treasury/resources/incoming_payment_details.py +++ b/src/modern_treasury/resources/incoming_payment_details.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Union, Optional +from typing import TYPE_CHECKING, Dict, Union, Optional from datetime import date from typing_extensions import Literal @@ -15,14 +15,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import Currency, AsyncResponse, TransactionDirection +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["IncomingPaymentDetails", "AsyncIncomingPaymentDetails"] class IncomingPaymentDetails(SyncAPIResource): + with_raw_response: IncomingPaymentDetailsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = IncomingPaymentDetailsWithRawResponse(self) + def retrieve( self, id: str, @@ -255,6 +265,12 @@ def create_async( class AsyncIncomingPaymentDetails(AsyncAPIResource): + with_raw_response: AsyncIncomingPaymentDetailsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncIncomingPaymentDetailsWithRawResponse(self) + async def retrieve( self, id: str, @@ -484,3 +500,35 @@ async def create_async( ), cast_to=AsyncResponse, ) + + +class IncomingPaymentDetailsWithRawResponse: + def __init__(self, incoming_payment_details: IncomingPaymentDetails) -> None: + self.retrieve = to_raw_response_wrapper( + incoming_payment_details.retrieve, + ) + self.update = to_raw_response_wrapper( + incoming_payment_details.update, + ) + self.list = to_raw_response_wrapper( + incoming_payment_details.list, + ) + self.create_async = to_raw_response_wrapper( + incoming_payment_details.create_async, + ) + + +class AsyncIncomingPaymentDetailsWithRawResponse: + def __init__(self, incoming_payment_details: AsyncIncomingPaymentDetails) -> None: + self.retrieve = async_to_raw_response_wrapper( + incoming_payment_details.retrieve, + ) + self.update = async_to_raw_response_wrapper( + incoming_payment_details.update, + ) + self.list = async_to_raw_response_wrapper( + incoming_payment_details.list, + ) + self.create_async = async_to_raw_response_wrapper( + incoming_payment_details.create_async, + ) diff --git a/src/modern_treasury/resources/internal_accounts/__init__.py b/src/modern_treasury/resources/internal_accounts/__init__.py index 38cc1002..d829ddba 100644 --- a/src/modern_treasury/resources/internal_accounts/__init__.py +++ b/src/modern_treasury/resources/internal_accounts/__init__.py @@ -1,6 +1,25 @@ # File generated from our OpenAPI spec by Stainless. -from .balance_reports import BalanceReports, AsyncBalanceReports -from .internal_accounts import InternalAccounts, AsyncInternalAccounts +from .balance_reports import ( + BalanceReports, + AsyncBalanceReports, + BalanceReportsWithRawResponse, + AsyncBalanceReportsWithRawResponse, +) +from .internal_accounts import ( + InternalAccounts, + AsyncInternalAccounts, + InternalAccountsWithRawResponse, + AsyncInternalAccountsWithRawResponse, +) -__all__ = ["BalanceReports", "AsyncBalanceReports", "InternalAccounts", "AsyncInternalAccounts"] +__all__ = [ + "BalanceReports", + "AsyncBalanceReports", + "BalanceReportsWithRawResponse", + "AsyncBalanceReportsWithRawResponse", + "InternalAccounts", + "AsyncInternalAccounts", + "InternalAccountsWithRawResponse", + "AsyncInternalAccountsWithRawResponse", +] diff --git a/src/modern_treasury/resources/internal_accounts/balance_reports.py b/src/modern_treasury/resources/internal_accounts/balance_reports.py index ea57a0dd..fbe8715f 100644 --- a/src/modern_treasury/resources/internal_accounts/balance_reports.py +++ b/src/modern_treasury/resources/internal_accounts/balance_reports.py @@ -2,21 +2,31 @@ from __future__ import annotations -from typing import Union, Optional +from typing import TYPE_CHECKING, Union, Optional from datetime import date from typing_extensions import Literal from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.internal_accounts import BalanceReport, balance_report_list_params +if TYPE_CHECKING: + from ..._client import ModernTreasury, AsyncModernTreasury + __all__ = ["BalanceReports", "AsyncBalanceReports"] class BalanceReports(SyncAPIResource): + with_raw_response: BalanceReportsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = BalanceReportsWithRawResponse(self) + def retrieve( self, id: str, @@ -104,6 +114,12 @@ def list( class AsyncBalanceReports(AsyncAPIResource): + with_raw_response: AsyncBalanceReportsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncBalanceReportsWithRawResponse(self) + async def retrieve( self, id: str, @@ -188,3 +204,23 @@ def list( ), model=BalanceReport, ) + + +class BalanceReportsWithRawResponse: + def __init__(self, balance_reports: BalanceReports) -> None: + self.retrieve = to_raw_response_wrapper( + balance_reports.retrieve, + ) + self.list = to_raw_response_wrapper( + balance_reports.list, + ) + + +class AsyncBalanceReportsWithRawResponse: + def __init__(self, balance_reports: AsyncBalanceReports) -> None: + self.retrieve = async_to_raw_response_wrapper( + balance_reports.retrieve, + ) + self.list = async_to_raw_response_wrapper( + balance_reports.list, + ) diff --git a/src/modern_treasury/resources/internal_accounts/internal_accounts.py b/src/modern_treasury/resources/internal_accounts/internal_accounts.py index 7df354df..a9bcb53f 100644 --- a/src/modern_treasury/resources/internal_accounts/internal_accounts.py +++ b/src/modern_treasury/resources/internal_accounts/internal_accounts.py @@ -14,10 +14,16 @@ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.shared import Currency, TransactionDirection -from .balance_reports import BalanceReports, AsyncBalanceReports +from .balance_reports import ( + BalanceReports, + AsyncBalanceReports, + BalanceReportsWithRawResponse, + AsyncBalanceReportsWithRawResponse, +) if TYPE_CHECKING: from ..._client import ModernTreasury, AsyncModernTreasury @@ -27,10 +33,12 @@ class InternalAccounts(SyncAPIResource): balance_reports: BalanceReports + with_raw_response: InternalAccountsWithRawResponse def __init__(self, client: ModernTreasury) -> None: super().__init__(client) self.balance_reports = BalanceReports(client) + self.with_raw_response = InternalAccountsWithRawResponse(self) def create( self, @@ -297,10 +305,12 @@ def list( class AsyncInternalAccounts(AsyncAPIResource): balance_reports: AsyncBalanceReports + with_raw_response: AsyncInternalAccountsWithRawResponse def __init__(self, client: AsyncModernTreasury) -> None: super().__init__(client) self.balance_reports = AsyncBalanceReports(client) + self.with_raw_response = AsyncInternalAccountsWithRawResponse(self) async def create( self, @@ -563,3 +573,39 @@ def list( ), model=InternalAccount, ) + + +class InternalAccountsWithRawResponse: + def __init__(self, internal_accounts: InternalAccounts) -> None: + self.balance_reports = BalanceReportsWithRawResponse(internal_accounts.balance_reports) + + self.create = to_raw_response_wrapper( + internal_accounts.create, + ) + self.retrieve = to_raw_response_wrapper( + internal_accounts.retrieve, + ) + self.update = to_raw_response_wrapper( + internal_accounts.update, + ) + self.list = to_raw_response_wrapper( + internal_accounts.list, + ) + + +class AsyncInternalAccountsWithRawResponse: + def __init__(self, internal_accounts: AsyncInternalAccounts) -> None: + self.balance_reports = AsyncBalanceReportsWithRawResponse(internal_accounts.balance_reports) + + self.create = async_to_raw_response_wrapper( + internal_accounts.create, + ) + self.retrieve = async_to_raw_response_wrapper( + internal_accounts.retrieve, + ) + self.update = async_to_raw_response_wrapper( + internal_accounts.update, + ) + self.list = async_to_raw_response_wrapper( + internal_accounts.list, + ) diff --git a/src/modern_treasury/resources/invoices/__init__.py b/src/modern_treasury/resources/invoices/__init__.py index e185c61d..76ddd5c5 100644 --- a/src/modern_treasury/resources/invoices/__init__.py +++ b/src/modern_treasury/resources/invoices/__init__.py @@ -1,6 +1,25 @@ # File generated from our OpenAPI spec by Stainless. -from .invoices import Invoices, AsyncInvoices -from .line_items import LineItems, AsyncLineItems +from .invoices import ( + Invoices, + AsyncInvoices, + InvoicesWithRawResponse, + AsyncInvoicesWithRawResponse, +) +from .line_items import ( + LineItems, + AsyncLineItems, + LineItemsWithRawResponse, + AsyncLineItemsWithRawResponse, +) -__all__ = ["LineItems", "AsyncLineItems", "Invoices", "AsyncInvoices"] +__all__ = [ + "LineItems", + "AsyncLineItems", + "LineItemsWithRawResponse", + "AsyncLineItemsWithRawResponse", + "Invoices", + "AsyncInvoices", + "InvoicesWithRawResponse", + "AsyncInvoicesWithRawResponse", +] diff --git a/src/modern_treasury/resources/invoices/invoices.py b/src/modern_treasury/resources/invoices/invoices.py index f2c8040d..eb11c176 100644 --- a/src/modern_treasury/resources/invoices/invoices.py +++ b/src/modern_treasury/resources/invoices/invoices.py @@ -14,8 +14,14 @@ ) from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from ..._utils import maybe_transform -from .line_items import LineItems, AsyncLineItems +from .line_items import ( + LineItems, + AsyncLineItems, + LineItemsWithRawResponse, + AsyncLineItemsWithRawResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.shared import Currency @@ -28,10 +34,12 @@ class Invoices(SyncAPIResource): line_items: LineItems + with_raw_response: InvoicesWithRawResponse def __init__(self, client: ModernTreasury) -> None: super().__init__(client) self.line_items = LineItems(client) + self.with_raw_response = InvoicesWithRawResponse(self) def create( self, @@ -467,10 +475,12 @@ def add_payment_order( class AsyncInvoices(AsyncAPIResource): line_items: AsyncLineItems + with_raw_response: AsyncInvoicesWithRawResponse def __init__(self, client: AsyncModernTreasury) -> None: super().__init__(client) self.line_items = AsyncLineItems(client) + self.with_raw_response = AsyncInvoicesWithRawResponse(self) async def create( self, @@ -902,3 +912,45 @@ async def add_payment_order( ), cast_to=NoneType, ) + + +class InvoicesWithRawResponse: + def __init__(self, invoices: Invoices) -> None: + self.line_items = LineItemsWithRawResponse(invoices.line_items) + + self.create = to_raw_response_wrapper( + invoices.create, + ) + self.retrieve = to_raw_response_wrapper( + invoices.retrieve, + ) + self.update = to_raw_response_wrapper( + invoices.update, + ) + self.list = to_raw_response_wrapper( + invoices.list, + ) + self.add_payment_order = to_raw_response_wrapper( + invoices.add_payment_order, + ) + + +class AsyncInvoicesWithRawResponse: + def __init__(self, invoices: AsyncInvoices) -> None: + self.line_items = AsyncLineItemsWithRawResponse(invoices.line_items) + + self.create = async_to_raw_response_wrapper( + invoices.create, + ) + self.retrieve = async_to_raw_response_wrapper( + invoices.retrieve, + ) + self.update = async_to_raw_response_wrapper( + invoices.update, + ) + self.list = async_to_raw_response_wrapper( + invoices.list, + ) + self.add_payment_order = async_to_raw_response_wrapper( + invoices.add_payment_order, + ) diff --git a/src/modern_treasury/resources/invoices/line_items.py b/src/modern_treasury/resources/invoices/line_items.py index a506a760..65759228 100644 --- a/src/modern_treasury/resources/invoices/line_items.py +++ b/src/modern_treasury/resources/invoices/line_items.py @@ -2,11 +2,12 @@ from __future__ import annotations -from typing import Optional +from typing import TYPE_CHECKING, Optional from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.invoices import ( @@ -16,10 +17,19 @@ line_item_update_params, ) +if TYPE_CHECKING: + from ..._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LineItems", "AsyncLineItems"] class LineItems(SyncAPIResource): + with_raw_response: LineItemsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LineItemsWithRawResponse(self) + def create( self, invoice_id: str, @@ -272,6 +282,12 @@ def delete( class AsyncLineItems(AsyncAPIResource): + with_raw_response: AsyncLineItemsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLineItemsWithRawResponse(self) + async def create( self, invoice_id: str, @@ -521,3 +537,41 @@ async def delete( ), cast_to=InvoiceLineItem, ) + + +class LineItemsWithRawResponse: + def __init__(self, line_items: LineItems) -> None: + self.create = to_raw_response_wrapper( + line_items.create, + ) + self.retrieve = to_raw_response_wrapper( + line_items.retrieve, + ) + self.update = to_raw_response_wrapper( + line_items.update, + ) + self.list = to_raw_response_wrapper( + line_items.list, + ) + self.delete = to_raw_response_wrapper( + line_items.delete, + ) + + +class AsyncLineItemsWithRawResponse: + def __init__(self, line_items: AsyncLineItems) -> None: + self.create = async_to_raw_response_wrapper( + line_items.create, + ) + self.retrieve = async_to_raw_response_wrapper( + line_items.retrieve, + ) + self.update = async_to_raw_response_wrapper( + line_items.update, + ) + self.list = async_to_raw_response_wrapper( + line_items.list, + ) + self.delete = async_to_raw_response_wrapper( + line_items.delete, + ) diff --git a/src/modern_treasury/resources/ledger_account_balance_monitors.py b/src/modern_treasury/resources/ledger_account_balance_monitors.py index e3745b90..01cc6055 100644 --- a/src/modern_treasury/resources/ledger_account_balance_monitors.py +++ b/src/modern_treasury/resources/ledger_account_balance_monitors.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Optional +from typing import TYPE_CHECKING, Dict, List, Optional from ..types import ( LedgerAccountBalanceMonitor, @@ -13,13 +13,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerAccountBalanceMonitors", "AsyncLedgerAccountBalanceMonitors"] class LedgerAccountBalanceMonitors(SyncAPIResource): + with_raw_response: LedgerAccountBalanceMonitorsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerAccountBalanceMonitorsWithRawResponse(self) + def create( self, *, @@ -260,6 +270,12 @@ def delete( class AsyncLedgerAccountBalanceMonitors(AsyncAPIResource): + with_raw_response: AsyncLedgerAccountBalanceMonitorsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerAccountBalanceMonitorsWithRawResponse(self) + async def create( self, *, @@ -497,3 +513,41 @@ async def delete( ), cast_to=LedgerAccountBalanceMonitor, ) + + +class LedgerAccountBalanceMonitorsWithRawResponse: + def __init__(self, ledger_account_balance_monitors: LedgerAccountBalanceMonitors) -> None: + self.create = to_raw_response_wrapper( + ledger_account_balance_monitors.create, + ) + self.retrieve = to_raw_response_wrapper( + ledger_account_balance_monitors.retrieve, + ) + self.update = to_raw_response_wrapper( + ledger_account_balance_monitors.update, + ) + self.list = to_raw_response_wrapper( + ledger_account_balance_monitors.list, + ) + self.delete = to_raw_response_wrapper( + ledger_account_balance_monitors.delete, + ) + + +class AsyncLedgerAccountBalanceMonitorsWithRawResponse: + def __init__(self, ledger_account_balance_monitors: AsyncLedgerAccountBalanceMonitors) -> None: + self.create = async_to_raw_response_wrapper( + ledger_account_balance_monitors.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledger_account_balance_monitors.retrieve, + ) + self.update = async_to_raw_response_wrapper( + ledger_account_balance_monitors.update, + ) + self.list = async_to_raw_response_wrapper( + ledger_account_balance_monitors.list, + ) + self.delete = async_to_raw_response_wrapper( + ledger_account_balance_monitors.delete, + ) diff --git a/src/modern_treasury/resources/ledger_account_categories.py b/src/modern_treasury/resources/ledger_account_categories.py index 9729984c..d566bebf 100644 --- a/src/modern_treasury/resources/ledger_account_categories.py +++ b/src/modern_treasury/resources/ledger_account_categories.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Optional +from typing import TYPE_CHECKING, Dict, List, Optional from ..types import ( LedgerAccountCategory, @@ -14,14 +14,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import TransactionDirection +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerAccountCategories", "AsyncLedgerAccountCategories"] class LedgerAccountCategories(SyncAPIResource): + with_raw_response: LedgerAccountCategoriesWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerAccountCategoriesWithRawResponse(self) + def create( self, *, @@ -464,6 +474,12 @@ def remove_nested_category( class AsyncLedgerAccountCategories(AsyncAPIResource): + with_raw_response: AsyncLedgerAccountCategoriesWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerAccountCategoriesWithRawResponse(self) + async def create( self, *, @@ -903,3 +919,65 @@ async def remove_nested_category( ), cast_to=NoneType, ) + + +class LedgerAccountCategoriesWithRawResponse: + def __init__(self, ledger_account_categories: LedgerAccountCategories) -> None: + self.create = to_raw_response_wrapper( + ledger_account_categories.create, + ) + self.retrieve = to_raw_response_wrapper( + ledger_account_categories.retrieve, + ) + self.update = to_raw_response_wrapper( + ledger_account_categories.update, + ) + self.list = to_raw_response_wrapper( + ledger_account_categories.list, + ) + self.delete = to_raw_response_wrapper( + ledger_account_categories.delete, + ) + self.add_ledger_account = to_raw_response_wrapper( + ledger_account_categories.add_ledger_account, + ) + self.add_nested_category = to_raw_response_wrapper( + ledger_account_categories.add_nested_category, + ) + self.remove_ledger_account = to_raw_response_wrapper( + ledger_account_categories.remove_ledger_account, + ) + self.remove_nested_category = to_raw_response_wrapper( + ledger_account_categories.remove_nested_category, + ) + + +class AsyncLedgerAccountCategoriesWithRawResponse: + def __init__(self, ledger_account_categories: AsyncLedgerAccountCategories) -> None: + self.create = async_to_raw_response_wrapper( + ledger_account_categories.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledger_account_categories.retrieve, + ) + self.update = async_to_raw_response_wrapper( + ledger_account_categories.update, + ) + self.list = async_to_raw_response_wrapper( + ledger_account_categories.list, + ) + self.delete = async_to_raw_response_wrapper( + ledger_account_categories.delete, + ) + self.add_ledger_account = async_to_raw_response_wrapper( + ledger_account_categories.add_ledger_account, + ) + self.add_nested_category = async_to_raw_response_wrapper( + ledger_account_categories.add_nested_category, + ) + self.remove_ledger_account = async_to_raw_response_wrapper( + ledger_account_categories.remove_ledger_account, + ) + self.remove_nested_category = async_to_raw_response_wrapper( + ledger_account_categories.remove_nested_category, + ) diff --git a/src/modern_treasury/resources/ledger_account_payouts.py b/src/modern_treasury/resources/ledger_account_payouts.py index ac5520e3..9c95c6ec 100644 --- a/src/modern_treasury/resources/ledger_account_payouts.py +++ b/src/modern_treasury/resources/ledger_account_payouts.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing_extensions -from typing import Dict, List, Union, Optional +from typing import TYPE_CHECKING, Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal @@ -16,13 +16,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerAccountPayouts", "AsyncLedgerAccountPayouts"] class LedgerAccountPayouts(SyncAPIResource): + with_raw_response: LedgerAccountPayoutsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerAccountPayoutsWithRawResponse(self) + def create( self, *, @@ -281,6 +291,12 @@ def retireve( class AsyncLedgerAccountPayouts(AsyncAPIResource): + with_raw_response: AsyncLedgerAccountPayoutsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerAccountPayoutsWithRawResponse(self) + async def create( self, *, @@ -536,3 +552,41 @@ async def retireve( return await self.retrieve( id=id, extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ) + + +class LedgerAccountPayoutsWithRawResponse: + def __init__(self, ledger_account_payouts: LedgerAccountPayouts) -> None: + self.create = to_raw_response_wrapper( + ledger_account_payouts.create, + ) + self.retrieve = to_raw_response_wrapper( + ledger_account_payouts.retrieve, + ) + self.update = to_raw_response_wrapper( + ledger_account_payouts.update, + ) + self.list = to_raw_response_wrapper( + ledger_account_payouts.list, + ) + self.retireve = to_raw_response_wrapper( # pyright: ignore[reportDeprecated] + ledger_account_payouts.retireve # pyright: ignore[reportDeprecated], + ) + + +class AsyncLedgerAccountPayoutsWithRawResponse: + def __init__(self, ledger_account_payouts: AsyncLedgerAccountPayouts) -> None: + self.create = async_to_raw_response_wrapper( + ledger_account_payouts.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledger_account_payouts.retrieve, + ) + self.update = async_to_raw_response_wrapper( + ledger_account_payouts.update, + ) + self.list = async_to_raw_response_wrapper( + ledger_account_payouts.list, + ) + self.retireve = async_to_raw_response_wrapper( # pyright: ignore[reportDeprecated] + ledger_account_payouts.retireve # pyright: ignore[reportDeprecated], + ) diff --git a/src/modern_treasury/resources/ledger_account_statements.py b/src/modern_treasury/resources/ledger_account_statements.py index f4f784a9..a50402a9 100644 --- a/src/modern_treasury/resources/ledger_account_statements.py +++ b/src/modern_treasury/resources/ledger_account_statements.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Union, Optional +from typing import TYPE_CHECKING, Dict, Union, Optional from datetime import datetime from ..types import ( @@ -13,12 +13,22 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerAccountStatements", "AsyncLedgerAccountStatements"] class LedgerAccountStatements(SyncAPIResource): + with_raw_response: LedgerAccountStatementsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerAccountStatementsWithRawResponse(self) + def create( self, *, @@ -118,6 +128,12 @@ def retrieve( class AsyncLedgerAccountStatements(AsyncAPIResource): + with_raw_response: AsyncLedgerAccountStatementsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerAccountStatementsWithRawResponse(self) + async def create( self, *, @@ -214,3 +230,23 @@ async def retrieve( ), cast_to=LedgerAccountStatementRetrieveResponse, ) + + +class LedgerAccountStatementsWithRawResponse: + def __init__(self, ledger_account_statements: LedgerAccountStatements) -> None: + self.create = to_raw_response_wrapper( + ledger_account_statements.create, + ) + self.retrieve = to_raw_response_wrapper( + ledger_account_statements.retrieve, + ) + + +class AsyncLedgerAccountStatementsWithRawResponse: + def __init__(self, ledger_account_statements: AsyncLedgerAccountStatements) -> None: + self.create = async_to_raw_response_wrapper( + ledger_account_statements.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledger_account_statements.retrieve, + ) diff --git a/src/modern_treasury/resources/ledger_accounts.py b/src/modern_treasury/resources/ledger_accounts.py index 0bcf6e05..056bbc1c 100644 --- a/src/modern_treasury/resources/ledger_accounts.py +++ b/src/modern_treasury/resources/ledger_accounts.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Union, Optional +from typing import TYPE_CHECKING, Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal @@ -16,14 +16,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import TransactionDirection +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerAccounts", "AsyncLedgerAccounts"] class LedgerAccounts(SyncAPIResource): + with_raw_response: LedgerAccountsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerAccountsWithRawResponse(self) + def create( self, *, @@ -344,6 +354,12 @@ def delete( class AsyncLedgerAccounts(AsyncAPIResource): + with_raw_response: AsyncLedgerAccountsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerAccountsWithRawResponse(self) + async def create( self, *, @@ -661,3 +677,41 @@ async def delete( ), cast_to=LedgerAccount, ) + + +class LedgerAccountsWithRawResponse: + def __init__(self, ledger_accounts: LedgerAccounts) -> None: + self.create = to_raw_response_wrapper( + ledger_accounts.create, + ) + self.retrieve = to_raw_response_wrapper( + ledger_accounts.retrieve, + ) + self.update = to_raw_response_wrapper( + ledger_accounts.update, + ) + self.list = to_raw_response_wrapper( + ledger_accounts.list, + ) + self.delete = to_raw_response_wrapper( + ledger_accounts.delete, + ) + + +class AsyncLedgerAccountsWithRawResponse: + def __init__(self, ledger_accounts: AsyncLedgerAccounts) -> None: + self.create = async_to_raw_response_wrapper( + ledger_accounts.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledger_accounts.retrieve, + ) + self.update = async_to_raw_response_wrapper( + ledger_accounts.update, + ) + self.list = async_to_raw_response_wrapper( + ledger_accounts.list, + ) + self.delete = async_to_raw_response_wrapper( + ledger_accounts.delete, + ) diff --git a/src/modern_treasury/resources/ledger_entries.py b/src/modern_treasury/resources/ledger_entries.py index c66621ff..09d13d09 100644 --- a/src/modern_treasury/resources/ledger_entries.py +++ b/src/modern_treasury/resources/ledger_entries.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Union, Optional +from typing import TYPE_CHECKING, Dict, List, Union, Optional from datetime import date, datetime from typing_extensions import Literal @@ -10,14 +10,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import TransactionDirection +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerEntries", "AsyncLedgerEntries"] class LedgerEntries(SyncAPIResource): + with_raw_response: LedgerEntriesWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerEntriesWithRawResponse(self) + def retrieve( self, id: str, @@ -186,6 +196,12 @@ def list( class AsyncLedgerEntries(AsyncAPIResource): + with_raw_response: AsyncLedgerEntriesWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerEntriesWithRawResponse(self) + async def retrieve( self, id: str, @@ -351,3 +367,23 @@ def list( ), model=LedgerEntry, ) + + +class LedgerEntriesWithRawResponse: + def __init__(self, ledger_entries: LedgerEntries) -> None: + self.retrieve = to_raw_response_wrapper( + ledger_entries.retrieve, + ) + self.list = to_raw_response_wrapper( + ledger_entries.list, + ) + + +class AsyncLedgerEntriesWithRawResponse: + def __init__(self, ledger_entries: AsyncLedgerEntries) -> None: + self.retrieve = async_to_raw_response_wrapper( + ledger_entries.retrieve, + ) + self.list = async_to_raw_response_wrapper( + ledger_entries.list, + ) diff --git a/src/modern_treasury/resources/ledger_event_handlers.py b/src/modern_treasury/resources/ledger_event_handlers.py index 1abfb7a8..2b174363 100644 --- a/src/modern_treasury/resources/ledger_event_handlers.py +++ b/src/modern_treasury/resources/ledger_event_handlers.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Union, Optional +from typing import TYPE_CHECKING, Dict, Union, Optional from datetime import datetime from ..types import ( @@ -14,13 +14,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerEventHandlers", "AsyncLedgerEventHandlers"] class LedgerEventHandlers(SyncAPIResource): + with_raw_response: LedgerEventHandlersWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerEventHandlersWithRawResponse(self) + def create( self, *, @@ -214,6 +224,12 @@ def delete( class AsyncLedgerEventHandlers(AsyncAPIResource): + with_raw_response: AsyncLedgerEventHandlersWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerEventHandlersWithRawResponse(self) + async def create( self, *, @@ -404,3 +420,35 @@ async def delete( ), cast_to=LedgerEventHandler, ) + + +class LedgerEventHandlersWithRawResponse: + def __init__(self, ledger_event_handlers: LedgerEventHandlers) -> None: + self.create = to_raw_response_wrapper( + ledger_event_handlers.create, + ) + self.retrieve = to_raw_response_wrapper( + ledger_event_handlers.retrieve, + ) + self.list = to_raw_response_wrapper( + ledger_event_handlers.list, + ) + self.delete = to_raw_response_wrapper( + ledger_event_handlers.delete, + ) + + +class AsyncLedgerEventHandlersWithRawResponse: + def __init__(self, ledger_event_handlers: AsyncLedgerEventHandlers) -> None: + self.create = async_to_raw_response_wrapper( + ledger_event_handlers.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledger_event_handlers.retrieve, + ) + self.list = async_to_raw_response_wrapper( + ledger_event_handlers.list, + ) + self.delete = async_to_raw_response_wrapper( + ledger_event_handlers.delete, + ) diff --git a/src/modern_treasury/resources/ledger_transactions/__init__.py b/src/modern_treasury/resources/ledger_transactions/__init__.py index 0bf3fdf7..d8ea9628 100644 --- a/src/modern_treasury/resources/ledger_transactions/__init__.py +++ b/src/modern_treasury/resources/ledger_transactions/__init__.py @@ -1,6 +1,25 @@ # File generated from our OpenAPI spec by Stainless. -from .versions import Versions, AsyncVersions -from .ledger_transactions import LedgerTransactions, AsyncLedgerTransactions +from .versions import ( + Versions, + AsyncVersions, + VersionsWithRawResponse, + AsyncVersionsWithRawResponse, +) +from .ledger_transactions import ( + LedgerTransactions, + AsyncLedgerTransactions, + LedgerTransactionsWithRawResponse, + AsyncLedgerTransactionsWithRawResponse, +) -__all__ = ["Versions", "AsyncVersions", "LedgerTransactions", "AsyncLedgerTransactions"] +__all__ = [ + "Versions", + "AsyncVersions", + "VersionsWithRawResponse", + "AsyncVersionsWithRawResponse", + "LedgerTransactions", + "AsyncLedgerTransactions", + "LedgerTransactionsWithRawResponse", + "AsyncLedgerTransactionsWithRawResponse", +] diff --git a/src/modern_treasury/resources/ledger_transactions/ledger_transactions.py b/src/modern_treasury/resources/ledger_transactions/ledger_transactions.py index de9b03b6..1b5b5661 100644 --- a/src/modern_treasury/resources/ledger_transactions/ledger_transactions.py +++ b/src/modern_treasury/resources/ledger_transactions/ledger_transactions.py @@ -15,8 +15,14 @@ ) from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform -from .versions import Versions, AsyncVersions +from .versions import ( + Versions, + AsyncVersions, + VersionsWithRawResponse, + AsyncVersionsWithRawResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options @@ -28,10 +34,12 @@ class LedgerTransactions(SyncAPIResource): versions: Versions + with_raw_response: LedgerTransactionsWithRawResponse def __init__(self, client: ModernTreasury) -> None: super().__init__(client) self.versions = Versions(client) + self.with_raw_response = LedgerTransactionsWithRawResponse(self) def create( self, @@ -433,10 +441,12 @@ def create_reversal( class AsyncLedgerTransactions(AsyncAPIResource): versions: AsyncVersions + with_raw_response: AsyncLedgerTransactionsWithRawResponse def __init__(self, client: AsyncModernTreasury) -> None: super().__init__(client) self.versions = AsyncVersions(client) + self.with_raw_response = AsyncLedgerTransactionsWithRawResponse(self) async def create( self, @@ -834,3 +844,45 @@ async def create_reversal( ), cast_to=LedgerTransaction, ) + + +class LedgerTransactionsWithRawResponse: + def __init__(self, ledger_transactions: LedgerTransactions) -> None: + self.versions = VersionsWithRawResponse(ledger_transactions.versions) + + self.create = to_raw_response_wrapper( + ledger_transactions.create, + ) + self.retrieve = to_raw_response_wrapper( + ledger_transactions.retrieve, + ) + self.update = to_raw_response_wrapper( + ledger_transactions.update, + ) + self.list = to_raw_response_wrapper( + ledger_transactions.list, + ) + self.create_reversal = to_raw_response_wrapper( + ledger_transactions.create_reversal, + ) + + +class AsyncLedgerTransactionsWithRawResponse: + def __init__(self, ledger_transactions: AsyncLedgerTransactions) -> None: + self.versions = AsyncVersionsWithRawResponse(ledger_transactions.versions) + + self.create = async_to_raw_response_wrapper( + ledger_transactions.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledger_transactions.retrieve, + ) + self.update = async_to_raw_response_wrapper( + ledger_transactions.update, + ) + self.list = async_to_raw_response_wrapper( + ledger_transactions.list, + ) + self.create_reversal = async_to_raw_response_wrapper( + ledger_transactions.create_reversal, + ) diff --git a/src/modern_treasury/resources/ledger_transactions/versions.py b/src/modern_treasury/resources/ledger_transactions/versions.py index 806ebbf0..fb77e280 100644 --- a/src/modern_treasury/resources/ledger_transactions/versions.py +++ b/src/modern_treasury/resources/ledger_transactions/versions.py @@ -2,20 +2,30 @@ from __future__ import annotations -from typing import Dict, Union, Optional +from typing import TYPE_CHECKING, Dict, Union, Optional from datetime import datetime from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.ledger_transactions import LedgerTransactionVersion, version_list_params +if TYPE_CHECKING: + from ..._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Versions", "AsyncVersions"] class Versions(SyncAPIResource): + with_raw_response: VersionsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = VersionsWithRawResponse(self) + def list( self, *, @@ -82,6 +92,12 @@ def list( class AsyncVersions(AsyncAPIResource): + with_raw_response: AsyncVersionsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncVersionsWithRawResponse(self) + def list( self, *, @@ -145,3 +161,17 @@ def list( ), model=LedgerTransactionVersion, ) + + +class VersionsWithRawResponse: + def __init__(self, versions: Versions) -> None: + self.list = to_raw_response_wrapper( + versions.list, + ) + + +class AsyncVersionsWithRawResponse: + def __init__(self, versions: AsyncVersions) -> None: + self.list = async_to_raw_response_wrapper( + versions.list, + ) diff --git a/src/modern_treasury/resources/ledgerable_events.py b/src/modern_treasury/resources/ledgerable_events.py index 62cafe3b..59fb02ab 100644 --- a/src/modern_treasury/resources/ledgerable_events.py +++ b/src/modern_treasury/resources/ledgerable_events.py @@ -2,18 +2,28 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import TYPE_CHECKING, Dict, Optional from ..types import LedgerableEvent, ledgerable_event_create_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LedgerableEvents", "AsyncLedgerableEvents"] class LedgerableEvents(SyncAPIResource): + with_raw_response: LedgerableEventsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgerableEventsWithRawResponse(self) + def create( self, *, @@ -106,6 +116,12 @@ def retrieve( class AsyncLedgerableEvents(AsyncAPIResource): + with_raw_response: AsyncLedgerableEventsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgerableEventsWithRawResponse(self) + async def create( self, *, @@ -195,3 +211,23 @@ async def retrieve( ), cast_to=LedgerableEvent, ) + + +class LedgerableEventsWithRawResponse: + def __init__(self, ledgerable_events: LedgerableEvents) -> None: + self.create = to_raw_response_wrapper( + ledgerable_events.create, + ) + self.retrieve = to_raw_response_wrapper( + ledgerable_events.retrieve, + ) + + +class AsyncLedgerableEventsWithRawResponse: + def __init__(self, ledgerable_events: AsyncLedgerableEvents) -> None: + self.create = async_to_raw_response_wrapper( + ledgerable_events.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledgerable_events.retrieve, + ) diff --git a/src/modern_treasury/resources/ledgers.py b/src/modern_treasury/resources/ledgers.py index ebd69195..c959a6da 100644 --- a/src/modern_treasury/resources/ledgers.py +++ b/src/modern_treasury/resources/ledgers.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Union, Optional +from typing import TYPE_CHECKING, Dict, List, Union, Optional from datetime import datetime from ..types import ( @@ -14,13 +14,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Ledgers", "AsyncLedgers"] class Ledgers(SyncAPIResource): + with_raw_response: LedgersWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LedgersWithRawResponse(self) + def create( self, *, @@ -263,6 +273,12 @@ def delete( class AsyncLedgers(AsyncAPIResource): + with_raw_response: AsyncLedgersWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLedgersWithRawResponse(self) + async def create( self, *, @@ -502,3 +518,41 @@ async def delete( ), cast_to=Ledger, ) + + +class LedgersWithRawResponse: + def __init__(self, ledgers: Ledgers) -> None: + self.create = to_raw_response_wrapper( + ledgers.create, + ) + self.retrieve = to_raw_response_wrapper( + ledgers.retrieve, + ) + self.update = to_raw_response_wrapper( + ledgers.update, + ) + self.list = to_raw_response_wrapper( + ledgers.list, + ) + self.delete = to_raw_response_wrapper( + ledgers.delete, + ) + + +class AsyncLedgersWithRawResponse: + def __init__(self, ledgers: AsyncLedgers) -> None: + self.create = async_to_raw_response_wrapper( + ledgers.create, + ) + self.retrieve = async_to_raw_response_wrapper( + ledgers.retrieve, + ) + self.update = async_to_raw_response_wrapper( + ledgers.update, + ) + self.list = async_to_raw_response_wrapper( + ledgers.list, + ) + self.delete = async_to_raw_response_wrapper( + ledgers.delete, + ) diff --git a/src/modern_treasury/resources/line_items.py b/src/modern_treasury/resources/line_items.py index 7e9d8a7d..9506b7b5 100644 --- a/src/modern_treasury/resources/line_items.py +++ b/src/modern_treasury/resources/line_items.py @@ -2,20 +2,30 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import TYPE_CHECKING, Dict, Optional from typing_extensions import Literal from ..types import LineItem, line_item_list_params, line_item_update_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LineItems", "AsyncLineItems"] class LineItems(SyncAPIResource): + with_raw_response: LineItemsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LineItemsWithRawResponse(self) + def retrieve( self, id: str, @@ -141,6 +151,12 @@ def list( class AsyncLineItems(AsyncAPIResource): + with_raw_response: AsyncLineItemsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLineItemsWithRawResponse(self) + async def retrieve( self, id: str, @@ -263,3 +279,29 @@ def list( ), model=LineItem, ) + + +class LineItemsWithRawResponse: + def __init__(self, line_items: LineItems) -> None: + self.retrieve = to_raw_response_wrapper( + line_items.retrieve, + ) + self.update = to_raw_response_wrapper( + line_items.update, + ) + self.list = to_raw_response_wrapper( + line_items.list, + ) + + +class AsyncLineItemsWithRawResponse: + def __init__(self, line_items: AsyncLineItems) -> None: + self.retrieve = async_to_raw_response_wrapper( + line_items.retrieve, + ) + self.update = async_to_raw_response_wrapper( + line_items.update, + ) + self.list = async_to_raw_response_wrapper( + line_items.list, + ) diff --git a/src/modern_treasury/resources/paper_items.py b/src/modern_treasury/resources/paper_items.py index f8d6c92c..25d4f1d0 100644 --- a/src/modern_treasury/resources/paper_items.py +++ b/src/modern_treasury/resources/paper_items.py @@ -2,20 +2,30 @@ from __future__ import annotations -from typing import Union, Optional +from typing import TYPE_CHECKING, Union, Optional from datetime import date from ..types import PaperItem, paper_item_list_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["PaperItems", "AsyncPaperItems"] class PaperItems(SyncAPIResource): + with_raw_response: PaperItemsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = PaperItemsWithRawResponse(self) + def retrieve( self, id: str, @@ -105,6 +115,12 @@ def list( class AsyncPaperItems(AsyncAPIResource): + with_raw_response: AsyncPaperItemsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncPaperItemsWithRawResponse(self) + async def retrieve( self, id: str, @@ -191,3 +207,23 @@ def list( ), model=PaperItem, ) + + +class PaperItemsWithRawResponse: + def __init__(self, paper_items: PaperItems) -> None: + self.retrieve = to_raw_response_wrapper( + paper_items.retrieve, + ) + self.list = to_raw_response_wrapper( + paper_items.list, + ) + + +class AsyncPaperItemsWithRawResponse: + def __init__(self, paper_items: AsyncPaperItems) -> None: + self.retrieve = async_to_raw_response_wrapper( + paper_items.retrieve, + ) + self.list = async_to_raw_response_wrapper( + paper_items.list, + ) diff --git a/src/modern_treasury/resources/payment_flows.py b/src/modern_treasury/resources/payment_flows.py index c60e9d3c..9c264568 100644 --- a/src/modern_treasury/resources/payment_flows.py +++ b/src/modern_treasury/resources/payment_flows.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Union, Optional +from typing import TYPE_CHECKING, Union, Optional from datetime import date from typing_extensions import Literal @@ -15,13 +15,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["PaymentFlows", "AsyncPaymentFlows"] class PaymentFlows(SyncAPIResource): + with_raw_response: PaymentFlowsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = PaymentFlowsWithRawResponse(self) + def create( self, *, @@ -226,6 +236,12 @@ def list( class AsyncPaymentFlows(AsyncAPIResource): + with_raw_response: AsyncPaymentFlowsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncPaymentFlowsWithRawResponse(self) + async def create( self, *, @@ -427,3 +443,35 @@ def list( ), model=PaymentFlow, ) + + +class PaymentFlowsWithRawResponse: + def __init__(self, payment_flows: PaymentFlows) -> None: + self.create = to_raw_response_wrapper( + payment_flows.create, + ) + self.retrieve = to_raw_response_wrapper( + payment_flows.retrieve, + ) + self.update = to_raw_response_wrapper( + payment_flows.update, + ) + self.list = to_raw_response_wrapper( + payment_flows.list, + ) + + +class AsyncPaymentFlowsWithRawResponse: + def __init__(self, payment_flows: AsyncPaymentFlows) -> None: + self.create = async_to_raw_response_wrapper( + payment_flows.create, + ) + self.retrieve = async_to_raw_response_wrapper( + payment_flows.retrieve, + ) + self.update = async_to_raw_response_wrapper( + payment_flows.update, + ) + self.list = async_to_raw_response_wrapper( + payment_flows.list, + ) diff --git a/src/modern_treasury/resources/payment_orders/__init__.py b/src/modern_treasury/resources/payment_orders/__init__.py index 7eb53412..657b029e 100644 --- a/src/modern_treasury/resources/payment_orders/__init__.py +++ b/src/modern_treasury/resources/payment_orders/__init__.py @@ -1,6 +1,25 @@ # File generated from our OpenAPI spec by Stainless. -from .reversals import Reversals, AsyncReversals -from .payment_orders import PaymentOrders, AsyncPaymentOrders +from .reversals import ( + Reversals, + AsyncReversals, + ReversalsWithRawResponse, + AsyncReversalsWithRawResponse, +) +from .payment_orders import ( + PaymentOrders, + AsyncPaymentOrders, + PaymentOrdersWithRawResponse, + AsyncPaymentOrdersWithRawResponse, +) -__all__ = ["Reversals", "AsyncReversals", "PaymentOrders", "AsyncPaymentOrders"] +__all__ = [ + "Reversals", + "AsyncReversals", + "ReversalsWithRawResponse", + "AsyncReversalsWithRawResponse", + "PaymentOrders", + "AsyncPaymentOrders", + "PaymentOrdersWithRawResponse", + "AsyncPaymentOrdersWithRawResponse", +] diff --git a/src/modern_treasury/resources/payment_orders/payment_orders.py b/src/modern_treasury/resources/payment_orders/payment_orders.py index 72e71e3c..0dede077 100644 --- a/src/modern_treasury/resources/payment_orders/payment_orders.py +++ b/src/modern_treasury/resources/payment_orders/payment_orders.py @@ -17,8 +17,14 @@ ) from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import extract_files, maybe_transform, deepcopy_minimal -from .reversals import Reversals, AsyncReversals +from .reversals import ( + Reversals, + AsyncReversals, + ReversalsWithRawResponse, + AsyncReversalsWithRawResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.shared import Currency, AsyncResponse, TransactionDirection @@ -31,10 +37,12 @@ class PaymentOrders(SyncAPIResource): reversals: Reversals + with_raw_response: PaymentOrdersWithRawResponse def __init__(self, client: ModernTreasury) -> None: super().__init__(client) self.reversals = Reversals(client) + self.with_raw_response = PaymentOrdersWithRawResponse(self) def create( self, @@ -891,10 +899,12 @@ def create_async( class AsyncPaymentOrders(AsyncAPIResource): reversals: AsyncReversals + with_raw_response: AsyncPaymentOrdersWithRawResponse def __init__(self, client: AsyncModernTreasury) -> None: super().__init__(client) self.reversals = AsyncReversals(client) + self.with_raw_response = AsyncPaymentOrdersWithRawResponse(self) async def create( self, @@ -1747,3 +1757,45 @@ async def create_async( ), cast_to=AsyncResponse, ) + + +class PaymentOrdersWithRawResponse: + def __init__(self, payment_orders: PaymentOrders) -> None: + self.reversals = ReversalsWithRawResponse(payment_orders.reversals) + + self.create = to_raw_response_wrapper( + payment_orders.create, + ) + self.retrieve = to_raw_response_wrapper( + payment_orders.retrieve, + ) + self.update = to_raw_response_wrapper( + payment_orders.update, + ) + self.list = to_raw_response_wrapper( + payment_orders.list, + ) + self.create_async = to_raw_response_wrapper( + payment_orders.create_async, + ) + + +class AsyncPaymentOrdersWithRawResponse: + def __init__(self, payment_orders: AsyncPaymentOrders) -> None: + self.reversals = AsyncReversalsWithRawResponse(payment_orders.reversals) + + self.create = async_to_raw_response_wrapper( + payment_orders.create, + ) + self.retrieve = async_to_raw_response_wrapper( + payment_orders.retrieve, + ) + self.update = async_to_raw_response_wrapper( + payment_orders.update, + ) + self.list = async_to_raw_response_wrapper( + payment_orders.list, + ) + self.create_async = async_to_raw_response_wrapper( + payment_orders.create_async, + ) diff --git a/src/modern_treasury/resources/payment_orders/reversals.py b/src/modern_treasury/resources/payment_orders/reversals.py index 0b57f2cf..d2ec5e18 100644 --- a/src/modern_treasury/resources/payment_orders/reversals.py +++ b/src/modern_treasury/resources/payment_orders/reversals.py @@ -2,12 +2,13 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import TYPE_CHECKING, Dict, Optional from typing_extensions import Literal from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.payment_orders import ( @@ -16,10 +17,19 @@ reversal_create_params, ) +if TYPE_CHECKING: + from ..._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Reversals", "AsyncReversals"] class Reversals(SyncAPIResource): + with_raw_response: ReversalsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = ReversalsWithRawResponse(self) + def create( self, payment_order_id: str, @@ -166,6 +176,12 @@ def list( class AsyncReversals(AsyncAPIResource): + with_raw_response: AsyncReversalsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncReversalsWithRawResponse(self) + async def create( self, payment_order_id: str, @@ -309,3 +325,29 @@ def list( ), model=Reversal, ) + + +class ReversalsWithRawResponse: + def __init__(self, reversals: Reversals) -> None: + self.create = to_raw_response_wrapper( + reversals.create, + ) + self.retrieve = to_raw_response_wrapper( + reversals.retrieve, + ) + self.list = to_raw_response_wrapper( + reversals.list, + ) + + +class AsyncReversalsWithRawResponse: + def __init__(self, reversals: AsyncReversals) -> None: + self.create = async_to_raw_response_wrapper( + reversals.create, + ) + self.retrieve = async_to_raw_response_wrapper( + reversals.retrieve, + ) + self.list = async_to_raw_response_wrapper( + reversals.list, + ) diff --git a/src/modern_treasury/resources/payment_references.py b/src/modern_treasury/resources/payment_references.py index 0ac762bf..d6cc7491 100644 --- a/src/modern_treasury/resources/payment_references.py +++ b/src/modern_treasury/resources/payment_references.py @@ -3,20 +3,30 @@ from __future__ import annotations import typing_extensions -from typing import Optional +from typing import TYPE_CHECKING, Optional from typing_extensions import Literal from ..types import PaymentReference, payment_reference_list_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["PaymentReferences", "AsyncPaymentReferences"] class PaymentReferences(SyncAPIResource): + with_raw_response: PaymentReferencesWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = PaymentReferencesWithRawResponse(self) + def retrieve( self, id: str, @@ -135,6 +145,12 @@ def retireve( class AsyncPaymentReferences(AsyncAPIResource): + with_raw_response: AsyncPaymentReferencesWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncPaymentReferencesWithRawResponse(self) + async def retrieve( self, id: str, @@ -250,3 +266,29 @@ async def retireve( return await self.retrieve( id=id, extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ) + + +class PaymentReferencesWithRawResponse: + def __init__(self, payment_references: PaymentReferences) -> None: + self.retrieve = to_raw_response_wrapper( + payment_references.retrieve, + ) + self.list = to_raw_response_wrapper( + payment_references.list, + ) + self.retireve = to_raw_response_wrapper( # pyright: ignore[reportDeprecated] + payment_references.retireve # pyright: ignore[reportDeprecated], + ) + + +class AsyncPaymentReferencesWithRawResponse: + def __init__(self, payment_references: AsyncPaymentReferences) -> None: + self.retrieve = async_to_raw_response_wrapper( + payment_references.retrieve, + ) + self.list = async_to_raw_response_wrapper( + payment_references.list, + ) + self.retireve = async_to_raw_response_wrapper( # pyright: ignore[reportDeprecated] + payment_references.retireve # pyright: ignore[reportDeprecated], + ) diff --git a/src/modern_treasury/resources/returns.py b/src/modern_treasury/resources/returns.py index 8805aaa3..40bbcbb2 100644 --- a/src/modern_treasury/resources/returns.py +++ b/src/modern_treasury/resources/returns.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Union, Optional +from typing import TYPE_CHECKING, Union, Optional from datetime import date from typing_extensions import Literal @@ -10,13 +10,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Returns", "AsyncReturns"] class Returns(SyncAPIResource): + with_raw_response: ReturnsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = ReturnsWithRawResponse(self) + def create( self, *, @@ -230,6 +240,12 @@ def list( class AsyncReturns(AsyncAPIResource): + with_raw_response: AsyncReturnsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncReturnsWithRawResponse(self) + async def create( self, *, @@ -440,3 +456,29 @@ def list( ), model=ReturnObject, ) + + +class ReturnsWithRawResponse: + def __init__(self, returns: Returns) -> None: + self.create = to_raw_response_wrapper( + returns.create, + ) + self.retrieve = to_raw_response_wrapper( + returns.retrieve, + ) + self.list = to_raw_response_wrapper( + returns.list, + ) + + +class AsyncReturnsWithRawResponse: + def __init__(self, returns: AsyncReturns) -> None: + self.create = async_to_raw_response_wrapper( + returns.create, + ) + self.retrieve = async_to_raw_response_wrapper( + returns.retrieve, + ) + self.list = async_to_raw_response_wrapper( + returns.list, + ) diff --git a/src/modern_treasury/resources/routing_details.py b/src/modern_treasury/resources/routing_details.py index 06ae80a9..e19bf06e 100644 --- a/src/modern_treasury/resources/routing_details.py +++ b/src/modern_treasury/resources/routing_details.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import TYPE_CHECKING, Optional from typing_extensions import Literal from ..types import ( @@ -13,14 +13,24 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.shared import AccountsType +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["RoutingDetails", "AsyncRoutingDetails"] class RoutingDetails(SyncAPIResource): + with_raw_response: RoutingDetailsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = RoutingDetailsWithRawResponse(self) + def create( self, account_id: str, @@ -244,6 +254,12 @@ def delete( class AsyncRoutingDetails(AsyncAPIResource): + with_raw_response: AsyncRoutingDetailsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncRoutingDetailsWithRawResponse(self) + async def create( self, account_id: str, @@ -464,3 +480,35 @@ async def delete( ), cast_to=NoneType, ) + + +class RoutingDetailsWithRawResponse: + def __init__(self, routing_details: RoutingDetails) -> None: + self.create = to_raw_response_wrapper( + routing_details.create, + ) + self.retrieve = to_raw_response_wrapper( + routing_details.retrieve, + ) + self.list = to_raw_response_wrapper( + routing_details.list, + ) + self.delete = to_raw_response_wrapper( + routing_details.delete, + ) + + +class AsyncRoutingDetailsWithRawResponse: + def __init__(self, routing_details: AsyncRoutingDetails) -> None: + self.create = async_to_raw_response_wrapper( + routing_details.create, + ) + self.retrieve = async_to_raw_response_wrapper( + routing_details.retrieve, + ) + self.list = async_to_raw_response_wrapper( + routing_details.list, + ) + self.delete = async_to_raw_response_wrapper( + routing_details.delete, + ) diff --git a/src/modern_treasury/resources/transactions/__init__.py b/src/modern_treasury/resources/transactions/__init__.py index 1444d0e0..6c7664ff 100644 --- a/src/modern_treasury/resources/transactions/__init__.py +++ b/src/modern_treasury/resources/transactions/__init__.py @@ -1,6 +1,25 @@ # File generated from our OpenAPI spec by Stainless. -from .line_items import LineItems, AsyncLineItems -from .transactions import Transactions, AsyncTransactions +from .line_items import ( + LineItems, + AsyncLineItems, + LineItemsWithRawResponse, + AsyncLineItemsWithRawResponse, +) +from .transactions import ( + Transactions, + AsyncTransactions, + TransactionsWithRawResponse, + AsyncTransactionsWithRawResponse, +) -__all__ = ["LineItems", "AsyncLineItems", "Transactions", "AsyncTransactions"] +__all__ = [ + "LineItems", + "AsyncLineItems", + "LineItemsWithRawResponse", + "AsyncLineItemsWithRawResponse", + "Transactions", + "AsyncTransactions", + "TransactionsWithRawResponse", + "AsyncTransactionsWithRawResponse", +] diff --git a/src/modern_treasury/resources/transactions/line_items.py b/src/modern_treasury/resources/transactions/line_items.py index 52eaf167..eee9681b 100644 --- a/src/modern_treasury/resources/transactions/line_items.py +++ b/src/modern_treasury/resources/transactions/line_items.py @@ -2,20 +2,30 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import TYPE_CHECKING, Dict, Optional from typing_extensions import Literal from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options from ...types.transactions import TransactionLineItem, line_item_list_params +if TYPE_CHECKING: + from ..._client import ModernTreasury, AsyncModernTreasury + __all__ = ["LineItems", "AsyncLineItems"] class LineItems(SyncAPIResource): + with_raw_response: LineItemsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = LineItemsWithRawResponse(self) + def retrieve( self, id: str, @@ -98,6 +108,12 @@ def list( class AsyncLineItems(AsyncAPIResource): + with_raw_response: AsyncLineItemsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncLineItemsWithRawResponse(self) + async def retrieve( self, id: str, @@ -177,3 +193,23 @@ def list( ), model=TransactionLineItem, ) + + +class LineItemsWithRawResponse: + def __init__(self, line_items: LineItems) -> None: + self.retrieve = to_raw_response_wrapper( + line_items.retrieve, + ) + self.list = to_raw_response_wrapper( + line_items.list, + ) + + +class AsyncLineItemsWithRawResponse: + def __init__(self, line_items: AsyncLineItems) -> None: + self.retrieve = async_to_raw_response_wrapper( + line_items.retrieve, + ) + self.list = async_to_raw_response_wrapper( + line_items.list, + ) diff --git a/src/modern_treasury/resources/transactions/transactions.py b/src/modern_treasury/resources/transactions/transactions.py index c42fc3d2..68722838 100644 --- a/src/modern_treasury/resources/transactions/transactions.py +++ b/src/modern_treasury/resources/transactions/transactions.py @@ -8,8 +8,14 @@ from ...types import Transaction, transaction_list_params, transaction_update_params from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform -from .line_items import LineItems, AsyncLineItems +from .line_items import ( + LineItems, + AsyncLineItems, + LineItemsWithRawResponse, + AsyncLineItemsWithRawResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ...pagination import SyncPage, AsyncPage from ..._base_client import AsyncPaginator, make_request_options @@ -21,10 +27,12 @@ class Transactions(SyncAPIResource): line_items: LineItems + with_raw_response: TransactionsWithRawResponse def __init__(self, client: ModernTreasury) -> None: super().__init__(client) self.line_items = LineItems(client) + self.with_raw_response = TransactionsWithRawResponse(self) def retrieve( self, @@ -190,10 +198,12 @@ def list( class AsyncTransactions(AsyncAPIResource): line_items: AsyncLineItems + with_raw_response: AsyncTransactionsWithRawResponse def __init__(self, client: AsyncModernTreasury) -> None: super().__init__(client) self.line_items = AsyncLineItems(client) + self.with_raw_response = AsyncTransactionsWithRawResponse(self) async def retrieve( self, @@ -355,3 +365,33 @@ def list( ), model=Transaction, ) + + +class TransactionsWithRawResponse: + def __init__(self, transactions: Transactions) -> None: + self.line_items = LineItemsWithRawResponse(transactions.line_items) + + self.retrieve = to_raw_response_wrapper( + transactions.retrieve, + ) + self.update = to_raw_response_wrapper( + transactions.update, + ) + self.list = to_raw_response_wrapper( + transactions.list, + ) + + +class AsyncTransactionsWithRawResponse: + def __init__(self, transactions: AsyncTransactions) -> None: + self.line_items = AsyncLineItemsWithRawResponse(transactions.line_items) + + self.retrieve = async_to_raw_response_wrapper( + transactions.retrieve, + ) + self.update = async_to_raw_response_wrapper( + transactions.update, + ) + self.list = async_to_raw_response_wrapper( + transactions.list, + ) diff --git a/src/modern_treasury/resources/validations.py b/src/modern_treasury/resources/validations.py index 516cf9c8..2d752f32 100644 --- a/src/modern_treasury/resources/validations.py +++ b/src/modern_treasury/resources/validations.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import TYPE_CHECKING from typing_extensions import Literal from ..types import ( @@ -11,12 +12,22 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Validations", "AsyncValidations"] class Validations(SyncAPIResource): + with_raw_response: ValidationsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = ValidationsWithRawResponse(self) + def validate_routing_number( self, *, @@ -84,6 +95,12 @@ def validate_routing_number( class AsyncValidations(AsyncAPIResource): + with_raw_response: AsyncValidationsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncValidationsWithRawResponse(self) + async def validate_routing_number( self, *, @@ -148,3 +165,17 @@ async def validate_routing_number( ), cast_to=RoutingNumberLookupRequest, ) + + +class ValidationsWithRawResponse: + def __init__(self, validations: Validations) -> None: + self.validate_routing_number = to_raw_response_wrapper( + validations.validate_routing_number, + ) + + +class AsyncValidationsWithRawResponse: + def __init__(self, validations: AsyncValidations) -> None: + self.validate_routing_number = async_to_raw_response_wrapper( + validations.validate_routing_number, + ) diff --git a/src/modern_treasury/resources/virtual_accounts.py b/src/modern_treasury/resources/virtual_accounts.py index 92f84735..5c44ec7e 100644 --- a/src/modern_treasury/resources/virtual_accounts.py +++ b/src/modern_treasury/resources/virtual_accounts.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, List, Optional +from typing import TYPE_CHECKING, Dict, List, Optional from ..types import ( VirtualAccount, @@ -13,13 +13,23 @@ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["VirtualAccounts", "AsyncVirtualAccounts"] class VirtualAccounts(SyncAPIResource): + with_raw_response: VirtualAccountsWithRawResponse + + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = VirtualAccountsWithRawResponse(self) + def create( self, *, @@ -276,6 +286,12 @@ def delete( class AsyncVirtualAccounts(AsyncAPIResource): + with_raw_response: AsyncVirtualAccountsWithRawResponse + + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + self.with_raw_response = AsyncVirtualAccountsWithRawResponse(self) + async def create( self, *, @@ -529,3 +545,41 @@ async def delete( ), cast_to=VirtualAccount, ) + + +class VirtualAccountsWithRawResponse: + def __init__(self, virtual_accounts: VirtualAccounts) -> None: + self.create = to_raw_response_wrapper( + virtual_accounts.create, + ) + self.retrieve = to_raw_response_wrapper( + virtual_accounts.retrieve, + ) + self.update = to_raw_response_wrapper( + virtual_accounts.update, + ) + self.list = to_raw_response_wrapper( + virtual_accounts.list, + ) + self.delete = to_raw_response_wrapper( + virtual_accounts.delete, + ) + + +class AsyncVirtualAccountsWithRawResponse: + def __init__(self, virtual_accounts: AsyncVirtualAccounts) -> None: + self.create = async_to_raw_response_wrapper( + virtual_accounts.create, + ) + self.retrieve = async_to_raw_response_wrapper( + virtual_accounts.retrieve, + ) + self.update = async_to_raw_response_wrapper( + virtual_accounts.update, + ) + self.list = async_to_raw_response_wrapper( + virtual_accounts.list, + ) + self.delete = async_to_raw_response_wrapper( + virtual_accounts.delete, + ) diff --git a/src/modern_treasury/resources/webhooks.py b/src/modern_treasury/resources/webhooks.py index d20b830e..5fddd4c5 100644 --- a/src/modern_treasury/resources/webhooks.py +++ b/src/modern_treasury/resources/webhooks.py @@ -3,16 +3,23 @@ from __future__ import annotations import hmac +from typing import TYPE_CHECKING from hashlib import sha256 from .._types import HeadersLike from .._utils import get_required_header from .._resource import SyncAPIResource, AsyncAPIResource +if TYPE_CHECKING: + from .._client import ModernTreasury, AsyncModernTreasury + __all__ = ["Webhooks", "AsyncWebhooks"] class Webhooks(SyncAPIResource): + def __init__(self, client: ModernTreasury) -> None: + super().__init__(client) + def get_signature( self, payload: str, @@ -63,6 +70,9 @@ def validate_signature( class AsyncWebhooks(AsyncAPIResource): + def __init__(self, client: AsyncModernTreasury) -> None: + super().__init__(client) + def get_signature( self, payload: str, diff --git a/tests/api_resources/internal_accounts/test_balance_reports.py b/tests/api_resources/internal_accounts/test_balance_reports.py index 98dcf966..8aa6c963 100644 --- a/tests/api_resources/internal_accounts/test_balance_reports.py +++ b/tests/api_resources/internal_accounts/test_balance_reports.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury._utils import parse_date +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage from modern_treasury.types.internal_accounts import BalanceReport @@ -34,6 +35,16 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(BalanceReport, balance_report, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.internal_accounts.balance_reports.with_raw_response.retrieve( + "string", + internal_account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + balance_report = response.parse() + assert_matches_type(BalanceReport, balance_report, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: balance_report = client.internal_accounts.balance_reports.list( @@ -52,6 +63,15 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[BalanceReport], balance_report, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.internal_accounts.balance_reports.with_raw_response.list( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + balance_report = response.parse() + assert_matches_type(SyncPage[BalanceReport], balance_report, path=["response"]) + class TestAsyncBalanceReports: strict_client = AsyncModernTreasury( @@ -70,6 +90,16 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(BalanceReport, balance_report, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.internal_accounts.balance_reports.with_raw_response.retrieve( + "string", + internal_account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + balance_report = response.parse() + assert_matches_type(BalanceReport, balance_report, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: balance_report = await client.internal_accounts.balance_reports.list( @@ -87,3 +117,12 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> per_page=0, ) assert_matches_type(AsyncPage[BalanceReport], balance_report, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.internal_accounts.balance_reports.with_raw_response.list( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + balance_report = response.parse() + assert_matches_type(AsyncPage[BalanceReport], balance_report, path=["response"]) diff --git a/tests/api_resources/invoices/test_line_items.py b/tests/api_resources/invoices/test_line_items.py index b438a52a..85241227 100644 --- a/tests/api_resources/invoices/test_line_items.py +++ b/tests/api_resources/invoices/test_line_items.py @@ -8,6 +8,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage from modern_treasury.types.invoices import InvoiceLineItem @@ -46,6 +47,17 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.invoices.line_items.with_raw_response.create( + "string", + name="string", + unit_amount=0, + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: line_item = client.invoices.line_items.retrieve( @@ -54,6 +66,16 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.invoices.line_items.with_raw_response.retrieve( + "string", + invoice_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: line_item = client.invoices.line_items.update( @@ -75,6 +97,16 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.invoices.line_items.with_raw_response.update( + "string", + invoice_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: line_item = client.invoices.line_items.list( @@ -91,6 +123,15 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[InvoiceLineItem], line_item, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.invoices.line_items.with_raw_response.list( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(SyncPage[InvoiceLineItem], line_item, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: line_item = client.invoices.line_items.delete( @@ -99,6 +140,16 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.invoices.line_items.with_raw_response.delete( + "string", + invoice_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + class TestAsyncLineItems: strict_client = AsyncModernTreasury( @@ -130,6 +181,17 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.line_items.with_raw_response.create( + "string", + name="string", + unit_amount=0, + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: line_item = await client.invoices.line_items.retrieve( @@ -138,6 +200,16 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.line_items.with_raw_response.retrieve( + "string", + invoice_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: line_item = await client.invoices.line_items.update( @@ -159,6 +231,16 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.line_items.with_raw_response.update( + "string", + invoice_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: line_item = await client.invoices.line_items.list( @@ -175,6 +257,15 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[InvoiceLineItem], line_item, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.line_items.with_raw_response.list( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(AsyncPage[InvoiceLineItem], line_item, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: line_item = await client.invoices.line_items.delete( @@ -182,3 +273,13 @@ async def test_method_delete(self, client: AsyncModernTreasury) -> None: invoice_id="string", ) assert_matches_type(InvoiceLineItem, line_item, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.line_items.with_raw_response.delete( + "string", + invoice_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(InvoiceLineItem, line_item, path=["response"]) diff --git a/tests/api_resources/ledger_transactions/test_versions.py b/tests/api_resources/ledger_transactions/test_versions.py index 3b7c67a7..2f0273b9 100644 --- a/tests/api_resources/ledger_transactions/test_versions.py +++ b/tests/api_resources/ledger_transactions/test_versions.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury._utils import parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage from modern_treasury.types.ledger_transactions import LedgerTransactionVersion @@ -43,6 +44,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerTransactionVersion], version, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_transactions.versions.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(SyncPage[LedgerTransactionVersion], version, path=["response"]) + class TestAsyncVersions: strict_client = AsyncModernTreasury( @@ -69,3 +77,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> version={"foo": 0}, ) assert_matches_type(AsyncPage[LedgerTransactionVersion], version, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_transactions.versions.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + version = response.parse() + assert_matches_type(AsyncPage[LedgerTransactionVersion], version, path=["response"]) diff --git a/tests/api_resources/payment_orders/test_reversals.py b/tests/api_resources/payment_orders/test_reversals.py index 1a5a416e..e74416b0 100644 --- a/tests/api_resources/payment_orders/test_reversals.py +++ b/tests/api_resources/payment_orders/test_reversals.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage from modern_treasury.types.payment_orders import Reversal @@ -108,6 +109,16 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.payment_orders.reversals.with_raw_response.create( + "string", + reason="duplicate", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reversal = response.parse() + assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: reversal = client.payment_orders.reversals.retrieve( @@ -116,6 +127,16 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.payment_orders.reversals.with_raw_response.retrieve( + "string", + payment_order_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reversal = response.parse() + assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: reversal = client.payment_orders.reversals.list( @@ -132,6 +153,15 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Reversal], reversal, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.payment_orders.reversals.with_raw_response.list( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reversal = response.parse() + assert_matches_type(SyncPage[Reversal], reversal, path=["response"]) + class TestAsyncReversals: strict_client = AsyncModernTreasury( @@ -224,6 +254,16 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.reversals.with_raw_response.create( + "string", + reason="duplicate", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reversal = response.parse() + assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: reversal = await client.payment_orders.reversals.retrieve( @@ -232,6 +272,16 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.reversals.with_raw_response.retrieve( + "string", + payment_order_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reversal = response.parse() + assert_matches_type(Reversal, reversal, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: reversal = await client.payment_orders.reversals.list( @@ -247,3 +297,12 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> per_page=0, ) assert_matches_type(AsyncPage[Reversal], reversal, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.reversals.with_raw_response.list( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reversal = response.parse() + assert_matches_type(AsyncPage[Reversal], reversal, path=["response"]) diff --git a/tests/api_resources/test_account_collection_flows.py b/tests/api_resources/test_account_collection_flows.py index e0d3d037..23da271f 100644 --- a/tests/api_resources/test_account_collection_flows.py +++ b/tests/api_resources/test_account_collection_flows.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import AccountCollectionFlow +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -42,6 +43,16 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.account_collection_flows.with_raw_response.create( + counterparty_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + payment_types=["string", "string", "string"], + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: account_collection_flow = client.account_collection_flows.retrieve( @@ -49,6 +60,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.account_collection_flows.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: account_collection_flow = client.account_collection_flows.update( @@ -57,6 +77,16 @@ def test_method_update(self, client: ModernTreasury) -> None: ) assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.account_collection_flows.with_raw_response.update( + "string", + status="cancelled", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: account_collection_flow = client.account_collection_flows.list() @@ -74,6 +104,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[AccountCollectionFlow], account_collection_flow, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.account_collection_flows.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(SyncPage[AccountCollectionFlow], account_collection_flow, path=["response"]) + class TestAsyncAccountCollectionFlows: strict_client = AsyncModernTreasury( @@ -101,6 +138,16 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.account_collection_flows.with_raw_response.create( + counterparty_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + payment_types=["string", "string", "string"], + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: account_collection_flow = await client.account_collection_flows.retrieve( @@ -108,6 +155,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.account_collection_flows.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: account_collection_flow = await client.account_collection_flows.update( @@ -116,6 +172,16 @@ async def test_method_update(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.account_collection_flows.with_raw_response.update( + "string", + status="cancelled", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(AccountCollectionFlow, account_collection_flow, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: account_collection_flow = await client.account_collection_flows.list() @@ -132,3 +198,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> status="string", ) assert_matches_type(AsyncPage[AccountCollectionFlow], account_collection_flow, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.account_collection_flows.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_collection_flow = response.parse() + assert_matches_type(AsyncPage[AccountCollectionFlow], account_collection_flow, path=["response"]) diff --git a/tests/api_resources/test_account_details.py b/tests/api_resources/test_account_details.py index fc907ba7..bef05fcb 100644 --- a/tests/api_resources/test_account_details.py +++ b/tests/api_resources/test_account_details.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import AccountDetail +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -44,6 +45,17 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.account_details.with_raw_response.create( + "string", + accounts_type="external_accounts", + account_number="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: account_detail = client.account_details.retrieve( @@ -53,6 +65,17 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.account_details.with_raw_response.retrieve( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: account_detail = client.account_details.list( @@ -71,6 +94,16 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[AccountDetail], account_detail, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.account_details.with_raw_response.list( + "string", + accounts_type="external_accounts", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert_matches_type(SyncPage[AccountDetail], account_detail, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: account_detail = client.account_details.delete( @@ -80,6 +113,17 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert account_detail is None + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.account_details.with_raw_response.delete( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert account_detail is None + class TestAsyncAccountDetails: strict_client = AsyncModernTreasury( @@ -109,6 +153,17 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.account_details.with_raw_response.create( + "string", + accounts_type="external_accounts", + account_number="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: account_detail = await client.account_details.retrieve( @@ -118,6 +173,17 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.account_details.with_raw_response.retrieve( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert_matches_type(AccountDetail, account_detail, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: account_detail = await client.account_details.list( @@ -136,6 +202,16 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[AccountDetail], account_detail, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.account_details.with_raw_response.list( + "string", + accounts_type="external_accounts", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert_matches_type(AsyncPage[AccountDetail], account_detail, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: account_detail = await client.account_details.delete( @@ -144,3 +220,14 @@ async def test_method_delete(self, client: AsyncModernTreasury) -> None: account_id="string", ) assert account_detail is None + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.account_details.with_raw_response.delete( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_detail = response.parse() + assert account_detail is None diff --git a/tests/api_resources/test_connections.py b/tests/api_resources/test_connections.py index abaac2b0..c607e565 100644 --- a/tests/api_resources/test_connections.py +++ b/tests/api_resources/test_connections.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import Connection +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -40,6 +41,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Connection], connection, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.connections.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connection = response.parse() + assert_matches_type(SyncPage[Connection], connection, path=["response"]) + class TestAsyncConnections: strict_client = AsyncModernTreasury( @@ -64,3 +72,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> vendor_customer_id="string", ) assert_matches_type(AsyncPage[Connection], connection, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.connections.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connection = response.parse() + assert_matches_type(AsyncPage[Connection], connection, path=["response"]) diff --git a/tests/api_resources/test_counterparties.py b/tests/api_resources/test_counterparties.py index 2a6620c7..6da22f8c 100644 --- a/tests/api_resources/test_counterparties.py +++ b/tests/api_resources/test_counterparties.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import Counterparty, CounterpartyCollectAccountResponse from modern_treasury._utils import parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -296,6 +297,15 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.counterparties.with_raw_response.create( + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: counterparty = client.counterparties.retrieve( @@ -303,6 +313,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.counterparties.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: counterparty = client.counterparties.update( @@ -322,6 +341,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.counterparties.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: counterparty = client.counterparties.list() @@ -340,6 +368,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Counterparty], counterparty, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.counterparties.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(SyncPage[Counterparty], counterparty, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: counterparty = client.counterparties.delete( @@ -347,6 +382,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert counterparty is None + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.counterparties.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert counterparty is None + @parametrize def test_method_collect_account(self, client: ModernTreasury) -> None: counterparty = client.counterparties.collect_account( @@ -366,6 +410,16 @@ def test_method_collect_account_with_all_params(self, client: ModernTreasury) -> ) assert_matches_type(CounterpartyCollectAccountResponse, counterparty, path=["response"]) + @parametrize + def test_raw_response_collect_account(self, client: ModernTreasury) -> None: + response = client.counterparties.with_raw_response.collect_account( + "string", + direction="credit", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(CounterpartyCollectAccountResponse, counterparty, path=["response"]) + class TestAsyncCounterparties: strict_client = AsyncModernTreasury( @@ -646,6 +700,15 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.counterparties.with_raw_response.create( + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: counterparty = await client.counterparties.retrieve( @@ -653,6 +716,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.counterparties.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: counterparty = await client.counterparties.update( @@ -672,6 +744,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.counterparties.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(Counterparty, counterparty, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: counterparty = await client.counterparties.list() @@ -690,6 +771,13 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[Counterparty], counterparty, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.counterparties.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(AsyncPage[Counterparty], counterparty, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: counterparty = await client.counterparties.delete( @@ -697,6 +785,15 @@ async def test_method_delete(self, client: AsyncModernTreasury) -> None: ) assert counterparty is None + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.counterparties.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert counterparty is None + @parametrize async def test_method_collect_account(self, client: AsyncModernTreasury) -> None: counterparty = await client.counterparties.collect_account( @@ -715,3 +812,13 @@ async def test_method_collect_account_with_all_params(self, client: AsyncModernT send_email=True, ) assert_matches_type(CounterpartyCollectAccountResponse, counterparty, path=["response"]) + + @parametrize + async def test_raw_response_collect_account(self, client: AsyncModernTreasury) -> None: + response = await client.counterparties.with_raw_response.collect_account( + "string", + direction="credit", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + counterparty = response.parse() + assert_matches_type(CounterpartyCollectAccountResponse, counterparty, path=["response"]) diff --git a/tests/api_resources/test_documents.py b/tests/api_resources/test_documents.py index 370d46b9..518174cc 100644 --- a/tests/api_resources/test_documents.py +++ b/tests/api_resources/test_documents.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import Document +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -44,6 +45,17 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Document, document, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.documents.with_raw_response.create( + documentable_id="string", + documentable_type="cases", + file=b"raw file contents", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = response.parse() + assert_matches_type(Document, document, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: document = client.documents.retrieve( @@ -51,6 +63,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(Document, document, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.documents.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = response.parse() + assert_matches_type(Document, document, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: document = client.documents.list() @@ -66,6 +87,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Document], document, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.documents.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = response.parse() + assert_matches_type(SyncPage[Document], document, path=["response"]) + class TestAsyncDocuments: strict_client = AsyncModernTreasury( @@ -95,6 +123,17 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Document, document, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.documents.with_raw_response.create( + documentable_id="string", + documentable_type="cases", + file=b"raw file contents", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = response.parse() + assert_matches_type(Document, document, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: document = await client.documents.retrieve( @@ -102,6 +141,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(Document, document, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.documents.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = response.parse() + assert_matches_type(Document, document, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: document = await client.documents.list() @@ -116,3 +164,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> per_page=0, ) assert_matches_type(AsyncPage[Document], document, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.documents.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = response.parse() + assert_matches_type(AsyncPage[Document], document, path=["response"]) diff --git a/tests/api_resources/test_events.py b/tests/api_resources/test_events.py index c6ed8168..87450b4c 100644 --- a/tests/api_resources/test_events.py +++ b/tests/api_resources/test_events.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import Event from modern_treasury._utils import parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -33,6 +34,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(Event, event, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.events.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + event = response.parse() + assert_matches_type(Event, event, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: event = client.events.list() @@ -51,6 +61,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Event], event, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.events.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + event = response.parse() + assert_matches_type(SyncPage[Event], event, path=["response"]) + class TestAsyncEvents: strict_client = AsyncModernTreasury( @@ -68,6 +85,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(Event, event, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.events.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + event = response.parse() + assert_matches_type(Event, event, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: event = await client.events.list() @@ -85,3 +111,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> resource="string", ) assert_matches_type(AsyncPage[Event], event, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.events.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + event = response.parse() + assert_matches_type(AsyncPage[Event], event, path=["response"]) diff --git a/tests/api_resources/test_expected_payments.py b/tests/api_resources/test_expected_payments.py index 064b5f99..1a68ef66 100644 --- a/tests/api_resources/test_expected_payments.py +++ b/tests/api_resources/test_expected_payments.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import ExpectedPayment from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -94,6 +95,18 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.expected_payments.with_raw_response.create( + amount_lower_bound=0, + amount_upper_bound=0, + direction="credit", + internal_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: expected_payment = client.expected_payments.retrieve( @@ -101,6 +114,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.expected_payments.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: expected_payment = client.expected_payments.update( @@ -135,6 +157,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.expected_payments.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: expected_payment = client.expected_payments.list() @@ -156,6 +187,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[ExpectedPayment], expected_payment, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.expected_payments.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(SyncPage[ExpectedPayment], expected_payment, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: expected_payment = client.expected_payments.delete( @@ -163,6 +201,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.expected_payments.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + class TestAsyncExpectedPayments: strict_client = AsyncModernTreasury( @@ -241,6 +288,18 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.expected_payments.with_raw_response.create( + amount_lower_bound=0, + amount_upper_bound=0, + direction="credit", + internal_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: expected_payment = await client.expected_payments.retrieve( @@ -248,6 +307,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.expected_payments.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: expected_payment = await client.expected_payments.update( @@ -282,6 +350,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.expected_payments.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: expected_payment = await client.expected_payments.list() @@ -303,9 +380,25 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[ExpectedPayment], expected_payment, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.expected_payments.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(AsyncPage[ExpectedPayment], expected_payment, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: expected_payment = await client.expected_payments.delete( "string", ) assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.expected_payments.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + expected_payment = response.parse() + assert_matches_type(ExpectedPayment, expected_payment, path=["response"]) diff --git a/tests/api_resources/test_external_accounts.py b/tests/api_resources/test_external_accounts.py index 9c447f4b..6f179b4c 100644 --- a/tests/api_resources/test_external_accounts.py +++ b/tests/api_resources/test_external_accounts.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import ExternalAccount +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -118,6 +119,15 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.external_accounts.with_raw_response.create( + counterparty_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: external_account = client.external_accounts.retrieve( @@ -125,6 +135,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.external_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: external_account = client.external_accounts.update( @@ -153,6 +172,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.external_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: external_account = client.external_accounts.list() @@ -169,6 +197,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[ExternalAccount], external_account, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.external_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(SyncPage[ExternalAccount], external_account, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: external_account = client.external_accounts.delete( @@ -176,6 +211,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert external_account is None + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.external_accounts.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert external_account is None + @parametrize def test_method_complete_verification(self, client: ModernTreasury) -> None: external_account = client.external_accounts.complete_verification( @@ -191,6 +235,15 @@ def test_method_complete_verification_with_all_params(self, client: ModernTreasu ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + def test_raw_response_complete_verification(self, client: ModernTreasury) -> None: + response = client.external_accounts.with_raw_response.complete_verification( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize def test_method_verify(self, client: ModernTreasury) -> None: external_account = client.external_accounts.verify( @@ -210,6 +263,17 @@ def test_method_verify_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + def test_raw_response_verify(self, client: ModernTreasury) -> None: + response = client.external_accounts.with_raw_response.verify( + "string", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + payment_type="ach", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + class TestAsyncExternalAccounts: strict_client = AsyncModernTreasury( @@ -313,6 +377,15 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.external_accounts.with_raw_response.create( + counterparty_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: external_account = await client.external_accounts.retrieve( @@ -320,6 +393,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.external_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: external_account = await client.external_accounts.update( @@ -348,6 +430,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.external_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: external_account = await client.external_accounts.list() @@ -364,6 +455,13 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[ExternalAccount], external_account, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.external_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(AsyncPage[ExternalAccount], external_account, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: external_account = await client.external_accounts.delete( @@ -371,6 +469,15 @@ async def test_method_delete(self, client: AsyncModernTreasury) -> None: ) assert external_account is None + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.external_accounts.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert external_account is None + @parametrize async def test_method_complete_verification(self, client: AsyncModernTreasury) -> None: external_account = await client.external_accounts.complete_verification( @@ -386,6 +493,15 @@ async def test_method_complete_verification_with_all_params(self, client: AsyncM ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize + async def test_raw_response_complete_verification(self, client: AsyncModernTreasury) -> None: + response = await client.external_accounts.with_raw_response.complete_verification( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) + @parametrize async def test_method_verify(self, client: AsyncModernTreasury) -> None: external_account = await client.external_accounts.verify( @@ -404,3 +520,14 @@ async def test_method_verify_with_all_params(self, client: AsyncModernTreasury) currency="AED", ) assert_matches_type(ExternalAccount, external_account, path=["response"]) + + @parametrize + async def test_raw_response_verify(self, client: AsyncModernTreasury) -> None: + response = await client.external_accounts.with_raw_response.verify( + "string", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + payment_type="ach", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + external_account = response.parse() + assert_matches_type(ExternalAccount, external_account, path=["response"]) diff --git a/tests/api_resources/test_incoming_payment_details.py b/tests/api_resources/test_incoming_payment_details.py index 22b8092a..c3a76de9 100644 --- a/tests/api_resources/test_incoming_payment_details.py +++ b/tests/api_resources/test_incoming_payment_details.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import IncomingPaymentDetail from modern_treasury._utils import parse_date +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage from modern_treasury.types.shared import AsyncResponse @@ -34,6 +35,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.incoming_payment_details.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: incoming_payment_detail = client.incoming_payment_details.update( @@ -49,6 +59,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.incoming_payment_details.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: incoming_payment_detail = client.incoming_payment_details.list() @@ -69,6 +88,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[IncomingPaymentDetail], incoming_payment_detail, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.incoming_payment_details.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(SyncPage[IncomingPaymentDetail], incoming_payment_detail, path=["response"]) + @parametrize def test_method_create_async(self, client: ModernTreasury) -> None: incoming_payment_detail = client.incoming_payment_details.create_async() @@ -88,6 +114,13 @@ def test_method_create_async_with_all_params(self, client: ModernTreasury) -> No ) assert_matches_type(AsyncResponse, incoming_payment_detail, path=["response"]) + @parametrize + def test_raw_response_create_async(self, client: ModernTreasury) -> None: + response = client.incoming_payment_details.with_raw_response.create_async() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(AsyncResponse, incoming_payment_detail, path=["response"]) + class TestAsyncIncomingPaymentDetails: strict_client = AsyncModernTreasury( @@ -105,6 +138,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.incoming_payment_details.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: incoming_payment_detail = await client.incoming_payment_details.update( @@ -120,6 +162,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.incoming_payment_details.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(IncomingPaymentDetail, incoming_payment_detail, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: incoming_payment_detail = await client.incoming_payment_details.list() @@ -140,6 +191,13 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[IncomingPaymentDetail], incoming_payment_detail, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.incoming_payment_details.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(AsyncPage[IncomingPaymentDetail], incoming_payment_detail, path=["response"]) + @parametrize async def test_method_create_async(self, client: AsyncModernTreasury) -> None: incoming_payment_detail = await client.incoming_payment_details.create_async() @@ -158,3 +216,10 @@ async def test_method_create_async_with_all_params(self, client: AsyncModernTrea virtual_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) assert_matches_type(AsyncResponse, incoming_payment_detail, path=["response"]) + + @parametrize + async def test_raw_response_create_async(self, client: AsyncModernTreasury) -> None: + response = await client.incoming_payment_details.with_raw_response.create_async() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + incoming_payment_detail = response.parse() + assert_matches_type(AsyncResponse, incoming_payment_detail, path=["response"]) diff --git a/tests/api_resources/test_internal_accounts.py b/tests/api_resources/test_internal_accounts.py index 0982d973..2d265e9b 100644 --- a/tests/api_resources/test_internal_accounts.py +++ b/tests/api_resources/test_internal_accounts.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import InternalAccount +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -60,6 +61,18 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.internal_accounts.with_raw_response.create( + connection_id="string", + currency="USD", + name="string", + party_name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: internal_account = client.internal_accounts.retrieve( @@ -67,6 +80,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.internal_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: internal_account = client.internal_accounts.update( @@ -86,6 +108,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.internal_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: internal_account = client.internal_accounts.list() @@ -104,6 +135,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[InternalAccount], internal_account, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.internal_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(SyncPage[InternalAccount], internal_account, path=["response"]) + class TestAsyncInternalAccounts: strict_client = AsyncModernTreasury( @@ -149,6 +187,18 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.internal_accounts.with_raw_response.create( + connection_id="string", + currency="USD", + name="string", + party_name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: internal_account = await client.internal_accounts.retrieve( @@ -156,6 +206,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.internal_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: internal_account = await client.internal_accounts.update( @@ -175,6 +234,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.internal_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(InternalAccount, internal_account, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: internal_account = await client.internal_accounts.list() @@ -192,3 +260,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> per_page=0, ) assert_matches_type(AsyncPage[InternalAccount], internal_account, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.internal_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + internal_account = response.parse() + assert_matches_type(AsyncPage[InternalAccount], internal_account, path=["response"]) diff --git a/tests/api_resources/test_invoices.py b/tests/api_resources/test_invoices.py index 276d971c..e2dad280 100644 --- a/tests/api_resources/test_invoices.py +++ b/tests/api_resources/test_invoices.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import Invoice from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -111,6 +112,17 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.invoices.with_raw_response.create( + counterparty_id="string", + due_date=parse_datetime("2019-12-27T18:11:19.117Z"), + originating_account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: invoice = client.invoices.retrieve( @@ -118,6 +130,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.invoices.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: invoice = client.invoices.update( @@ -203,6 +224,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.invoices.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: invoice = client.invoices.list() @@ -216,6 +246,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Invoice], invoice, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.invoices.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(SyncPage[Invoice], invoice, path=["response"]) + @parametrize def test_method_add_payment_order(self, client: ModernTreasury) -> None: invoice = client.invoices.add_payment_order( @@ -224,6 +261,16 @@ def test_method_add_payment_order(self, client: ModernTreasury) -> None: ) assert invoice is None + @parametrize + def test_raw_response_add_payment_order(self, client: ModernTreasury) -> None: + response = client.invoices.with_raw_response.add_payment_order( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert invoice is None + class TestAsyncInvoices: strict_client = AsyncModernTreasury( @@ -319,6 +366,17 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.with_raw_response.create( + counterparty_id="string", + due_date=parse_datetime("2019-12-27T18:11:19.117Z"), + originating_account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: invoice = await client.invoices.retrieve( @@ -326,6 +384,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: invoice = await client.invoices.update( @@ -411,6 +478,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(Invoice, invoice, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: invoice = await client.invoices.list() @@ -424,6 +500,13 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[Invoice], invoice, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert_matches_type(AsyncPage[Invoice], invoice, path=["response"]) + @parametrize async def test_method_add_payment_order(self, client: AsyncModernTreasury) -> None: invoice = await client.invoices.add_payment_order( @@ -431,3 +514,13 @@ async def test_method_add_payment_order(self, client: AsyncModernTreasury) -> No id="string", ) assert invoice is None + + @parametrize + async def test_raw_response_add_payment_order(self, client: AsyncModernTreasury) -> None: + response = await client.invoices.with_raw_response.add_payment_order( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + invoice = response.parse() + assert invoice is None diff --git a/tests/api_resources/test_ledger_account_balance_monitors.py b/tests/api_resources/test_ledger_account_balance_monitors.py index 1e96bd1d..62852cd9 100644 --- a/tests/api_resources/test_ledger_account_balance_monitors.py +++ b/tests/api_resources/test_ledger_account_balance_monitors.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerAccountBalanceMonitor +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -55,6 +56,20 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledger_account_balance_monitors.with_raw_response.create( + alert_condition={ + "field": "string", + "operator": "string", + "value": 0, + }, + ledger_account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger_account_balance_monitor = client.ledger_account_balance_monitors.retrieve( @@ -62,6 +77,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_account_balance_monitors.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: ledger_account_balance_monitor = client.ledger_account_balance_monitors.update( @@ -82,6 +106,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.ledger_account_balance_monitors.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger_account_balance_monitor = client.ledger_account_balance_monitors.list() @@ -98,6 +131,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerAccountBalanceMonitor], ledger_account_balance_monitor, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_account_balance_monitors.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(SyncPage[LedgerAccountBalanceMonitor], ledger_account_balance_monitor, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: ledger_account_balance_monitor = client.ledger_account_balance_monitors.delete( @@ -105,6 +145,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.ledger_account_balance_monitors.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + class TestAsyncLedgerAccountBalanceMonitors: strict_client = AsyncModernTreasury( @@ -145,6 +194,20 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_balance_monitors.with_raw_response.create( + alert_condition={ + "field": "string", + "operator": "string", + "value": 0, + }, + ledger_account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger_account_balance_monitor = await client.ledger_account_balance_monitors.retrieve( @@ -152,6 +215,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_balance_monitors.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: ledger_account_balance_monitor = await client.ledger_account_balance_monitors.update( @@ -172,6 +244,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_balance_monitors.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger_account_balance_monitor = await client.ledger_account_balance_monitors.list() @@ -188,9 +269,25 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[LedgerAccountBalanceMonitor], ledger_account_balance_monitor, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_balance_monitors.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(AsyncPage[LedgerAccountBalanceMonitor], ledger_account_balance_monitor, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: ledger_account_balance_monitor = await client.ledger_account_balance_monitors.delete( "string", ) assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_balance_monitors.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_balance_monitor = response.parse() + assert_matches_type(LedgerAccountBalanceMonitor, ledger_account_balance_monitor, path=["response"]) diff --git a/tests/api_resources/test_ledger_account_categories.py b/tests/api_resources/test_ledger_account_categories.py index 6de3ef64..5d8ece45 100644 --- a/tests/api_resources/test_ledger_account_categories.py +++ b/tests/api_resources/test_ledger_account_categories.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerAccountCategory from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -53,6 +54,18 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.create( + currency="string", + ledger_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + name="string", + normal_balance="credit", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.retrieve( @@ -71,6 +84,15 @@ def test_method_retrieve_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.update( @@ -92,6 +114,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.list() @@ -112,6 +143,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerAccountCategory], ledger_account_category, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(SyncPage[LedgerAccountCategory], ledger_account_category, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.delete( @@ -119,6 +157,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize def test_method_add_ledger_account(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.add_ledger_account( @@ -127,6 +174,16 @@ def test_method_add_ledger_account(self, client: ModernTreasury) -> None: ) assert ledger_account_category is None + @parametrize + def test_raw_response_add_ledger_account(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.add_ledger_account( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None + @parametrize def test_method_add_nested_category(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.add_nested_category( @@ -135,6 +192,16 @@ def test_method_add_nested_category(self, client: ModernTreasury) -> None: ) assert ledger_account_category is None + @parametrize + def test_raw_response_add_nested_category(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.add_nested_category( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None + @parametrize def test_method_remove_ledger_account(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.remove_ledger_account( @@ -143,6 +210,16 @@ def test_method_remove_ledger_account(self, client: ModernTreasury) -> None: ) assert ledger_account_category is None + @parametrize + def test_raw_response_remove_ledger_account(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.remove_ledger_account( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None + @parametrize def test_method_remove_nested_category(self, client: ModernTreasury) -> None: ledger_account_category = client.ledger_account_categories.remove_nested_category( @@ -151,6 +228,16 @@ def test_method_remove_nested_category(self, client: ModernTreasury) -> None: ) assert ledger_account_category is None + @parametrize + def test_raw_response_remove_nested_category(self, client: ModernTreasury) -> None: + response = client.ledger_account_categories.with_raw_response.remove_nested_category( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None + class TestAsyncLedgerAccountCategories: strict_client = AsyncModernTreasury( @@ -188,6 +275,18 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.create( + currency="string", + ledger_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + name="string", + normal_balance="credit", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.retrieve( @@ -206,6 +305,15 @@ async def test_method_retrieve_with_all_params(self, client: AsyncModernTreasury ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.update( @@ -227,6 +335,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.list() @@ -247,6 +364,13 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[LedgerAccountCategory], ledger_account_category, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(AsyncPage[LedgerAccountCategory], ledger_account_category, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.delete( @@ -254,6 +378,15 @@ async def test_method_delete(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert_matches_type(LedgerAccountCategory, ledger_account_category, path=["response"]) + @parametrize async def test_method_add_ledger_account(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.add_ledger_account( @@ -262,6 +395,16 @@ async def test_method_add_ledger_account(self, client: AsyncModernTreasury) -> N ) assert ledger_account_category is None + @parametrize + async def test_raw_response_add_ledger_account(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.add_ledger_account( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None + @parametrize async def test_method_add_nested_category(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.add_nested_category( @@ -270,6 +413,16 @@ async def test_method_add_nested_category(self, client: AsyncModernTreasury) -> ) assert ledger_account_category is None + @parametrize + async def test_raw_response_add_nested_category(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.add_nested_category( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None + @parametrize async def test_method_remove_ledger_account(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.remove_ledger_account( @@ -278,6 +431,16 @@ async def test_method_remove_ledger_account(self, client: AsyncModernTreasury) - ) assert ledger_account_category is None + @parametrize + async def test_raw_response_remove_ledger_account(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.remove_ledger_account( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None + @parametrize async def test_method_remove_nested_category(self, client: AsyncModernTreasury) -> None: ledger_account_category = await client.ledger_account_categories.remove_nested_category( @@ -285,3 +448,13 @@ async def test_method_remove_nested_category(self, client: AsyncModernTreasury) id="string", ) assert ledger_account_category is None + + @parametrize + async def test_raw_response_remove_nested_category(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_categories.with_raw_response.remove_nested_category( + "string", + id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_category = response.parse() + assert ledger_account_category is None diff --git a/tests/api_resources/test_ledger_account_payouts.py b/tests/api_resources/test_ledger_account_payouts.py index 5991bbf5..9ba9d15b 100644 --- a/tests/api_resources/test_ledger_account_payouts.py +++ b/tests/api_resources/test_ledger_account_payouts.py @@ -10,8 +10,11 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerAccountPayout from modern_treasury._utils import parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") api_key = "My API Key" organization_id = "my-organization-ID" @@ -52,6 +55,16 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledger_account_payouts.with_raw_response.create( + funding_ledger_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + payout_ledger_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger_account_payout = client.ledger_account_payouts.retrieve( @@ -59,6 +72,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_account_payouts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: ledger_account_payout = client.ledger_account_payouts.update( @@ -80,6 +102,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.ledger_account_payouts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger_account_payout = client.ledger_account_payouts.list() @@ -97,12 +128,29 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerAccountPayout], ledger_account_payout, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_account_payouts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(SyncPage[LedgerAccountPayout], ledger_account_payout, path=["response"]) + @parametrize def test_method_retireve(self, client: ModernTreasury) -> None: with pytest.warns(DeprecationWarning): - ledger_account_payout = client.ledger_account_payouts.retireve( # pyright: ignore[reportDeprecated] + ledger_account_payout = client.ledger_account_payouts.retireve( + "string", + ) + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + + @parametrize + def test_raw_response_retireve(self, client: ModernTreasury) -> None: + with pytest.warns(DeprecationWarning): + response = client.ledger_account_payouts.with_raw_response.retireve( "string", ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) @@ -141,6 +189,16 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_payouts.with_raw_response.create( + funding_ledger_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + payout_ledger_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger_account_payout = await client.ledger_account_payouts.retrieve( @@ -148,6 +206,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_payouts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: ledger_account_payout = await client.ledger_account_payouts.update( @@ -169,6 +236,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_payouts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger_account_payout = await client.ledger_account_payouts.list() @@ -186,10 +262,27 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[LedgerAccountPayout], ledger_account_payout, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_payouts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() + assert_matches_type(AsyncPage[LedgerAccountPayout], ledger_account_payout, path=["response"]) + @parametrize async def test_method_retireve(self, client: AsyncModernTreasury) -> None: with pytest.warns(DeprecationWarning): - ledger_account_payout = await client.ledger_account_payouts.retireve( # pyright: ignore[reportDeprecated] + ledger_account_payout = await client.ledger_account_payouts.retireve( + "string", + ) + assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) + + @parametrize + async def test_raw_response_retireve(self, client: AsyncModernTreasury) -> None: + with pytest.warns(DeprecationWarning): + response = await client.ledger_account_payouts.with_raw_response.retireve( "string", ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_payout = response.parse() assert_matches_type(LedgerAccountPayout, ledger_account_payout, path=["response"]) diff --git a/tests/api_resources/test_ledger_account_statements.py b/tests/api_resources/test_ledger_account_statements.py index 4936ef2d..cc792d36 100644 --- a/tests/api_resources/test_ledger_account_statements.py +++ b/tests/api_resources/test_ledger_account_statements.py @@ -13,6 +13,7 @@ LedgerAccountStatementRetrieveResponse, ) from modern_treasury._utils import parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") api_key = "My API Key" @@ -54,6 +55,18 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountStatementCreateResponse, ledger_account_statement, path=["response"]) + @pytest.mark.skip(reason="Prism is broken in this case") + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledger_account_statements.with_raw_response.create( + effective_at_lower_bound=parse_datetime("2019-12-27T18:11:19.117Z"), + effective_at_upper_bound=parse_datetime("2019-12-27T18:11:19.117Z"), + ledger_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_statement = response.parse() + assert_matches_type(LedgerAccountStatementCreateResponse, ledger_account_statement, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger_account_statement = client.ledger_account_statements.retrieve( @@ -61,6 +74,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccountStatementRetrieveResponse, ledger_account_statement, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_account_statements.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_statement = response.parse() + assert_matches_type(LedgerAccountStatementRetrieveResponse, ledger_account_statement, path=["response"]) + class TestAsyncLedgerAccountStatements: strict_client = AsyncModernTreasury( @@ -97,9 +119,30 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccountStatementCreateResponse, ledger_account_statement, path=["response"]) + @pytest.mark.skip(reason="Prism is broken in this case") + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_statements.with_raw_response.create( + effective_at_lower_bound=parse_datetime("2019-12-27T18:11:19.117Z"), + effective_at_upper_bound=parse_datetime("2019-12-27T18:11:19.117Z"), + ledger_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_statement = response.parse() + assert_matches_type(LedgerAccountStatementCreateResponse, ledger_account_statement, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger_account_statement = await client.ledger_account_statements.retrieve( "string", ) assert_matches_type(LedgerAccountStatementRetrieveResponse, ledger_account_statement, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_account_statements.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account_statement = response.parse() + assert_matches_type(LedgerAccountStatementRetrieveResponse, ledger_account_statement, path=["response"]) diff --git a/tests/api_resources/test_ledger_accounts.py b/tests/api_resources/test_ledger_accounts.py index 6ba5e91e..661c81fd 100644 --- a/tests/api_resources/test_ledger_accounts.py +++ b/tests/api_resources/test_ledger_accounts.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerAccount from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -55,6 +56,18 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledger_accounts.with_raw_response.create( + currency="string", + ledger_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + name="string", + normal_balance="credit", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger_account = client.ledger_accounts.retrieve( @@ -76,6 +89,15 @@ def test_method_retrieve_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: ledger_account = client.ledger_accounts.update( @@ -97,6 +119,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.ledger_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger_account = client.ledger_accounts.list() @@ -148,6 +179,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerAccount], ledger_account, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(SyncPage[LedgerAccount], ledger_account, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: ledger_account = client.ledger_accounts.delete( @@ -155,6 +193,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.ledger_accounts.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + class TestAsyncLedgerAccounts: strict_client = AsyncModernTreasury( @@ -194,6 +241,18 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_accounts.with_raw_response.create( + currency="string", + ledger_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + name="string", + normal_balance="credit", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger_account = await client.ledger_accounts.retrieve( @@ -215,6 +274,15 @@ async def test_method_retrieve_with_all_params(self, client: AsyncModernTreasury ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: ledger_account = await client.ledger_accounts.update( @@ -236,6 +304,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger_account = await client.ledger_accounts.list() @@ -287,9 +364,25 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[LedgerAccount], ledger_account, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(AsyncPage[LedgerAccount], ledger_account, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: ledger_account = await client.ledger_accounts.delete( "string", ) assert_matches_type(LedgerAccount, ledger_account, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_accounts.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_account = response.parse() + assert_matches_type(LedgerAccount, ledger_account, path=["response"]) diff --git a/tests/api_resources/test_ledger_entries.py b/tests/api_resources/test_ledger_entries.py index a556a5fe..5b8f7aed 100644 --- a/tests/api_resources/test_ledger_entries.py +++ b/tests/api_resources/test_ledger_entries.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerEntry from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -41,6 +42,15 @@ def test_method_retrieve_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerEntry, ledger_entry, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_entries.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_entry = response.parse() + assert_matches_type(LedgerEntry, ledger_entry, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger_entry = client.ledger_entries.list() @@ -74,6 +84,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerEntry], ledger_entry, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_entries.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_entry = response.parse() + assert_matches_type(SyncPage[LedgerEntry], ledger_entry, path=["response"]) + class TestAsyncLedgerEntries: strict_client = AsyncModernTreasury( @@ -99,6 +116,15 @@ async def test_method_retrieve_with_all_params(self, client: AsyncModernTreasury ) assert_matches_type(LedgerEntry, ledger_entry, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_entries.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_entry = response.parse() + assert_matches_type(LedgerEntry, ledger_entry, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger_entry = await client.ledger_entries.list() @@ -131,3 +157,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> updated_at={"foo": parse_datetime("2019-12-27T18:11:19.117Z")}, ) assert_matches_type(AsyncPage[LedgerEntry], ledger_entry, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_entries.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_entry = response.parse() + assert_matches_type(AsyncPage[LedgerEntry], ledger_entry, path=["response"]) diff --git a/tests/api_resources/test_ledger_event_handlers.py b/tests/api_resources/test_ledger_event_handlers.py index aa2790bf..ab12b299 100644 --- a/tests/api_resources/test_ledger_event_handlers.py +++ b/tests/api_resources/test_ledger_event_handlers.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerEventHandler from modern_treasury._utils import parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -106,6 +107,37 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledger_event_handlers.with_raw_response.create( + ledger_transaction_template={ + "description": "My Ledger Transaction Template Description", + "effective_at": "{{ledgerable_event.custom_data.effective_at}}", + "status": "posted", + "ledger_entries": [ + { + "amount": "string", + "direction": "string", + "ledger_account_id": "string", + }, + { + "amount": "string", + "direction": "string", + "ledger_account_id": "string", + }, + { + "amount": "string", + "direction": "string", + "ledger_account_id": "string", + }, + ], + }, + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger_event_handler = client.ledger_event_handlers.retrieve( @@ -113,6 +145,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_event_handlers.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger_event_handler = client.ledger_event_handlers.list() @@ -129,6 +170,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerEventHandler], ledger_event_handler, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_event_handlers.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(SyncPage[LedgerEventHandler], ledger_event_handler, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: ledger_event_handler = client.ledger_event_handlers.delete( @@ -136,6 +184,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.ledger_event_handlers.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + class TestAsyncLedgerEventHandlers: strict_client = AsyncModernTreasury( @@ -226,6 +283,37 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_event_handlers.with_raw_response.create( + ledger_transaction_template={ + "description": "My Ledger Transaction Template Description", + "effective_at": "{{ledgerable_event.custom_data.effective_at}}", + "status": "posted", + "ledger_entries": [ + { + "amount": "string", + "direction": "string", + "ledger_account_id": "string", + }, + { + "amount": "string", + "direction": "string", + "ledger_account_id": "string", + }, + { + "amount": "string", + "direction": "string", + "ledger_account_id": "string", + }, + ], + }, + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger_event_handler = await client.ledger_event_handlers.retrieve( @@ -233,6 +321,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_event_handlers.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger_event_handler = await client.ledger_event_handlers.list() @@ -249,9 +346,25 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[LedgerEventHandler], ledger_event_handler, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_event_handlers.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(AsyncPage[LedgerEventHandler], ledger_event_handler, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: ledger_event_handler = await client.ledger_event_handlers.delete( "string", ) assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_event_handlers.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_event_handler = response.parse() + assert_matches_type(LedgerEventHandler, ledger_event_handler, path=["response"]) diff --git a/tests/api_resources/test_ledger_transactions.py b/tests/api_resources/test_ledger_transactions.py index cdc19066..78007901 100644 --- a/tests/api_resources/test_ledger_transactions.py +++ b/tests/api_resources/test_ledger_transactions.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerTransaction from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -114,6 +115,31 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledger_transactions.with_raw_response.create( + ledger_entries=[ + { + "amount": 0, + "direction": "credit", + "ledger_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + }, + { + "amount": 0, + "direction": "credit", + "ledger_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + }, + { + "amount": 0, + "direction": "credit", + "ledger_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + }, + ], + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger_transaction = client.ledger_transactions.retrieve( @@ -121,6 +147,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledger_transactions.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: ledger_transaction = client.ledger_transactions.update( @@ -190,6 +225,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.ledger_transactions.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger_transaction = client.ledger_transactions.list() @@ -222,6 +266,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LedgerTransaction], ledger_transaction, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledger_transactions.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(SyncPage[LedgerTransaction], ledger_transaction, path=["response"]) + @parametrize def test_method_create_reversal(self, client: ModernTreasury) -> None: ledger_transaction = client.ledger_transactions.create_reversal( @@ -247,6 +298,15 @@ def test_method_create_reversal_with_all_params(self, client: ModernTreasury) -> ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize + def test_raw_response_create_reversal(self, client: ModernTreasury) -> None: + response = client.ledger_transactions.with_raw_response.create_reversal( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + class TestAsyncLedgerTransactions: strict_client = AsyncModernTreasury( @@ -345,6 +405,31 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_transactions.with_raw_response.create( + ledger_entries=[ + { + "amount": 0, + "direction": "credit", + "ledger_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + }, + { + "amount": 0, + "direction": "credit", + "ledger_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + }, + { + "amount": 0, + "direction": "credit", + "ledger_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + }, + ], + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger_transaction = await client.ledger_transactions.retrieve( @@ -352,6 +437,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_transactions.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: ledger_transaction = await client.ledger_transactions.update( @@ -421,6 +515,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_transactions.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger_transaction = await client.ledger_transactions.list() @@ -453,6 +556,13 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[LedgerTransaction], ledger_transaction, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_transactions.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(AsyncPage[LedgerTransaction], ledger_transaction, path=["response"]) + @parametrize async def test_method_create_reversal(self, client: AsyncModernTreasury) -> None: ledger_transaction = await client.ledger_transactions.create_reversal( @@ -477,3 +587,12 @@ async def test_method_create_reversal_with_all_params(self, client: AsyncModernT status="archived", ) assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) + + @parametrize + async def test_raw_response_create_reversal(self, client: AsyncModernTreasury) -> None: + response = await client.ledger_transactions.with_raw_response.create_reversal( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger_transaction = response.parse() + assert_matches_type(LedgerTransaction, ledger_transaction, path=["response"]) diff --git a/tests/api_resources/test_ledgerable_events.py b/tests/api_resources/test_ledgerable_events.py index 1847121e..5a0e0bb9 100644 --- a/tests/api_resources/test_ledgerable_events.py +++ b/tests/api_resources/test_ledgerable_events.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LedgerableEvent +from modern_treasury._client import ModernTreasury, AsyncModernTreasury base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") api_key = "My API Key" @@ -45,6 +46,15 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledgerable_events.with_raw_response.create( + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledgerable_event = response.parse() + assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledgerable_event = client.ledgerable_events.retrieve( @@ -52,6 +62,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledgerable_events.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledgerable_event = response.parse() + assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) + class TestAsyncLedgerableEvents: strict_client = AsyncModernTreasury( @@ -83,9 +102,27 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledgerable_events.with_raw_response.create( + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledgerable_event = response.parse() + assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledgerable_event = await client.ledgerable_events.retrieve( "string", ) assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledgerable_events.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledgerable_event = response.parse() + assert_matches_type(LedgerableEvent, ledgerable_event, path=["response"]) diff --git a/tests/api_resources/test_ledgers.py b/tests/api_resources/test_ledgers.py index 35e3acb8..13ef8750 100644 --- a/tests/api_resources/test_ledgers.py +++ b/tests/api_resources/test_ledgers.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import Ledger from modern_treasury._utils import parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -46,6 +47,15 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.ledgers.with_raw_response.create( + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: ledger = client.ledgers.retrieve( @@ -53,6 +63,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.ledgers.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: ledger = client.ledgers.update( @@ -74,6 +93,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.ledgers.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: ledger = client.ledgers.list() @@ -90,6 +118,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Ledger], ledger, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.ledgers.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(SyncPage[Ledger], ledger, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: ledger = client.ledgers.delete( @@ -97,6 +132,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.ledgers.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) + class TestAsyncLedgers: strict_client = AsyncModernTreasury( @@ -127,6 +171,15 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.ledgers.with_raw_response.create( + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ledger = await client.ledgers.retrieve( @@ -134,6 +187,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.ledgers.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: ledger = await client.ledgers.update( @@ -155,6 +217,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.ledgers.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: ledger = await client.ledgers.list() @@ -171,9 +242,25 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[Ledger], ledger, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.ledgers.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(AsyncPage[Ledger], ledger, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: ledger = await client.ledgers.delete( "string", ) assert_matches_type(Ledger, ledger, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.ledgers.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ledger = response.parse() + assert_matches_type(Ledger, ledger, path=["response"]) diff --git a/tests/api_resources/test_line_items.py b/tests/api_resources/test_line_items.py index 0f68858c..636f8c46 100644 --- a/tests/api_resources/test_line_items.py +++ b/tests/api_resources/test_line_items.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import LineItem +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -34,6 +35,17 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(LineItem, line_item, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.line_items.with_raw_response.retrieve( + "string", + itemizable_type="expected_payments", + itemizable_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(LineItem, line_item, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: line_item = client.line_items.update( @@ -57,6 +69,17 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(LineItem, line_item, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.line_items.with_raw_response.update( + "string", + itemizable_type="expected_payments", + itemizable_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(LineItem, line_item, path=["response"]) + @pytest.mark.skip(reason="Prism is broken in this case") @parametrize def test_method_list(self, client: ModernTreasury) -> None: @@ -77,6 +100,17 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[LineItem], line_item, path=["response"]) + @pytest.mark.skip(reason="Prism is broken in this case") + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.line_items.with_raw_response.list( + "string", + itemizable_type="expected_payments", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(SyncPage[LineItem], line_item, path=["response"]) + class TestAsyncLineItems: strict_client = AsyncModernTreasury( @@ -96,6 +130,17 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(LineItem, line_item, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.line_items.with_raw_response.retrieve( + "string", + itemizable_type="expected_payments", + itemizable_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(LineItem, line_item, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: line_item = await client.line_items.update( @@ -119,6 +164,17 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(LineItem, line_item, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.line_items.with_raw_response.update( + "string", + itemizable_type="expected_payments", + itemizable_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(LineItem, line_item, path=["response"]) + @pytest.mark.skip(reason="Prism is broken in this case") @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: @@ -138,3 +194,14 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> per_page=0, ) assert_matches_type(AsyncPage[LineItem], line_item, path=["response"]) + + @pytest.mark.skip(reason="Prism is broken in this case") + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.line_items.with_raw_response.list( + "string", + itemizable_type="expected_payments", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(AsyncPage[LineItem], line_item, path=["response"]) diff --git a/tests/api_resources/test_paper_items.py b/tests/api_resources/test_paper_items.py index ac3405b7..48fea5ee 100644 --- a/tests/api_resources/test_paper_items.py +++ b/tests/api_resources/test_paper_items.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import PaperItem from modern_treasury._utils import parse_date +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -33,6 +34,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(PaperItem, paper_item, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.paper_items.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + paper_item = response.parse() + assert_matches_type(PaperItem, paper_item, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: paper_item = client.paper_items.list() @@ -49,6 +59,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[PaperItem], paper_item, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.paper_items.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + paper_item = response.parse() + assert_matches_type(SyncPage[PaperItem], paper_item, path=["response"]) + class TestAsyncPaperItems: strict_client = AsyncModernTreasury( @@ -66,6 +83,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(PaperItem, paper_item, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.paper_items.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + paper_item = response.parse() + assert_matches_type(PaperItem, paper_item, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: paper_item = await client.paper_items.list() @@ -81,3 +107,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> per_page=0, ) assert_matches_type(AsyncPage[PaperItem], paper_item, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.paper_items.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + paper_item = response.parse() + assert_matches_type(AsyncPage[PaperItem], paper_item, path=["response"]) diff --git a/tests/api_resources/test_payment_flows.py b/tests/api_resources/test_payment_flows.py index a28db006..4e8d0a2a 100644 --- a/tests/api_resources/test_payment_flows.py +++ b/tests/api_resources/test_payment_flows.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import PaymentFlow from modern_treasury._utils import parse_date +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -49,6 +50,19 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.payment_flows.with_raw_response.create( + amount=0, + counterparty_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + currency="string", + direction="credit", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: payment_flow = client.payment_flows.retrieve( @@ -56,6 +70,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.payment_flows.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: payment_flow = client.payment_flows.update( @@ -64,6 +87,16 @@ def test_method_update(self, client: ModernTreasury) -> None: ) assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.payment_flows.with_raw_response.update( + "string", + status="cancelled", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: payment_flow = client.payment_flows.list() @@ -83,6 +116,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[PaymentFlow], payment_flow, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.payment_flows.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(SyncPage[PaymentFlow], payment_flow, path=["response"]) + class TestAsyncPaymentFlows: strict_client = AsyncModernTreasury( @@ -116,6 +156,19 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.payment_flows.with_raw_response.create( + amount=0, + counterparty_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + currency="string", + direction="credit", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: payment_flow = await client.payment_flows.retrieve( @@ -123,6 +176,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.payment_flows.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: payment_flow = await client.payment_flows.update( @@ -131,6 +193,16 @@ async def test_method_update(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.payment_flows.with_raw_response.update( + "string", + status="cancelled", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(PaymentFlow, payment_flow, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: payment_flow = await client.payment_flows.list() @@ -149,3 +221,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> status="string", ) assert_matches_type(AsyncPage[PaymentFlow], payment_flow, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.payment_flows.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_flow = response.parse() + assert_matches_type(AsyncPage[PaymentFlow], payment_flow, path=["response"]) diff --git a/tests/api_resources/test_payment_orders.py b/tests/api_resources/test_payment_orders.py index fd8d695f..9713a13f 100644 --- a/tests/api_resources/test_payment_orders.py +++ b/tests/api_resources/test_payment_orders.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import PaymentOrder from modern_treasury._utils import parse_date, parse_datetime +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage from modern_treasury.types.shared import AsyncResponse @@ -277,6 +278,19 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @pytest.mark.skip(reason="Multiple values for nested arrays aren't supported yet") + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.payment_orders.with_raw_response.create( + amount=0, + direction="credit", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="ach", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: payment_order = client.payment_orders.retrieve( @@ -284,6 +298,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.payment_orders.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: payment_order = client.payment_orders.update( @@ -449,6 +472,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.payment_orders.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: payment_order = client.payment_orders.list() @@ -473,6 +505,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[PaymentOrder], payment_order, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.payment_orders.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(SyncPage[PaymentOrder], payment_order, path=["response"]) + @parametrize def test_method_create_async(self, client: ModernTreasury) -> None: payment_order = client.payment_orders.create_async( @@ -701,6 +740,18 @@ def test_method_create_async_with_all_params(self, client: ModernTreasury) -> No ) assert_matches_type(AsyncResponse, payment_order, path=["response"]) + @parametrize + def test_raw_response_create_async(self, client: ModernTreasury) -> None: + response = client.payment_orders.with_raw_response.create_async( + amount=0, + direction="credit", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="ach", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(AsyncResponse, payment_order, path=["response"]) + class TestAsyncPaymentOrders: strict_client = AsyncModernTreasury( @@ -961,6 +1012,19 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @pytest.mark.skip(reason="Multiple values for nested arrays aren't supported yet") + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.with_raw_response.create( + amount=0, + direction="credit", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="ach", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: payment_order = await client.payment_orders.retrieve( @@ -968,6 +1032,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: payment_order = await client.payment_orders.update( @@ -1133,6 +1206,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(PaymentOrder, payment_order, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: payment_order = await client.payment_orders.list() @@ -1157,6 +1239,13 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[PaymentOrder], payment_order, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(AsyncPage[PaymentOrder], payment_order, path=["response"]) + @parametrize async def test_method_create_async(self, client: AsyncModernTreasury) -> None: payment_order = await client.payment_orders.create_async( @@ -1384,3 +1473,15 @@ async def test_method_create_async_with_all_params(self, client: AsyncModernTrea ultimate_receiving_party_name="string", ) assert_matches_type(AsyncResponse, payment_order, path=["response"]) + + @parametrize + async def test_raw_response_create_async(self, client: AsyncModernTreasury) -> None: + response = await client.payment_orders.with_raw_response.create_async( + amount=0, + direction="credit", + originating_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="ach", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_order = response.parse() + assert_matches_type(AsyncResponse, payment_order, path=["response"]) diff --git a/tests/api_resources/test_payment_references.py b/tests/api_resources/test_payment_references.py index 54c61966..2ed77148 100644 --- a/tests/api_resources/test_payment_references.py +++ b/tests/api_resources/test_payment_references.py @@ -9,8 +9,11 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import PaymentReference +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") api_key = "My API Key" organization_id = "my-organization-ID" @@ -32,6 +35,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(PaymentReference, payment_reference, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.payment_references.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_reference = response.parse() + assert_matches_type(PaymentReference, payment_reference, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: payment_reference = client.payment_references.list() @@ -48,12 +60,29 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[PaymentReference], payment_reference, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.payment_references.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_reference = response.parse() + assert_matches_type(SyncPage[PaymentReference], payment_reference, path=["response"]) + @parametrize def test_method_retireve(self, client: ModernTreasury) -> None: with pytest.warns(DeprecationWarning): - payment_reference = client.payment_references.retireve( # pyright: ignore[reportDeprecated] + payment_reference = client.payment_references.retireve( + "string", + ) + assert_matches_type(PaymentReference, payment_reference, path=["response"]) + + @parametrize + def test_raw_response_retireve(self, client: ModernTreasury) -> None: + with pytest.warns(DeprecationWarning): + response = client.payment_references.with_raw_response.retireve( "string", ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_reference = response.parse() assert_matches_type(PaymentReference, payment_reference, path=["response"]) @@ -73,6 +102,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(PaymentReference, payment_reference, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.payment_references.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_reference = response.parse() + assert_matches_type(PaymentReference, payment_reference, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: payment_reference = await client.payment_references.list() @@ -89,10 +127,27 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[PaymentReference], payment_reference, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.payment_references.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_reference = response.parse() + assert_matches_type(AsyncPage[PaymentReference], payment_reference, path=["response"]) + @parametrize async def test_method_retireve(self, client: AsyncModernTreasury) -> None: with pytest.warns(DeprecationWarning): - payment_reference = await client.payment_references.retireve( # pyright: ignore[reportDeprecated] + payment_reference = await client.payment_references.retireve( + "string", + ) + assert_matches_type(PaymentReference, payment_reference, path=["response"]) + + @parametrize + async def test_raw_response_retireve(self, client: AsyncModernTreasury) -> None: + with pytest.warns(DeprecationWarning): + response = await client.payment_references.with_raw_response.retireve( "string", ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + payment_reference = response.parse() assert_matches_type(PaymentReference, payment_reference, path=["response"]) diff --git a/tests/api_resources/test_returns.py b/tests/api_resources/test_returns.py index 191eaa15..eb686c23 100644 --- a/tests/api_resources/test_returns.py +++ b/tests/api_resources/test_returns.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import ReturnObject from modern_treasury._utils import parse_date +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -46,6 +47,16 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.returns.with_raw_response.create( + returnable_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + returnable_type="incoming_payment_detail", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + return_ = response.parse() + assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: return_ = client.returns.retrieve( @@ -53,6 +64,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.returns.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + return_ = response.parse() + assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: return_ = client.returns.list() @@ -70,6 +90,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[ReturnObject], return_, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.returns.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + return_ = response.parse() + assert_matches_type(SyncPage[ReturnObject], return_, path=["response"]) + class TestAsyncReturns: strict_client = AsyncModernTreasury( @@ -100,6 +127,16 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.returns.with_raw_response.create( + returnable_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + returnable_type="incoming_payment_detail", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + return_ = response.parse() + assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: return_ = await client.returns.retrieve( @@ -107,6 +144,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.returns.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + return_ = response.parse() + assert_matches_type(ReturnObject, return_, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: return_ = await client.returns.list() @@ -123,3 +169,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> returnable_type="incoming_payment_detail", ) assert_matches_type(AsyncPage[ReturnObject], return_, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.returns.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + return_ = response.parse() + assert_matches_type(AsyncPage[ReturnObject], return_, path=["response"]) diff --git a/tests/api_resources/test_routing_details.py b/tests/api_resources/test_routing_details.py index 96bd0109..a0cde6fe 100644 --- a/tests/api_resources/test_routing_details.py +++ b/tests/api_resources/test_routing_details.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import RoutingDetail +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -46,6 +47,18 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.routing_details.with_raw_response.create( + "string", + accounts_type="external_accounts", + routing_number="string", + routing_number_type="aba", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: routing_detail = client.routing_details.retrieve( @@ -55,6 +68,17 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.routing_details.with_raw_response.retrieve( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: routing_detail = client.routing_details.list( @@ -73,6 +97,16 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[RoutingDetail], routing_detail, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.routing_details.with_raw_response.list( + "string", + accounts_type="external_accounts", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert_matches_type(SyncPage[RoutingDetail], routing_detail, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: routing_detail = client.routing_details.delete( @@ -82,6 +116,17 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert routing_detail is None + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.routing_details.with_raw_response.delete( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert routing_detail is None + class TestAsyncRoutingDetails: strict_client = AsyncModernTreasury( @@ -113,6 +158,18 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.routing_details.with_raw_response.create( + "string", + accounts_type="external_accounts", + routing_number="string", + routing_number_type="aba", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: routing_detail = await client.routing_details.retrieve( @@ -122,6 +179,17 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.routing_details.with_raw_response.retrieve( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert_matches_type(RoutingDetail, routing_detail, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: routing_detail = await client.routing_details.list( @@ -140,6 +208,16 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[RoutingDetail], routing_detail, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.routing_details.with_raw_response.list( + "string", + accounts_type="external_accounts", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert_matches_type(AsyncPage[RoutingDetail], routing_detail, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: routing_detail = await client.routing_details.delete( @@ -148,3 +226,14 @@ async def test_method_delete(self, client: AsyncModernTreasury) -> None: account_id="string", ) assert routing_detail is None + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.routing_details.with_raw_response.delete( + "string", + accounts_type="external_accounts", + account_id="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + routing_detail = response.parse() + assert routing_detail is None diff --git a/tests/api_resources/test_top_level.py b/tests/api_resources/test_top_level.py index 3849d1be..535be838 100644 --- a/tests/api_resources/test_top_level.py +++ b/tests/api_resources/test_top_level.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import PingResponse +from modern_treasury._client import ModernTreasury, AsyncModernTreasury base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") api_key = "My API Key" @@ -29,6 +30,13 @@ def test_method_ping(self, client: ModernTreasury) -> None: top_level = client.ping() assert_matches_type(PingResponse, top_level, path=["response"]) + @parametrize + def test_raw_response_ping(self, client: ModernTreasury) -> None: + response = client.with_raw_response.ping() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + top_level = response.parse() + assert_matches_type(PingResponse, top_level, path=["response"]) + class TestAsyncTopLevel: strict_client = AsyncModernTreasury( @@ -43,3 +51,10 @@ class TestAsyncTopLevel: async def test_method_ping(self, client: AsyncModernTreasury) -> None: top_level = await client.ping() assert_matches_type(PingResponse, top_level, path=["response"]) + + @parametrize + async def test_raw_response_ping(self, client: AsyncModernTreasury) -> None: + response = await client.with_raw_response.ping() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + top_level = response.parse() + assert_matches_type(PingResponse, top_level, path=["response"]) diff --git a/tests/api_resources/test_transactions.py b/tests/api_resources/test_transactions.py index 9d48e541..00b132ea 100644 --- a/tests/api_resources/test_transactions.py +++ b/tests/api_resources/test_transactions.py @@ -10,6 +10,7 @@ from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import Transaction from modern_treasury._utils import parse_date +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -33,6 +34,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.transactions.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + transaction = response.parse() + assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: transaction = client.transactions.update( @@ -48,6 +58,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.transactions.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + transaction = response.parse() + assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: transaction = client.transactions.list() @@ -73,6 +92,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[Transaction], transaction, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.transactions.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + transaction = response.parse() + assert_matches_type(SyncPage[Transaction], transaction, path=["response"]) + class TestAsyncTransactions: strict_client = AsyncModernTreasury( @@ -90,6 +116,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.transactions.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + transaction = response.parse() + assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: transaction = await client.transactions.update( @@ -105,6 +140,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.transactions.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + transaction = response.parse() + assert_matches_type(Transaction, transaction, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: transaction = await client.transactions.list() @@ -129,3 +173,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> virtual_account_id="string", ) assert_matches_type(AsyncPage[Transaction], transaction, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.transactions.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + transaction = response.parse() + assert_matches_type(AsyncPage[Transaction], transaction, path=["response"]) diff --git a/tests/api_resources/test_validations.py b/tests/api_resources/test_validations.py index dcfb56d8..9538799d 100644 --- a/tests/api_resources/test_validations.py +++ b/tests/api_resources/test_validations.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import RoutingNumberLookupRequest +from modern_treasury._client import ModernTreasury, AsyncModernTreasury base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") api_key = "My API Key" @@ -32,6 +33,16 @@ def test_method_validate_routing_number(self, client: ModernTreasury) -> None: ) assert_matches_type(RoutingNumberLookupRequest, validation, path=["response"]) + @parametrize + def test_raw_response_validate_routing_number(self, client: ModernTreasury) -> None: + response = client.validations.with_raw_response.validate_routing_number( + routing_number="string", + routing_number_type="aba", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + validation = response.parse() + assert_matches_type(RoutingNumberLookupRequest, validation, path=["response"]) + class TestAsyncValidations: strict_client = AsyncModernTreasury( @@ -49,3 +60,13 @@ async def test_method_validate_routing_number(self, client: AsyncModernTreasury) routing_number_type="aba", ) assert_matches_type(RoutingNumberLookupRequest, validation, path=["response"]) + + @parametrize + async def test_raw_response_validate_routing_number(self, client: AsyncModernTreasury) -> None: + response = await client.validations.with_raw_response.validate_routing_number( + routing_number="string", + routing_number_type="aba", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + validation = response.parse() + assert_matches_type(RoutingNumberLookupRequest, validation, path=["response"]) diff --git a/tests/api_resources/test_virtual_accounts.py b/tests/api_resources/test_virtual_accounts.py index 6138c2d9..729fd69b 100644 --- a/tests/api_resources/test_virtual_accounts.py +++ b/tests/api_resources/test_virtual_accounts.py @@ -9,6 +9,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury from modern_treasury.types import VirtualAccount +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -77,6 +78,16 @@ def test_method_create_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize + def test_raw_response_create(self, client: ModernTreasury) -> None: + response = client.virtual_accounts.with_raw_response.create( + internal_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize def test_method_retrieve(self, client: ModernTreasury) -> None: virtual_account = client.virtual_accounts.retrieve( @@ -84,6 +95,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.virtual_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize def test_method_update(self, client: ModernTreasury) -> None: virtual_account = client.virtual_accounts.update( @@ -101,6 +121,15 @@ def test_method_update_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize + def test_raw_response_update(self, client: ModernTreasury) -> None: + response = client.virtual_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: virtual_account = client.virtual_accounts.list() @@ -117,6 +146,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[VirtualAccount], virtual_account, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.virtual_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(SyncPage[VirtualAccount], virtual_account, path=["response"]) + @parametrize def test_method_delete(self, client: ModernTreasury) -> None: virtual_account = client.virtual_accounts.delete( @@ -124,6 +160,15 @@ def test_method_delete(self, client: ModernTreasury) -> None: ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize + def test_raw_response_delete(self, client: ModernTreasury) -> None: + response = client.virtual_accounts.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + class TestAsyncVirtualAccounts: strict_client = AsyncModernTreasury( @@ -186,6 +231,16 @@ async def test_method_create_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize + async def test_raw_response_create(self, client: AsyncModernTreasury) -> None: + response = await client.virtual_accounts.with_raw_response.create( + internal_account_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + name="string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: virtual_account = await client.virtual_accounts.retrieve( @@ -193,6 +248,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.virtual_accounts.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize async def test_method_update(self, client: AsyncModernTreasury) -> None: virtual_account = await client.virtual_accounts.update( @@ -210,6 +274,15 @@ async def test_method_update_with_all_params(self, client: AsyncModernTreasury) ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize + async def test_raw_response_update(self, client: AsyncModernTreasury) -> None: + response = await client.virtual_accounts.with_raw_response.update( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: virtual_account = await client.virtual_accounts.list() @@ -226,9 +299,25 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> ) assert_matches_type(AsyncPage[VirtualAccount], virtual_account, path=["response"]) + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.virtual_accounts.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(AsyncPage[VirtualAccount], virtual_account, path=["response"]) + @parametrize async def test_method_delete(self, client: AsyncModernTreasury) -> None: virtual_account = await client.virtual_accounts.delete( "string", ) assert_matches_type(VirtualAccount, virtual_account, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, client: AsyncModernTreasury) -> None: + response = await client.virtual_accounts.with_raw_response.delete( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_account = response.parse() + assert_matches_type(VirtualAccount, virtual_account, path=["response"]) diff --git a/tests/api_resources/test_webhooks.py b/tests/api_resources/test_webhooks.py index d144d6a9..f66aee96 100644 --- a/tests/api_resources/test_webhooks.py +++ b/tests/api_resources/test_webhooks.py @@ -8,6 +8,7 @@ import pytest from modern_treasury import ModernTreasury, AsyncModernTreasury +from modern_treasury._client import ModernTreasury, AsyncModernTreasury base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") api_key = "My API Key" diff --git a/tests/api_resources/transactions/test_line_items.py b/tests/api_resources/transactions/test_line_items.py index c38b1b1b..036c53a9 100644 --- a/tests/api_resources/transactions/test_line_items.py +++ b/tests/api_resources/transactions/test_line_items.py @@ -8,6 +8,7 @@ from tests.utils import assert_matches_type from modern_treasury import ModernTreasury, AsyncModernTreasury +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury.pagination import SyncPage, AsyncPage from modern_treasury.types.transactions import TransactionLineItem @@ -32,6 +33,15 @@ def test_method_retrieve(self, client: ModernTreasury) -> None: ) assert_matches_type(TransactionLineItem, line_item, path=["response"]) + @parametrize + def test_raw_response_retrieve(self, client: ModernTreasury) -> None: + response = client.transactions.line_items.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(TransactionLineItem, line_item, path=["response"]) + @parametrize def test_method_list(self, client: ModernTreasury) -> None: line_item = client.transactions.line_items.list() @@ -48,6 +58,13 @@ def test_method_list_with_all_params(self, client: ModernTreasury) -> None: ) assert_matches_type(SyncPage[TransactionLineItem], line_item, path=["response"]) + @parametrize + def test_raw_response_list(self, client: ModernTreasury) -> None: + response = client.transactions.line_items.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(SyncPage[TransactionLineItem], line_item, path=["response"]) + class TestAsyncLineItems: strict_client = AsyncModernTreasury( @@ -65,6 +82,15 @@ async def test_method_retrieve(self, client: AsyncModernTreasury) -> None: ) assert_matches_type(TransactionLineItem, line_item, path=["response"]) + @parametrize + async def test_raw_response_retrieve(self, client: AsyncModernTreasury) -> None: + response = await client.transactions.line_items.with_raw_response.retrieve( + "string", + ) + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(TransactionLineItem, line_item, path=["response"]) + @parametrize async def test_method_list(self, client: AsyncModernTreasury) -> None: line_item = await client.transactions.line_items.list() @@ -80,3 +106,10 @@ async def test_method_list_with_all_params(self, client: AsyncModernTreasury) -> type="originating", ) assert_matches_type(AsyncPage[TransactionLineItem], line_item, path=["response"]) + + @parametrize + async def test_raw_response_list(self, client: AsyncModernTreasury) -> None: + response = await client.transactions.line_items.with_raw_response.list() + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + line_item = response.parse() + assert_matches_type(AsyncPage[TransactionLineItem], line_item, path=["response"]) diff --git a/tests/test_client.py b/tests/test_client.py index 46f8ac8a..cc89d8c9 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -19,6 +19,7 @@ AsyncModernTreasury, APIResponseValidationError, ) +from modern_treasury._client import ModernTreasury, AsyncModernTreasury from modern_treasury._models import BaseModel, FinalRequestOptions from modern_treasury._exceptions import APIResponseValidationError from modern_treasury._base_client import ( @@ -33,7 +34,7 @@ organization_id = "my-organization-ID" -def _get_params(client: BaseClient[Any]) -> dict[str, str]: +def _get_params(client: BaseClient[Any, Any]) -> dict[str, str]: request = client._build_request(FinalRequestOptions(method="get", url="/foo")) url = httpx.URL(request.url) return dict(url.params)