Skip to content
Open
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
  •  
  •  
  •  
97 changes: 53 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@ Instantiate and use the client with the following:

```python
from merge import Merge
from merge.resources.chat import DataPassthroughRequest, MethodEnum

client = Merge(
account_token="YOUR_ACCOUNT_TOKEN",
api_key="YOUR_API_KEY",
)
client.chat.async_passthrough.create(
request=DataPassthroughRequest(
method=MethodEnum.GET,
path="/scooters",
),
)
client.ats.account_token.regenerate_create()
```

## Instantiation
Expand Down Expand Up @@ -89,7 +83,6 @@ The SDK also exports an `async` client so that you can make non-blocking calls t
import asyncio

from merge import AsyncMerge
from merge.resources.chat import DataPassthroughRequest, MethodEnum

client = AsyncMerge(
account_token="YOUR_ACCOUNT_TOKEN",
Expand All @@ -98,12 +91,7 @@ client = AsyncMerge(


async def main() -> None:
await client.chat.async_passthrough.create(
request=DataPassthroughRequest(
method=MethodEnum.GET,
path="/scooters",
),
)
await client.ats.account_token.regenerate_create()


asyncio.run(main())
Expand All @@ -118,7 +106,7 @@ will be thrown.
from merge.core.api_error import ApiError

try:
client.chat.async_passthrough.create(...)
client.ats.account_token.regenerate_create(...)
except ApiError as e:
print(e.status_code)
print(e.body)
Expand All @@ -137,9 +125,17 @@ from merge import Merge
client = Merge(
...,
)
response = client.chat.async_passthrough.with_raw_response.create(...)
response = client.ats.account_token.with_raw_response.regenerate_create(...)
print(response.headers) # access the response headers
print(response.data) # access the underlying object
pager = client.ats.activities.list(...)
print(pager.response.headers) # access the response headers 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
for item in page:
print(item) # access the underlying object(s)
```

### Retries
Expand All @@ -157,7 +153,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.chat.async_passthrough.create(..., request_options={
client.ats.account_token.regenerate_create(..., request_options={
"max_retries": 1
})
```
Expand All @@ -177,7 +173,7 @@ client = Merge(


# Override timeout for a specific method
client.chat.async_passthrough.create(..., request_options={
client.ats.account_token.regenerate_create(..., request_options={
"timeout_in_seconds": 1
})
```
Expand Down Expand Up @@ -233,35 +229,48 @@ with open(local_filename, "wb") as f:

## Pagination

The SDK may return paginated results. Endpoints that return paginated results will
include a `next` and `prev` property on the response. To get the next page, you can
pass in the value of `next` to the cursor property on the request. Similarly, to
get the previous page, you can pass in the value of `prev` to the cursor property on
the request.
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.

Below is an example of iterating over all pages:
```python
import datetime

# response contains the first page
response = merge_client.hris.employees.list(created_after="2030-01-01")
from merge import Merge
from merge.resources.ats.resources.activities import (
ActivitiesListRequestRemoteFields,
ActivitiesListRequestShowEnumOrigins,
)

# if there is a next page, load it by passing `next` to the cursor argument
while response.next is not None:
response = hris_client.employees.list(
cursor=response.next,
created_after="2030-01-01")
client = Merge(
account_token="YOUR_ACCOUNT_TOKEN",
api_key="YOUR_API_KEY",
)
response = client.ats.activities.list(
created_after=datetime.datetime.fromisoformat(
"2024-01-15 09:30:00+00:00",
),
created_before=datetime.datetime.fromisoformat(
"2024-01-15 09:30:00+00:00",
),
cursor="cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw",
include_deleted_data=True,
include_remote_data=True,
include_shell_data=True,
modified_after=datetime.datetime.fromisoformat(
"2024-01-15 09:30:00+00:00",
),
modified_before=datetime.datetime.fromisoformat(
"2024-01-15 09:30:00+00:00",
),
page_size=1,
remote_fields=ActivitiesListRequestRemoteFields.ACTIVITY_TYPE,
remote_id="remote_id",
show_enum_origins=ActivitiesListRequestShowEnumOrigins.ACTIVITY_TYPE,
user_id="user_id",
)
for item in response:
yield item
# alternatively, you can paginate page-by-page
for page in response.iter_pages():
yield page
```














20 changes: 10 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "MergePythonClient"

[tool.poetry]
name = "MergePythonClient"
version = "2.6.3"
version = "3.0.0"
description = ""
readme = "README.md"
authors = []
Expand Down
Loading
Loading