Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"cliVersion": "3.0.2",
"generatorName": "fernapi/fern-python-sdk",
"generatorVersion": "4.41.8",
"generatorConfig": {
"client_class_name": "Intercom",
"pydantic_config": {
"skip_validation": true
}
}
}
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: ci

on: [push]
jobs:
compile:
Expand All @@ -10,7 +9,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand All @@ -26,15 +25,15 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install

- name: Test
run: poetry run pytest -rP .
run: poetry run pytest -rP -n auto .

publish:
needs: [compile, test]
Expand All @@ -46,7 +45,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand Down
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@
[![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%2Fpython-intercom)
[![pypi](https://img.shields.io/pypi/v/python-intercom)](https://pypi.python.org/pypi/python-intercom)

The Intercom Python library provides convenient access to the Intercom API from Python.
The Intercom Python library provides convenient access to the Intercom APIs from Python.

## Table of Contents

- [Installation](#installation)
- [Reference](#reference)
- [Usage](#usage)
- [Async Client](#async-client)
- [Exception Handling](#exception-handling)
- [Pagination](#pagination)
- [Advanced](#advanced)
- [Access Raw Response Data](#access-raw-response-data)
- [Retries](#retries)
- [Timeouts](#timeouts)
- [Custom Client](#custom-client)
- [Contributing](#contributing)

## Installation

Expand All @@ -25,18 +40,14 @@ from intercom import Intercom
client = Intercom(
token="YOUR_TOKEN",
)
client.articles.create(
title="Thanks for everything",
description="Description of the Article",
body="Body of the Article",
author_id=1295,
state="published",
client.ai_content.create_content_import_source(
url="https://www.example.com",
)
```

## Async Client

The SDK also exports an `async` client so that you can make non-blocking calls to our API.
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).

```python
import asyncio
Expand All @@ -49,12 +60,8 @@ client = AsyncIntercom(


async def main() -> None:
await client.articles.create(
title="Thanks for everything",
description="Description of the Article",
body="Body of the Article",
author_id=1295,
state="published",
await client.ai_content.create_content_import_source(
url="https://www.example.com",
)


Expand All @@ -70,7 +77,7 @@ will be thrown.
from intercom.core.api_error import ApiError

try:
client.articles.create(...)
client.ai_content.create_content_import_source(...)
except ApiError as e:
print(e.status_code)
print(e.body)
Expand All @@ -94,6 +101,15 @@ for page in response.iter_pages():
yield page
```

```python
# You can also iterate through pages and access the typed response per page
pager = client.articles.list(...)
for page in pager.iter_pages():
print(page.response) # access the typed response for each page
for item in page:
print(item)
```

## Advanced

### Access Raw Response Data
Expand All @@ -107,15 +123,15 @@ from intercom import Intercom
client = Intercom(
...,
)
response = client.articles.with_raw_response.create(...)
response = client.ai_content.with_raw_response.create_content_import_source(...)
print(response.headers) # access the response headers
print(response.data) # access the underlying object
pager = client.articles.list(...)
print(pager.response.headers) # access the response headers for the first page
print(pager.response) # access the typed response for the first page
for item in pager:
print(item) # access the underlying object(s)
for page in pager.iter_pages():
print(page.response.headers) # access the response headers for each page
print(page.response) # access the typed response for each page
for item in page:
print(item) # access the underlying object(s)
```
Expand All @@ -135,7 +151,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret
Use the `max_retries` request option to configure this behavior.

```python
client.articles.create(..., request_options={
client.ai_content.create_content_import_source(..., request_options={
"max_retries": 1
})
```
Expand All @@ -155,7 +171,7 @@ client = Intercom(


# Override timeout for a specific method
client.articles.create(..., request_options={
client.ai_content.create_content_import_source(..., request_options={
"timeout_in_seconds": 1
})
```
Expand All @@ -172,7 +188,7 @@ from intercom import Intercom
client = Intercom(
...,
httpx_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Expand Down
Loading
Loading