diff --git a/.stats.yml b/.stats.yml index e4b3f9a..ba2b4d8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 9 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openint%2Fopenint-f0038c91e290e6ffce873f627e8fb548c35aea1d7fa2e317997b151c159049e3.yml -openapi_spec_hash: 735905a92f106aae48c80635729f44c1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openint%2Fopenint-573ba7bb24acb12f9769960c0d801cd5e6d9522993d27f66c5c10c9e6588ea0e.yml +openapi_spec_hash: db9d90654bbdc3d6280c4a4c752a08ed config_hash: 3745e90e1c879ca82ecfade8dfd108df diff --git a/README.md b/README.md index c4ab5dd..86f4218 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,31 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`. +## Nested params + +Nested parameters are dictionaries, typed using `TypedDict`, for example: + +```python +from openint import Openint + +client = Openint() + +response = client.create_magic_link( + customer_id="x", + client_options={ + "minus_background": "--background", + "minus_card": "--card", + "minus_card_foreground": "--card-foreground", + "minus_foreground": "--foreground", + "minus_primary": "--primary", + "connector_name": "plaid", + "debug": True, + "tab": "my-connections", + }, +) +print(response.client_options) +``` + ## Handling errors When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openint.APIConnectionError` is raised. diff --git a/src/openint/_client.py b/src/openint/_client.py index 493183e..4377435 100644 --- a/src/openint/_client.py +++ b/src/openint/_client.py @@ -327,71 +327,8 @@ def create_magic_link( self, customer_id: str, *, - connection_id: str | NotGiven = NOT_GIVEN, - connector_names: List[ - Literal[ - "aircall", - "airtable", - "apollo", - "brex", - "coda", - "confluence", - "discord", - "facebook", - "finch", - "firebase", - "foreceipt", - "github", - "gong", - "googlecalendar", - "googledocs", - "googledrive", - "googlemail", - "googlesheet", - "greenhouse", - "heron", - "hubspot", - "instagram", - "intercom", - "jira", - "kustomer", - "lever", - "linear", - "linkedin", - "lunchmoney", - "merge", - "microsoft", - "moota", - "notion", - "onebrick", - "outreach", - "pipedrive", - "plaid", - "quickbooks", - "ramp", - "reddit", - "salesforce", - "salesloft", - "saltedge", - "sharepointonline", - "slack", - "splitwise", - "stripe", - "teller", - "toggl", - "twenty", - "twitter", - "wise", - "xero", - "yodlee", - "zohodesk", - ] - ] - | NotGiven = NOT_GIVEN, - redirect_url: str | NotGiven = NOT_GIVEN, - theme: Literal["light", "dark"] | NotGiven = NOT_GIVEN, + client_options: client_create_magic_link_params.ClientOptions | NotGiven = NOT_GIVEN, validity_in_seconds: float | NotGiven = NOT_GIVEN, - view: Literal["manage", "manage-deeplink", "add", "add-deeplink"] | 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, @@ -400,24 +337,15 @@ def create_magic_link( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> CreateMagicLinkResponse: """ - Create a magic link for connecting integrations + Create a magic link that is ready to be shared with customers who want to use + Connect Args: - customer_id: The id of the customer in your application. Ensure it is unique for that - customer. - - connection_id: The specific connection id to load - - connector_names: Filter integrations by connector names - - redirect_url: Where to send user to after connect / if they press back button - - theme: Magic Link display theme + client_options: Search params to configure the connect page. Not signed as part of JWT and + therefore can be modified by client validity_in_seconds: How long the magic link will be valid for (in seconds) before it expires - view: Magic Link tab view to load in the connect magic link - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -432,12 +360,8 @@ def create_magic_link( f"/customer/{customer_id}/magic-link", body=maybe_transform( { - "connection_id": connection_id, - "connector_names": connector_names, - "redirect_url": redirect_url, - "theme": theme, + "client_options": client_options, "validity_in_seconds": validity_in_seconds, - "view": view, }, client_create_magic_link_params.ClientCreateMagicLinkParams, ), @@ -459,8 +383,10 @@ def create_token( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> CreateTokenResponse: - """ - Create an authentication token for a customer + """Create a @Connect authentication token for a customer. + + This token can be used to + embed @Connect in your application via the `@openint/connect` npm package. Args: customer_id: The id of the customer in your application. Ensure it is unique for that @@ -674,7 +600,8 @@ def list_connection_configs( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> SyncOffsetPagination[ListConnectionConfigsResponse]: """ - List all connector configurations + List the connectors that are configured in your account and available for your + customers Args: connector_name: The name of the connector @@ -792,8 +719,11 @@ def list_connections( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> SyncOffsetPagination[ListConnectionsResponse]: - """ - List all connections with optional filtering + """List all connections with optional filtering. + + Does not retrieve secrets or + perform any connection healthcheck. For that use `getConnection` or + `checkConnectionHealth`. Args: connector_config_id: The id of the connector config, starts with `ccfg_` @@ -1136,71 +1066,8 @@ async def create_magic_link( self, customer_id: str, *, - connection_id: str | NotGiven = NOT_GIVEN, - connector_names: List[ - Literal[ - "aircall", - "airtable", - "apollo", - "brex", - "coda", - "confluence", - "discord", - "facebook", - "finch", - "firebase", - "foreceipt", - "github", - "gong", - "googlecalendar", - "googledocs", - "googledrive", - "googlemail", - "googlesheet", - "greenhouse", - "heron", - "hubspot", - "instagram", - "intercom", - "jira", - "kustomer", - "lever", - "linear", - "linkedin", - "lunchmoney", - "merge", - "microsoft", - "moota", - "notion", - "onebrick", - "outreach", - "pipedrive", - "plaid", - "quickbooks", - "ramp", - "reddit", - "salesforce", - "salesloft", - "saltedge", - "sharepointonline", - "slack", - "splitwise", - "stripe", - "teller", - "toggl", - "twenty", - "twitter", - "wise", - "xero", - "yodlee", - "zohodesk", - ] - ] - | NotGiven = NOT_GIVEN, - redirect_url: str | NotGiven = NOT_GIVEN, - theme: Literal["light", "dark"] | NotGiven = NOT_GIVEN, + client_options: client_create_magic_link_params.ClientOptions | NotGiven = NOT_GIVEN, validity_in_seconds: float | NotGiven = NOT_GIVEN, - view: Literal["manage", "manage-deeplink", "add", "add-deeplink"] | 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, @@ -1209,24 +1076,15 @@ async def create_magic_link( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> CreateMagicLinkResponse: """ - Create a magic link for connecting integrations + Create a magic link that is ready to be shared with customers who want to use + Connect Args: - customer_id: The id of the customer in your application. Ensure it is unique for that - customer. - - connection_id: The specific connection id to load - - connector_names: Filter integrations by connector names - - redirect_url: Where to send user to after connect / if they press back button - - theme: Magic Link display theme + client_options: Search params to configure the connect page. Not signed as part of JWT and + therefore can be modified by client validity_in_seconds: How long the magic link will be valid for (in seconds) before it expires - view: Magic Link tab view to load in the connect magic link - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -1241,12 +1099,8 @@ async def create_magic_link( f"/customer/{customer_id}/magic-link", body=await async_maybe_transform( { - "connection_id": connection_id, - "connector_names": connector_names, - "redirect_url": redirect_url, - "theme": theme, + "client_options": client_options, "validity_in_seconds": validity_in_seconds, - "view": view, }, client_create_magic_link_params.ClientCreateMagicLinkParams, ), @@ -1268,8 +1122,10 @@ async def create_token( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> CreateTokenResponse: - """ - Create an authentication token for a customer + """Create a @Connect authentication token for a customer. + + This token can be used to + embed @Connect in your application via the `@openint/connect` npm package. Args: customer_id: The id of the customer in your application. Ensure it is unique for that @@ -1483,7 +1339,8 @@ def list_connection_configs( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AsyncPaginator[ListConnectionConfigsResponse, AsyncOffsetPagination[ListConnectionConfigsResponse]]: """ - List all connector configurations + List the connectors that are configured in your account and available for your + customers Args: connector_name: The name of the connector @@ -1601,8 +1458,11 @@ def list_connections( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AsyncPaginator[ListConnectionsResponse, AsyncOffsetPagination[ListConnectionsResponse]]: - """ - List all connections with optional filtering + """List all connections with optional filtering. + + Does not retrieve secrets or + perform any connection healthcheck. For that use `getConnection` or + `checkConnectionHealth`. Args: connector_config_id: The id of the connector config, starts with `ccfg_` diff --git a/src/openint/types/client_create_magic_link_params.py b/src/openint/types/client_create_magic_link_params.py index 26f1aee..4285ffe 100644 --- a/src/openint/types/client_create_magic_link_params.py +++ b/src/openint/types/client_create_magic_link_params.py @@ -2,85 +2,43 @@ from __future__ import annotations -from typing import List -from typing_extensions import Literal, TypedDict +from typing_extensions import Literal, Annotated, TypedDict -__all__ = ["ClientCreateMagicLinkParams"] +from .._utils import PropertyInfo + +__all__ = ["ClientCreateMagicLinkParams", "ClientOptions"] class ClientCreateMagicLinkParams(TypedDict, total=False): - connection_id: str - """The specific connection id to load""" - - connector_names: List[ - Literal[ - "aircall", - "airtable", - "apollo", - "brex", - "coda", - "confluence", - "discord", - "facebook", - "finch", - "firebase", - "foreceipt", - "github", - "gong", - "googlecalendar", - "googledocs", - "googledrive", - "googlemail", - "googlesheet", - "greenhouse", - "heron", - "hubspot", - "instagram", - "intercom", - "jira", - "kustomer", - "lever", - "linear", - "linkedin", - "lunchmoney", - "merge", - "microsoft", - "moota", - "notion", - "onebrick", - "outreach", - "pipedrive", - "plaid", - "quickbooks", - "ramp", - "reddit", - "salesforce", - "salesloft", - "saltedge", - "sharepointonline", - "slack", - "splitwise", - "stripe", - "teller", - "toggl", - "twenty", - "twitter", - "wise", - "xero", - "yodlee", - "zohodesk", - ] - ] - """Filter integrations by connector names""" - - redirect_url: str - """Where to send user to after connect / if they press back button""" - - theme: Literal["light", "dark"] - """Magic Link display theme""" + client_options: ClientOptions + """Search params to configure the connect page. + + Not signed as part of JWT and therefore can be modified by client + """ validity_in_seconds: float """How long the magic link will be valid for (in seconds) before it expires""" - view: Literal["manage", "manage-deeplink", "add", "add-deeplink"] - """Magic Link tab view to load in the connect magic link""" + +class ClientOptions(TypedDict, total=False): + minus_background: Annotated[str, PropertyInfo(alias="--background")] + + minus_card: Annotated[str, PropertyInfo(alias="--card")] + + minus_card_foreground: Annotated[str, PropertyInfo(alias="--card-foreground")] + + minus_foreground: Annotated[str, PropertyInfo(alias="--foreground")] + + minus_primary: Annotated[str, PropertyInfo(alias="--primary")] + + connector_name: Literal["plaid", "greenhouse"] + """The name of the connector to limit connection to. Default to all otherwise""" + + debug: bool + """Whether to enable debug mode""" + + tab: Literal["my-connections", "add-connection"] + """The default tab to show when the magic link is opened. + + Defaults to "my-connections" + """ diff --git a/tests/api_resources/test_client.py b/tests/api_resources/test_client.py index b62e7a1..b1428aa 100644 --- a/tests/api_resources/test_client.py +++ b/tests/api_resources/test_client.py @@ -175,7 +175,7 @@ def test_streaming_response_create_connection(self, client: Openint) -> None: @parametrize def test_method_create_magic_link(self, client: Openint) -> None: client_ = client.create_magic_link( - customer_id="customer_id", + customer_id="x", ) assert_matches_type(CreateMagicLinkResponse, client_, path=["response"]) @@ -183,13 +183,18 @@ def test_method_create_magic_link(self, client: Openint) -> None: @parametrize def test_method_create_magic_link_with_all_params(self, client: Openint) -> None: client_ = client.create_magic_link( - customer_id="customer_id", - connection_id="conn_", - connector_names=["aircall"], - redirect_url="redirect_url", - theme="light", + customer_id="x", + client_options={ + "minus_background": "--background", + "minus_card": "--card", + "minus_card_foreground": "--card-foreground", + "minus_foreground": "--foreground", + "minus_primary": "--primary", + "connector_name": "plaid", + "debug": True, + "tab": "my-connections", + }, validity_in_seconds=0, - view="manage", ) assert_matches_type(CreateMagicLinkResponse, client_, path=["response"]) @@ -197,7 +202,7 @@ def test_method_create_magic_link_with_all_params(self, client: Openint) -> None @parametrize def test_raw_response_create_magic_link(self, client: Openint) -> None: response = client.with_raw_response.create_magic_link( - customer_id="customer_id", + customer_id="x", ) assert response.is_closed is True @@ -209,7 +214,7 @@ def test_raw_response_create_magic_link(self, client: Openint) -> None: @parametrize def test_streaming_response_create_magic_link(self, client: Openint) -> None: with client.with_streaming_response.create_magic_link( - customer_id="customer_id", + customer_id="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -633,7 +638,7 @@ async def test_streaming_response_create_connection(self, async_client: AsyncOpe @parametrize async def test_method_create_magic_link(self, async_client: AsyncOpenint) -> None: client = await async_client.create_magic_link( - customer_id="customer_id", + customer_id="x", ) assert_matches_type(CreateMagicLinkResponse, client, path=["response"]) @@ -641,13 +646,18 @@ async def test_method_create_magic_link(self, async_client: AsyncOpenint) -> Non @parametrize async def test_method_create_magic_link_with_all_params(self, async_client: AsyncOpenint) -> None: client = await async_client.create_magic_link( - customer_id="customer_id", - connection_id="conn_", - connector_names=["aircall"], - redirect_url="redirect_url", - theme="light", + customer_id="x", + client_options={ + "minus_background": "--background", + "minus_card": "--card", + "minus_card_foreground": "--card-foreground", + "minus_foreground": "--foreground", + "minus_primary": "--primary", + "connector_name": "plaid", + "debug": True, + "tab": "my-connections", + }, validity_in_seconds=0, - view="manage", ) assert_matches_type(CreateMagicLinkResponse, client, path=["response"]) @@ -655,7 +665,7 @@ async def test_method_create_magic_link_with_all_params(self, async_client: Asyn @parametrize async def test_raw_response_create_magic_link(self, async_client: AsyncOpenint) -> None: response = await async_client.with_raw_response.create_magic_link( - customer_id="customer_id", + customer_id="x", ) assert response.is_closed is True @@ -667,7 +677,7 @@ async def test_raw_response_create_magic_link(self, async_client: AsyncOpenint) @parametrize async def test_streaming_response_create_magic_link(self, async_client: AsyncOpenint) -> None: async with async_client.with_streaming_response.create_magic_link( - customer_id="customer_id", + customer_id="x", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python"