diff --git a/.release-please-manifest.json b/.release-please-manifest.json index dfe6cb919..bf939b09f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.171.0" + ".": "0.172.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 8e2a25a86..d0500faee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 199 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-9a8f92e87439c05437fc55f45933f3c564f6d705b43fe2ac9ffcc87037b15bd8.yml +configured_endpoints: 201 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-6e3f74c1cfeef92447868eb9d50fb5bd703bd25191aa1c4583d659082e1adea7.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index eed89f9c9..ad898b615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.172.0 (2024-12-23) + +Full Changelog: [v0.171.0...v0.172.0](https://github.com/Increase/increase-python/compare/v0.171.0...v0.172.0) + +### Features + +* **api:** api update ([#882](https://github.com/Increase/increase-python/issues/882)) ([271aa05](https://github.com/Increase/increase-python/commit/271aa059c9314c402911e3a54caecefb80f4a00a)) + ## 0.171.0 (2024-12-20) Full Changelog: [v0.170.0...v0.171.0](https://github.com/Increase/increase-python/compare/v0.170.0...v0.171.0) diff --git a/api.md b/api.md index 71ed34089..846461cfc 100644 --- a/api.md +++ b/api.md @@ -654,6 +654,19 @@ Methods: - client.groups.retrieve() -> Group +# OAuthApplications + +Types: + +```python +from increase.types import OAuthApplication +``` + +Methods: + +- client.oauth_applications.retrieve(oauth_application_id) -> OAuthApplication +- client.oauth_applications.list(\*\*params) -> SyncPage[OAuthApplication] + # OAuthConnections Types: diff --git a/pyproject.toml b/pyproject.toml index d1d029a48..a15d255d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "increase" -version = "0.171.0" +version = "0.172.0" description = "The official Python library for the increase API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/increase/_client.py b/src/increase/_client.py index aa7cabecf..da2e8a779 100644 --- a/src/increase/_client.py +++ b/src/increase/_client.py @@ -55,6 +55,7 @@ account_statements, inbound_mail_items, intrafi_exclusions, + oauth_applications, bookkeeping_entries, event_subscriptions, real_time_decisions, @@ -156,6 +157,7 @@ class Increase(SyncAPIClient): bookkeeping_entry_sets: bookkeeping_entry_sets.BookkeepingEntrySetsResource bookkeeping_entries: bookkeeping_entries.BookkeepingEntriesResource groups: groups.GroupsResource + oauth_applications: oauth_applications.OAuthApplicationsResource oauth_connections: oauth_connections.OAuthConnectionsResource oauth_tokens: oauth_tokens.OAuthTokensResource intrafi_account_enrollments: intrafi_account_enrollments.IntrafiAccountEnrollmentsResource @@ -309,6 +311,7 @@ def __init__( self.bookkeeping_entry_sets = bookkeeping_entry_sets.BookkeepingEntrySetsResource(self) self.bookkeeping_entries = bookkeeping_entries.BookkeepingEntriesResource(self) self.groups = groups.GroupsResource(self) + self.oauth_applications = oauth_applications.OAuthApplicationsResource(self) self.oauth_connections = oauth_connections.OAuthConnectionsResource(self) self.oauth_tokens = oauth_tokens.OAuthTokensResource(self) self.intrafi_account_enrollments = intrafi_account_enrollments.IntrafiAccountEnrollmentsResource(self) @@ -527,6 +530,7 @@ class AsyncIncrease(AsyncAPIClient): bookkeeping_entry_sets: bookkeeping_entry_sets.AsyncBookkeepingEntrySetsResource bookkeeping_entries: bookkeeping_entries.AsyncBookkeepingEntriesResource groups: groups.AsyncGroupsResource + oauth_applications: oauth_applications.AsyncOAuthApplicationsResource oauth_connections: oauth_connections.AsyncOAuthConnectionsResource oauth_tokens: oauth_tokens.AsyncOAuthTokensResource intrafi_account_enrollments: intrafi_account_enrollments.AsyncIntrafiAccountEnrollmentsResource @@ -682,6 +686,7 @@ def __init__( self.bookkeeping_entry_sets = bookkeeping_entry_sets.AsyncBookkeepingEntrySetsResource(self) self.bookkeeping_entries = bookkeeping_entries.AsyncBookkeepingEntriesResource(self) self.groups = groups.AsyncGroupsResource(self) + self.oauth_applications = oauth_applications.AsyncOAuthApplicationsResource(self) self.oauth_connections = oauth_connections.AsyncOAuthConnectionsResource(self) self.oauth_tokens = oauth_tokens.AsyncOAuthTokensResource(self) self.intrafi_account_enrollments = intrafi_account_enrollments.AsyncIntrafiAccountEnrollmentsResource(self) @@ -951,6 +956,7 @@ def __init__(self, client: Increase) -> None: client.bookkeeping_entries ) self.groups = groups.GroupsResourceWithRawResponse(client.groups) + self.oauth_applications = oauth_applications.OAuthApplicationsResourceWithRawResponse(client.oauth_applications) self.oauth_connections = oauth_connections.OAuthConnectionsResourceWithRawResponse(client.oauth_connections) self.oauth_tokens = oauth_tokens.OAuthTokensResourceWithRawResponse(client.oauth_tokens) self.intrafi_account_enrollments = intrafi_account_enrollments.IntrafiAccountEnrollmentsResourceWithRawResponse( @@ -1074,6 +1080,9 @@ def __init__(self, client: AsyncIncrease) -> None: client.bookkeeping_entries ) self.groups = groups.AsyncGroupsResourceWithRawResponse(client.groups) + self.oauth_applications = oauth_applications.AsyncOAuthApplicationsResourceWithRawResponse( + client.oauth_applications + ) self.oauth_connections = oauth_connections.AsyncOAuthConnectionsResourceWithRawResponse( client.oauth_connections ) @@ -1203,6 +1212,9 @@ def __init__(self, client: Increase) -> None: client.bookkeeping_entries ) self.groups = groups.GroupsResourceWithStreamingResponse(client.groups) + self.oauth_applications = oauth_applications.OAuthApplicationsResourceWithStreamingResponse( + client.oauth_applications + ) self.oauth_connections = oauth_connections.OAuthConnectionsResourceWithStreamingResponse( client.oauth_connections ) @@ -1334,6 +1346,9 @@ def __init__(self, client: AsyncIncrease) -> None: client.bookkeeping_entries ) self.groups = groups.AsyncGroupsResourceWithStreamingResponse(client.groups) + self.oauth_applications = oauth_applications.AsyncOAuthApplicationsResourceWithStreamingResponse( + client.oauth_applications + ) self.oauth_connections = oauth_connections.AsyncOAuthConnectionsResourceWithStreamingResponse( client.oauth_connections ) diff --git a/src/increase/_version.py b/src/increase/_version.py index fc6aa1b7a..51c5bdced 100644 --- a/src/increase/_version.py +++ b/src/increase/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "increase" -__version__ = "0.171.0" # x-release-please-version +__version__ = "0.172.0" # x-release-please-version diff --git a/src/increase/resources/__init__.py b/src/increase/resources/__init__.py index d7a0c5f2c..00101a697 100644 --- a/src/increase/resources/__init__.py +++ b/src/increase/resources/__init__.py @@ -233,6 +233,14 @@ IntrafiExclusionsResourceWithStreamingResponse, AsyncIntrafiExclusionsResourceWithStreamingResponse, ) +from .oauth_applications import ( + OAuthApplicationsResource, + AsyncOAuthApplicationsResource, + OAuthApplicationsResourceWithRawResponse, + AsyncOAuthApplicationsResourceWithRawResponse, + OAuthApplicationsResourceWithStreamingResponse, + AsyncOAuthApplicationsResourceWithStreamingResponse, +) from .bookkeeping_entries import ( BookkeepingEntriesResource, AsyncBookkeepingEntriesResource, @@ -705,6 +713,12 @@ "AsyncGroupsResourceWithRawResponse", "GroupsResourceWithStreamingResponse", "AsyncGroupsResourceWithStreamingResponse", + "OAuthApplicationsResource", + "AsyncOAuthApplicationsResource", + "OAuthApplicationsResourceWithRawResponse", + "AsyncOAuthApplicationsResourceWithRawResponse", + "OAuthApplicationsResourceWithStreamingResponse", + "AsyncOAuthApplicationsResourceWithStreamingResponse", "OAuthConnectionsResource", "AsyncOAuthConnectionsResource", "OAuthConnectionsResourceWithRawResponse", diff --git a/src/increase/resources/oauth_applications.py b/src/increase/resources/oauth_applications.py new file mode 100644 index 000000000..c46086de3 --- /dev/null +++ b/src/increase/resources/oauth_applications.py @@ -0,0 +1,282 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..types import oauth_application_list_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..pagination import SyncPage, AsyncPage +from .._base_client import AsyncPaginator, make_request_options +from ..types.oauth_application import OAuthApplication + +__all__ = ["OAuthApplicationsResource", "AsyncOAuthApplicationsResource"] + + +class OAuthApplicationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OAuthApplicationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Increase/increase-python#accessing-raw-response-data-eg-headers + """ + return OAuthApplicationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OAuthApplicationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Increase/increase-python#with_streaming_response + """ + return OAuthApplicationsResourceWithStreamingResponse(self) + + def retrieve( + self, + oauth_application_id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> OAuthApplication: + """ + Retrieve an OAuth Application + + Args: + oauth_application_id: The identifier of the OAuth Application. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not oauth_application_id: + raise ValueError( + f"Expected a non-empty value for `oauth_application_id` but received {oauth_application_id!r}" + ) + return self._get( + f"/oauth_applications/{oauth_application_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthApplication, + ) + + def list( + self, + *, + cursor: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncPage[OAuthApplication]: + """ + List OAuth Applications + + Args: + cursor: Return the page of entries after this one. + + limit: Limit the size of the list that is returned. The default (and maximum) is 100 + objects. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/oauth_applications", + page=SyncPage[OAuthApplication], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "limit": limit, + }, + oauth_application_list_params.OAuthApplicationListParams, + ), + ), + model=OAuthApplication, + ) + + +class AsyncOAuthApplicationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOAuthApplicationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/Increase/increase-python#accessing-raw-response-data-eg-headers + """ + return AsyncOAuthApplicationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOAuthApplicationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/Increase/increase-python#with_streaming_response + """ + return AsyncOAuthApplicationsResourceWithStreamingResponse(self) + + async def retrieve( + self, + oauth_application_id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> OAuthApplication: + """ + Retrieve an OAuth Application + + Args: + oauth_application_id: The identifier of the OAuth Application. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not oauth_application_id: + raise ValueError( + f"Expected a non-empty value for `oauth_application_id` but received {oauth_application_id!r}" + ) + return await self._get( + f"/oauth_applications/{oauth_application_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OAuthApplication, + ) + + def list( + self, + *, + cursor: str | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[OAuthApplication, AsyncPage[OAuthApplication]]: + """ + List OAuth Applications + + Args: + cursor: Return the page of entries after this one. + + limit: Limit the size of the list that is returned. The default (and maximum) is 100 + objects. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/oauth_applications", + page=AsyncPage[OAuthApplication], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "limit": limit, + }, + oauth_application_list_params.OAuthApplicationListParams, + ), + ), + model=OAuthApplication, + ) + + +class OAuthApplicationsResourceWithRawResponse: + def __init__(self, oauth_applications: OAuthApplicationsResource) -> None: + self._oauth_applications = oauth_applications + + self.retrieve = to_raw_response_wrapper( + oauth_applications.retrieve, + ) + self.list = to_raw_response_wrapper( + oauth_applications.list, + ) + + +class AsyncOAuthApplicationsResourceWithRawResponse: + def __init__(self, oauth_applications: AsyncOAuthApplicationsResource) -> None: + self._oauth_applications = oauth_applications + + self.retrieve = async_to_raw_response_wrapper( + oauth_applications.retrieve, + ) + self.list = async_to_raw_response_wrapper( + oauth_applications.list, + ) + + +class OAuthApplicationsResourceWithStreamingResponse: + def __init__(self, oauth_applications: OAuthApplicationsResource) -> None: + self._oauth_applications = oauth_applications + + self.retrieve = to_streamed_response_wrapper( + oauth_applications.retrieve, + ) + self.list = to_streamed_response_wrapper( + oauth_applications.list, + ) + + +class AsyncOAuthApplicationsResourceWithStreamingResponse: + def __init__(self, oauth_applications: AsyncOAuthApplicationsResource) -> None: + self._oauth_applications = oauth_applications + + self.retrieve = async_to_streamed_response_wrapper( + oauth_applications.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + oauth_applications.list, + ) diff --git a/src/increase/resources/oauth_connections.py b/src/increase/resources/oauth_connections.py index 55630cf00..fff55c6c7 100644 --- a/src/increase/resources/oauth_connections.py +++ b/src/increase/resources/oauth_connections.py @@ -84,6 +84,7 @@ def list( *, cursor: str | NotGiven = NOT_GIVEN, limit: int | NotGiven = NOT_GIVEN, + oauth_application_id: str | NotGiven = NOT_GIVEN, status: oauth_connection_list_params.Status | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -101,6 +102,8 @@ def list( limit: Limit the size of the list that is returned. The default (and maximum) is 100 objects. + oauth_application_id: The identifier of the OAuth Application to filter by. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -121,6 +124,7 @@ def list( { "cursor": cursor, "limit": limit, + "oauth_application_id": oauth_application_id, "status": status, }, oauth_connection_list_params.OAuthConnectionListParams, @@ -192,6 +196,7 @@ def list( *, cursor: str | NotGiven = NOT_GIVEN, limit: int | NotGiven = NOT_GIVEN, + oauth_application_id: str | NotGiven = NOT_GIVEN, status: oauth_connection_list_params.Status | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -209,6 +214,8 @@ def list( limit: Limit the size of the list that is returned. The default (and maximum) is 100 objects. + oauth_application_id: The identifier of the OAuth Application to filter by. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -229,6 +236,7 @@ def list( { "cursor": cursor, "limit": limit, + "oauth_application_id": oauth_application_id, "status": status, }, oauth_connection_list_params.OAuthConnectionListParams, diff --git a/src/increase/types/__init__.py b/src/increase/types/__init__.py index e36613983..da9db5702 100644 --- a/src/increase/types/__init__.py +++ b/src/increase/types/__init__.py @@ -35,6 +35,7 @@ from .event_list_params import EventListParams as EventListParams from .inbound_mail_item import InboundMailItem as InboundMailItem from .intrafi_exclusion import IntrafiExclusion as IntrafiExclusion +from .oauth_application import OAuthApplication as OAuthApplication from .card_create_params import CardCreateParams as CardCreateParams from .card_update_params import CardUpdateParams as CardUpdateParams from .entity_list_params import EntityListParams as EntityListParams @@ -101,6 +102,7 @@ from .inbound_mail_item_list_params import InboundMailItemListParams as InboundMailItemListParams from .inbound_wire_drawdown_request import InboundWireDrawdownRequest as InboundWireDrawdownRequest from .intrafi_exclusion_list_params import IntrafiExclusionListParams as IntrafiExclusionListParams +from .oauth_application_list_params import OAuthApplicationListParams as OAuthApplicationListParams from .account_transfer_create_params import AccountTransferCreateParams as AccountTransferCreateParams from .event_subscription_list_params import EventSubscriptionListParams as EventSubscriptionListParams from .external_account_create_params import ExternalAccountCreateParams as ExternalAccountCreateParams diff --git a/src/increase/types/oauth_application.py b/src/increase/types/oauth_application.py new file mode 100644 index 000000000..99bb1f92c --- /dev/null +++ b/src/increase/types/oauth_application.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["OAuthApplication"] + + +class OAuthApplication(BaseModel): + id: str + """The OAuth Application's identifier.""" + + client_id: str + """The OAuth Application's client_id. + + Use this to authenticate with the OAuth Application. + """ + + created_at: datetime + """ + The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp when the OAuth + Application was created. + """ + + deleted_at: Optional[datetime] = None + """ + The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp when the OAuth + Application was deleted. + """ + + name: Optional[str] = None + """The name you chose for this OAuth Application.""" + + status: Literal["active", "deleted"] + """Whether the application is active. + + - `active` - The application is active and can be used by your users. + - `deleted` - The application is deleted. + """ + + type: Literal["oauth_application"] + """A constant representing the object's type. + + For this resource it will always be `oauth_application`. + """ diff --git a/src/increase/types/oauth_application_list_params.py b/src/increase/types/oauth_application_list_params.py new file mode 100644 index 000000000..fa0d4f42b --- /dev/null +++ b/src/increase/types/oauth_application_list_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["OAuthApplicationListParams"] + + +class OAuthApplicationListParams(TypedDict, total=False): + cursor: str + """Return the page of entries after this one.""" + + limit: int + """Limit the size of the list that is returned. + + The default (and maximum) is 100 objects. + """ diff --git a/src/increase/types/oauth_connection.py b/src/increase/types/oauth_connection.py index 0ced8bed6..e8ef81603 100644 --- a/src/increase/types/oauth_connection.py +++ b/src/increase/types/oauth_connection.py @@ -28,6 +28,9 @@ class OAuthConnection(BaseModel): group_id: str """The identifier of the Group that has authorized your OAuth application.""" + oauth_application_id: str + """The identifier of the OAuth application this connection is for.""" + status: Literal["active", "inactive"] """Whether the connection is active. diff --git a/src/increase/types/oauth_connection_list_params.py b/src/increase/types/oauth_connection_list_params.py index 2cd6a5ef1..bc1e3e240 100644 --- a/src/increase/types/oauth_connection_list_params.py +++ b/src/increase/types/oauth_connection_list_params.py @@ -18,6 +18,9 @@ class OAuthConnectionListParams(TypedDict, total=False): The default (and maximum) is 100 objects. """ + oauth_application_id: str + """The identifier of the OAuth Application to filter by.""" + status: Status diff --git a/tests/api_resources/test_oauth_applications.py b/tests/api_resources/test_oauth_applications.py new file mode 100644 index 000000000..1aed1fe00 --- /dev/null +++ b/tests/api_resources/test_oauth_applications.py @@ -0,0 +1,165 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from increase import Increase, AsyncIncrease +from tests.utils import assert_matches_type +from increase.types import OAuthApplication +from increase.pagination import SyncPage, AsyncPage + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOAuthApplications: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_retrieve(self, client: Increase) -> None: + oauth_application = client.oauth_applications.retrieve( + "oauth_application_id", + ) + assert_matches_type(OAuthApplication, oauth_application, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: Increase) -> None: + response = client.oauth_applications.with_raw_response.retrieve( + "oauth_application_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_application = response.parse() + assert_matches_type(OAuthApplication, oauth_application, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: Increase) -> None: + with client.oauth_applications.with_streaming_response.retrieve( + "oauth_application_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_application = response.parse() + assert_matches_type(OAuthApplication, oauth_application, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: Increase) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `oauth_application_id` but received ''"): + client.oauth_applications.with_raw_response.retrieve( + "", + ) + + @parametrize + def test_method_list(self, client: Increase) -> None: + oauth_application = client.oauth_applications.list() + assert_matches_type(SyncPage[OAuthApplication], oauth_application, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Increase) -> None: + oauth_application = client.oauth_applications.list( + cursor="cursor", + limit=1, + ) + assert_matches_type(SyncPage[OAuthApplication], oauth_application, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Increase) -> None: + response = client.oauth_applications.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_application = response.parse() + assert_matches_type(SyncPage[OAuthApplication], oauth_application, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Increase) -> None: + with client.oauth_applications.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_application = response.parse() + assert_matches_type(SyncPage[OAuthApplication], oauth_application, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncOAuthApplications: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_retrieve(self, async_client: AsyncIncrease) -> None: + oauth_application = await async_client.oauth_applications.retrieve( + "oauth_application_id", + ) + assert_matches_type(OAuthApplication, oauth_application, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncIncrease) -> None: + response = await async_client.oauth_applications.with_raw_response.retrieve( + "oauth_application_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_application = await response.parse() + assert_matches_type(OAuthApplication, oauth_application, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncIncrease) -> None: + async with async_client.oauth_applications.with_streaming_response.retrieve( + "oauth_application_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_application = await response.parse() + assert_matches_type(OAuthApplication, oauth_application, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncIncrease) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `oauth_application_id` but received ''"): + await async_client.oauth_applications.with_raw_response.retrieve( + "", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncIncrease) -> None: + oauth_application = await async_client.oauth_applications.list() + assert_matches_type(AsyncPage[OAuthApplication], oauth_application, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncIncrease) -> None: + oauth_application = await async_client.oauth_applications.list( + cursor="cursor", + limit=1, + ) + assert_matches_type(AsyncPage[OAuthApplication], oauth_application, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncIncrease) -> None: + response = await async_client.oauth_applications.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + oauth_application = await response.parse() + assert_matches_type(AsyncPage[OAuthApplication], oauth_application, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncIncrease) -> None: + async with async_client.oauth_applications.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + oauth_application = await response.parse() + assert_matches_type(AsyncPage[OAuthApplication], oauth_application, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_oauth_connections.py b/tests/api_resources/test_oauth_connections.py index a62eb4491..d8e08b2d9 100644 --- a/tests/api_resources/test_oauth_connections.py +++ b/tests/api_resources/test_oauth_connections.py @@ -66,6 +66,7 @@ def test_method_list_with_all_params(self, client: Increase) -> None: oauth_connection = client.oauth_connections.list( cursor="cursor", limit=1, + oauth_application_id="oauth_application_id", status={"in": ["active"]}, ) assert_matches_type(SyncPage[OAuthConnection], oauth_connection, path=["response"]) @@ -142,6 +143,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncIncrease) -> oauth_connection = await async_client.oauth_connections.list( cursor="cursor", limit=1, + oauth_application_id="oauth_application_id", status={"in": ["active"]}, ) assert_matches_type(AsyncPage[OAuthConnection], oauth_connection, path=["response"])