Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit 2b6b37e

Browse files
committed
SDK regeneration
1 parent 63a7895 commit 2b6b37e

File tree

912 files changed

+115547
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

912 files changed

+115547
-1
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Specify files that shouldn't be modified by Fern

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: ci
2+
3+
on: [push]
4+
jobs:
5+
compile:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout repo
9+
uses: actions/checkout@v4
10+
- name: Set up python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: 3.8
14+
- name: Bootstrap poetry
15+
run: |
16+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
17+
- name: Install dependencies
18+
run: poetry install
19+
- name: Compile
20+
run: poetry run mypy .
21+
test:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@v4
26+
- name: Set up python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: 3.8
30+
- name: Bootstrap poetry
31+
run: |
32+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
33+
- name: Install dependencies
34+
run: poetry install
35+
36+
- name: Test
37+
run: poetry run pytest -rP .
38+
39+
publish:
40+
needs: [compile, test]
41+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout repo
45+
uses: actions/checkout@v4
46+
- name: Set up python
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: 3.8
50+
- name: Bootstrap poetry
51+
run: |
52+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
53+
- name: Install dependencies
54+
run: poetry install
55+
- name: Publish to pypi
56+
run: |
57+
poetry config repositories.remote https://upload.pypi.org/legacy/
58+
poetry --no-interaction -v publish --build --repository remote --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD"
59+
env:
60+
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
61+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.mypy_cache/
2+
.ruff_cache/
3+
__pycache__/
4+
dist/
5+
poetry.toml

README.md

Lines changed: 189 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,189 @@
1-
# intercom-python
1+
# Intercom Python Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fintercom%2Fintercom-python)
4+
[![pypi](https://img.shields.io/pypi/v/intercom-python)](https://pypi.python.org/pypi/intercom-python)
5+
6+
The Intercom Python library provides convenient access to the Intercom API from Python.
7+
8+
## Installation
9+
10+
```sh
11+
pip install intercom-python
12+
```
13+
14+
## Reference
15+
16+
A full reference for this library is available [here](https://github.com/intercom/intercom-python/blob/HEAD/./reference.md).
17+
18+
## Usage
19+
20+
Instantiate and use the client with the following:
21+
22+
```python
23+
from intercom import Intercom
24+
25+
client = Intercom(
26+
token="YOUR_TOKEN",
27+
)
28+
client.articles.create(
29+
title="Thanks for everything",
30+
description="Description of the Article",
31+
body="Body of the Article",
32+
author_id=1295,
33+
state="published",
34+
)
35+
```
36+
37+
## Async Client
38+
39+
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
40+
41+
```python
42+
import asyncio
43+
44+
from intercom import AsyncIntercom
45+
46+
client = AsyncIntercom(
47+
token="YOUR_TOKEN",
48+
)
49+
50+
51+
async def main() -> None:
52+
await client.articles.create(
53+
title="Thanks for everything",
54+
description="Description of the Article",
55+
body="Body of the Article",
56+
author_id=1295,
57+
state="published",
58+
)
59+
60+
61+
asyncio.run(main())
62+
```
63+
64+
## Exception Handling
65+
66+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
67+
will be thrown.
68+
69+
```python
70+
from intercom.core.api_error import ApiError
71+
72+
try:
73+
client.articles.create(...)
74+
except ApiError as e:
75+
print(e.status_code)
76+
print(e.body)
77+
```
78+
79+
## Pagination
80+
81+
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.
82+
83+
```python
84+
from intercom import Intercom
85+
86+
client = Intercom(
87+
token="YOUR_TOKEN",
88+
)
89+
response = client.articles.list()
90+
for item in response:
91+
yield item
92+
# alternatively, you can paginate page-by-page
93+
for page in response.iter_pages():
94+
yield page
95+
```
96+
97+
## Advanced
98+
99+
### Access Raw Response Data
100+
101+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
102+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
103+
104+
```python
105+
from intercom import Intercom
106+
107+
client = Intercom(
108+
...,
109+
)
110+
response = client.articles.with_raw_response.create(...)
111+
print(response.headers) # access the response headers
112+
print(response.data) # access the underlying object
113+
pager = client.articles.list(...)
114+
print(pager.response.headers) # access the response headers for the first page
115+
for item in pager:
116+
print(item) # access the underlying object(s)
117+
for page in pager.iter_pages():
118+
print(page.response.headers) # access the response headers for each page
119+
for item in page:
120+
print(item) # access the underlying object(s)
121+
```
122+
123+
### Retries
124+
125+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
126+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
127+
retry limit (default: 2).
128+
129+
A request is deemed retryable when any of the following HTTP status codes is returned:
130+
131+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
132+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
133+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
134+
135+
Use the `max_retries` request option to configure this behavior.
136+
137+
```python
138+
client.articles.create(..., request_options={
139+
"max_retries": 1
140+
})
141+
```
142+
143+
### Timeouts
144+
145+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
146+
147+
```python
148+
149+
from intercom import Intercom
150+
151+
client = Intercom(
152+
...,
153+
timeout=20.0,
154+
)
155+
156+
157+
# Override timeout for a specific method
158+
client.articles.create(..., request_options={
159+
"timeout_in_seconds": 1
160+
})
161+
```
162+
163+
### Custom Client
164+
165+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
166+
and transports.
167+
168+
```python
169+
import httpx
170+
from intercom import Intercom
171+
172+
client = Intercom(
173+
...,
174+
httpx_client=httpx.Client(
175+
proxies="http://my.test.proxy.example.com",
176+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
177+
),
178+
)
179+
```
180+
181+
## Contributing
182+
183+
While we value open-source contributions to this SDK, this library is generated programmatically.
184+
Additions made directly to this library would have to be moved over to our generation code,
185+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
186+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
187+
an issue first to discuss with us!
188+
189+
On the other hand, contributions to the README are always very welcome!

0 commit comments

Comments
 (0)