Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Jun 6, 2024
1 parent e3069e9 commit b1b9219
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ from intercom import Intercom
client = Intercom(
# This is the default and can be omitted
access_token=os.environ.get("INTERCOM_ACCESS_TOKEN"),
# or 'production' | 'environment_2'; defaults to "production".
environment="environment_1",
# or 'us' | 'au'; defaults to "us".
environment="eu",
)

admin_with_app = client.me.retrieve()
Expand All @@ -55,8 +55,8 @@ from intercom import AsyncIntercom
client = AsyncIntercom(
# This is the default and can be omitted
access_token=os.environ.get("INTERCOM_ACCESS_TOKEN"),
# or 'production' | 'environment_2'; defaults to "production".
environment="environment_1",
# or 'us' | 'au'; defaults to "us".
environment="eu",
)


Expand Down
22 changes: 11 additions & 11 deletions src/intercom/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
]

ENVIRONMENTS: Dict[str, str] = {
"production": "https://api.intercom.io",
"environment_1": "https://api.eu.intercom.io",
"environment_2": "https://api.au.intercom.io",
"us": "https://api.intercom.io",
"eu": "https://api.eu.intercom.io",
"au": "https://api.au.intercom.io",
}


Expand Down Expand Up @@ -82,13 +82,13 @@ class Intercom(SyncAPIClient):
# client options
access_token: str

_environment: Literal["production", "environment_1", "environment_2"] | NotGiven
_environment: Literal["us", "eu", "au"] | NotGiven

def __init__(
self,
*,
access_token: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | NotGiven = NOT_GIVEN,
environment: Literal["us", "eu", "au"] | NotGiven = NOT_GIVEN,
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand Down Expand Up @@ -139,7 +139,7 @@ def __init__(
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"
self._environment = environment = "us"

try:
base_url = ENVIRONMENTS[environment]
Expand Down Expand Up @@ -207,7 +207,7 @@ def copy(
self,
*,
access_token: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | None = None,
environment: Literal["us", "eu", "au"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.Client | None = None,
Expand Down Expand Up @@ -320,13 +320,13 @@ class AsyncIntercom(AsyncAPIClient):
# client options
access_token: str

_environment: Literal["production", "environment_1", "environment_2"] | NotGiven
_environment: Literal["us", "eu", "au"] | NotGiven

def __init__(
self,
*,
access_token: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | NotGiven = NOT_GIVEN,
environment: Literal["us", "eu", "au"] | NotGiven = NOT_GIVEN,
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand Down Expand Up @@ -377,7 +377,7 @@ def __init__(
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"
self._environment = environment = "us"

try:
base_url = ENVIRONMENTS[environment]
Expand Down Expand Up @@ -445,7 +445,7 @@ def copy(
self,
*,
access_token: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | None = None,
environment: Literal["us", "eu", "au"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.AsyncClient | None = None,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,10 @@ def test_base_url_env(self) -> None:
# explicit environment arg requires explicitness
with update_env(INTERCOM_BASE_URL="http://localhost:5000/from/env"):
with pytest.raises(ValueError, match=r"you must pass base_url=None"):
Intercom(access_token=access_token, _strict_response_validation=True, environment="production")
Intercom(access_token=access_token, _strict_response_validation=True, environment="us")

client = Intercom(
base_url=None, access_token=access_token, _strict_response_validation=True, environment="production"
base_url=None, access_token=access_token, _strict_response_validation=True, environment="us"
)
assert str(client.base_url).startswith("https://api.intercom.io")

Expand Down Expand Up @@ -1276,10 +1276,10 @@ def test_base_url_env(self) -> None:
# explicit environment arg requires explicitness
with update_env(INTERCOM_BASE_URL="http://localhost:5000/from/env"):
with pytest.raises(ValueError, match=r"you must pass base_url=None"):
AsyncIntercom(access_token=access_token, _strict_response_validation=True, environment="production")
AsyncIntercom(access_token=access_token, _strict_response_validation=True, environment="us")

client = AsyncIntercom(
base_url=None, access_token=access_token, _strict_response_validation=True, environment="production"
base_url=None, access_token=access_token, _strict_response_validation=True, environment="us"
)
assert str(client.base_url).startswith("https://api.intercom.io")

Expand Down

0 comments on commit b1b9219

Please sign in to comment.