Skip to content

Commit 354e56b

Browse files
committed
feat(api): update via SDK Studio
1 parent 97cab81 commit 354e56b

File tree

4 files changed

+147
-99
lines changed

4 files changed

+147
-99
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ from intercom import Intercom
2929

3030
client = Intercom(
3131
# This is the default and can be omitted
32-
api_key=os.environ.get("INTERCOM_API_KEY"),
32+
access_token=os.environ.get("INTERCOM_ACCESS_TOKEN"),
3333
# or 'production' | 'environment_2'; defaults to "production".
3434
environment="environment_1",
3535
)
@@ -38,10 +38,10 @@ admin_with_app = client.me.retrieve()
3838
print(admin_with_app.id)
3939
```
4040

41-
While you can provide an `api_key` keyword argument,
41+
While you can provide a `access_token` keyword argument,
4242
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
43-
to add `INTERCOM_API_KEY="My API Key"` to your `.env` file
44-
so that your API Key is not stored in source control.
43+
to add `INTERCOM_ACCESS_TOKEN="My Access Token"` to your `.env` file
44+
so that your Access Token is not stored in source control.
4545

4646
## Async usage
4747

@@ -54,7 +54,7 @@ from intercom import AsyncIntercom
5454

5555
client = AsyncIntercom(
5656
# This is the default and can be omitted
57-
api_key=os.environ.get("INTERCOM_API_KEY"),
57+
access_token=os.environ.get("INTERCOM_ACCESS_TOKEN"),
5858
# or 'production' | 'environment_2'; defaults to "production".
5959
environment="environment_1",
6060
)

src/intercom/_client.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ class Intercom(SyncAPIClient):
8080
with_streaming_response: IntercomWithStreamedResponse
8181

8282
# client options
83-
api_key: str
83+
access_token: str
8484

8585
_environment: Literal["production", "environment_1", "environment_2"] | NotGiven
8686

8787
def __init__(
8888
self,
8989
*,
90-
api_key: str | None = None,
90+
access_token: str | None = None,
9191
environment: Literal["production", "environment_1", "environment_2"] | NotGiven = NOT_GIVEN,
9292
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
9393
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
@@ -110,15 +110,15 @@ def __init__(
110110
) -> None:
111111
"""Construct a new synchronous intercom client instance.
112112
113-
This automatically infers the `api_key` argument from the `INTERCOM_API_KEY` environment variable if it is not provided.
113+
This automatically infers the `access_token` argument from the `INTERCOM_ACCESS_TOKEN` environment variable if it is not provided.
114114
"""
115-
if api_key is None:
116-
api_key = os.environ.get("INTERCOM_API_KEY")
117-
if api_key is None:
115+
if access_token is None:
116+
access_token = os.environ.get("INTERCOM_ACCESS_TOKEN")
117+
if access_token is None:
118118
raise IntercomError(
119-
"The api_key client option must be set either by passing api_key to the client or by setting the INTERCOM_API_KEY environment variable"
119+
"The access_token client option must be set either by passing access_token to the client or by setting the INTERCOM_ACCESS_TOKEN environment variable"
120120
)
121-
self.api_key = api_key
121+
self.access_token = access_token
122122

123123
self._environment = environment
124124

@@ -191,8 +191,8 @@ def qs(self) -> Querystring:
191191
@property
192192
@override
193193
def auth_headers(self) -> dict[str, str]:
194-
api_key = self.api_key
195-
return {"Authorization": f"Bearer {api_key}"}
194+
access_token = self.access_token
195+
return {"Authorization": f"Bearer {access_token}"}
196196

197197
@property
198198
@override
@@ -206,7 +206,7 @@ def default_headers(self) -> dict[str, str | Omit]:
206206
def copy(
207207
self,
208208
*,
209-
api_key: str | None = None,
209+
access_token: str | None = None,
210210
environment: Literal["production", "environment_1", "environment_2"] | None = None,
211211
base_url: str | httpx.URL | None = None,
212212
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
@@ -241,7 +241,7 @@ def copy(
241241

242242
http_client = http_client or self._client
243243
return self.__class__(
244-
api_key=api_key or self.api_key,
244+
access_token=access_token or self.access_token,
245245
base_url=base_url or self.base_url,
246246
environment=environment or self._environment,
247247
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
@@ -318,14 +318,14 @@ class AsyncIntercom(AsyncAPIClient):
318318
with_streaming_response: AsyncIntercomWithStreamedResponse
319319

320320
# client options
321-
api_key: str
321+
access_token: str
322322

323323
_environment: Literal["production", "environment_1", "environment_2"] | NotGiven
324324

325325
def __init__(
326326
self,
327327
*,
328-
api_key: str | None = None,
328+
access_token: str | None = None,
329329
environment: Literal["production", "environment_1", "environment_2"] | NotGiven = NOT_GIVEN,
330330
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
331331
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
@@ -348,15 +348,15 @@ def __init__(
348348
) -> None:
349349
"""Construct a new async intercom client instance.
350350
351-
This automatically infers the `api_key` argument from the `INTERCOM_API_KEY` environment variable if it is not provided.
351+
This automatically infers the `access_token` argument from the `INTERCOM_ACCESS_TOKEN` environment variable if it is not provided.
352352
"""
353-
if api_key is None:
354-
api_key = os.environ.get("INTERCOM_API_KEY")
355-
if api_key is None:
353+
if access_token is None:
354+
access_token = os.environ.get("INTERCOM_ACCESS_TOKEN")
355+
if access_token is None:
356356
raise IntercomError(
357-
"The api_key client option must be set either by passing api_key to the client or by setting the INTERCOM_API_KEY environment variable"
357+
"The access_token client option must be set either by passing access_token to the client or by setting the INTERCOM_ACCESS_TOKEN environment variable"
358358
)
359-
self.api_key = api_key
359+
self.access_token = access_token
360360

361361
self._environment = environment
362362

@@ -429,8 +429,8 @@ def qs(self) -> Querystring:
429429
@property
430430
@override
431431
def auth_headers(self) -> dict[str, str]:
432-
api_key = self.api_key
433-
return {"Authorization": f"Bearer {api_key}"}
432+
access_token = self.access_token
433+
return {"Authorization": f"Bearer {access_token}"}
434434

435435
@property
436436
@override
@@ -444,7 +444,7 @@ def default_headers(self) -> dict[str, str | Omit]:
444444
def copy(
445445
self,
446446
*,
447-
api_key: str | None = None,
447+
access_token: str | None = None,
448448
environment: Literal["production", "environment_1", "environment_2"] | None = None,
449449
base_url: str | httpx.URL | None = None,
450450
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
@@ -479,7 +479,7 @@ def copy(
479479

480480
http_client = http_client or self._client
481481
return self.__class__(
482-
api_key=api_key or self.api_key,
482+
access_token=access_token or self.access_token,
483483
base_url=base_url or self.base_url,
484484
environment=environment or self._environment,
485485
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,

tests/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def event_loop() -> Iterator[asyncio.AbstractEventLoop]:
2626

2727
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
2828

29-
api_key = "My API Key"
29+
access_token = "My Access Token"
3030

3131

3232
@pytest.fixture(scope="session")
@@ -35,7 +35,7 @@ def client(request: FixtureRequest) -> Iterator[Intercom]:
3535
if not isinstance(strict, bool):
3636
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
3737

38-
with Intercom(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
38+
with Intercom(base_url=base_url, access_token=access_token, _strict_response_validation=strict) as client:
3939
yield client
4040

4141

@@ -45,5 +45,7 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncIntercom]:
4545
if not isinstance(strict, bool):
4646
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
4747

48-
async with AsyncIntercom(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
48+
async with AsyncIntercom(
49+
base_url=base_url, access_token=access_token, _strict_response_validation=strict
50+
) as client:
4951
yield client

0 commit comments

Comments
 (0)