Skip to content

Commit ca007cd

Browse files
committed
SDK regeneration
1 parent c93039e commit ca007cd

File tree

2,047 files changed

+36170
-116838
lines changed

Some content is hidden

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

2,047 files changed

+36170
-116838
lines changed

.gitignore

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

README.md

Lines changed: 135 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Merge Python Library
22

3-
[![pypi](https://img.shields.io/pypi/v/MergePythonClient.svg)](https://pypi.python.org/pypi/MergePythonClient)
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%2Fmerge-api%2Fmerge-python-client)
4+
[![pypi](https://img.shields.io/pypi/v/MergePythonClient)](https://pypi.python.org/pypi/MergePythonClient)
45

5-
The Merge Python library provides access to the Merge API from Python.
6+
The Merge Python library provides convenient access to the Merge API from Python.
67

78
## Documentation
89

@@ -11,9 +12,13 @@ API reference documentation is available [here](https://docs.merge.dev/).
1112
## Installation
1213

1314
```sh
14-
pip install --upgrade MergePythonClient
15+
pip install MergePythonClient
1516
```
1617

18+
## Reference
19+
20+
A full reference for this library is available [here](https://github.com/merge-api/merge-python-client/blob/HEAD/./reference.md).
21+
1722
## Instantiation
1823

1924
```python
@@ -39,53 +44,64 @@ client.hris. # APIs specific to the HRIS Category
3944

4045
## Usage
4146

42-
### Async Client
43-
The SDK also exports an async client so that you can make non-blocking
44-
calls to our API. This client leverages `httpx`'s AsyncClient, and exports all the same functions and functionality of the sync client.
47+
Instantiate and use the client with the following:
48+
49+
```python
50+
from merge import Merge
51+
from merge.resources.ats import ActivityRequest
52+
53+
client = Merge(
54+
account_token="YOUR_ACCOUNT_TOKEN",
55+
api_key="YOUR_API_KEY",
56+
)
57+
client.ats.activities.create(
58+
model=ActivityRequest(),
59+
remote_user_id="remote_user_id",
60+
)
61+
```
62+
63+
## Async Client
64+
65+
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
4566

4667
```python
4768
import asyncio
48-
from merge.client import AsyncMerge
69+
70+
from merge import AsyncMerge
71+
from merge.resources.ats import ActivityRequest
4972

5073
client = AsyncMerge(
51-
api_key="<YOUR_API_KEY>",
52-
account_token="<YOUR_ACCOUNT_TOKEN>")
74+
account_token="YOUR_ACCOUNT_TOKEN",
75+
api_key="YOUR_API_KEY",
76+
)
77+
5378

5479
async def main() -> None:
55-
await merge_client.ats.link_token.create(
56-
end_user_email_address="[email protected]",
57-
end_user_organization_name="acme",
58-
end_user_origin_id="1234",
59-
categories=[CategoriesEnum.ATS],
60-
link_expiry_mins=30,
80+
await client.ats.activities.create(
81+
model=ActivityRequest(),
82+
remote_user_id="remote_user_id",
6183
)
6284

85+
6386
asyncio.run(main())
6487
```
6588

66-
### Create Link Token
89+
## Exception Handling
6790

68-
```python
69-
import merge
70-
from merge.client import Merge
71-
from merge.resources.ats.types import CategoriesEnum
72-
73-
merge_client = Merge(
74-
api_key="<YOUR_API_KEY>",
75-
account_token="<YOUR_ACCOUNT_TOKEN>")
91+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
92+
will be thrown.
7693

77-
link_token_response = merge_client.ats.link_token.create(
78-
end_user_email_address="[email protected]",
79-
end_user_organization_name="acme",
80-
end_user_origin_id="1234",
81-
categories=[CategoriesEnum.ATS],
82-
link_expiry_mins=30,
83-
)
94+
```python
95+
from merge.core.api_error import ApiError
8496

85-
print("Created link token", link_token_response.link_token)
97+
try:
98+
client.ats.activities.create(...)
99+
except ApiError as e:
100+
print(e.status_code)
101+
print(e.body)
86102
```
87103

88-
### Get Employee
104+
## File Download
89105

90106
```python
91107
import merge
@@ -95,122 +111,127 @@ merge_client = Merge(
95111
api_key="<YOUR_API_KEY>",
96112
account_token="<YOUR_ACCOUNT_TOKEN>")
97113

98-
employee = merge_client.hris.employees.retrieve(
99-
id="0958cbc6-6040-430a-848e-aafacbadf4ae")
114+
files = merge_client.filestorage.files.list(name="<FILE_NAME>").results
115+
116+
id = files[0].id
117+
name = files[0].name
118+
local_filename = f"<LOCAL_FILE_PATH>/{name}"
119+
120+
response = merge_client.filestorage.files.download_retrieve(id=id)
121+
with open(local_filename, "wb") as f:
122+
for chunk in response:
123+
f.write(chunk)
100124
```
101125

102-
### Get Candidate
126+
## Pagination
103127

104-
```python
105-
import merge
106-
from merge.client import Merge
128+
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.
107129

108-
merge_client = Merge(
109-
api_key="<YOUR_API_KEY>",
110-
account_token="<YOUR_ACCOUNT_TOKEN>")
130+
```python
131+
from merge import Merge
111132

112-
candidate = merge_client.ats.candidates.retrieve(
113-
id="521b18c2-4d01-4297-b451-19858d07c133")
133+
client = Merge(
134+
account_token="YOUR_ACCOUNT_TOKEN",
135+
api_key="YOUR_API_KEY",
136+
)
137+
response = client.ats.activities.list()
138+
for item in response:
139+
yield item
140+
# alternatively, you can paginate page-by-page
141+
for page in response.iter_pages():
142+
yield page
114143
```
115144

116-
### Filter Candidate
145+
## Advanced
117146

118-
```python
119-
import merge
120-
from merge.client import Merge
147+
### Access Raw Response Data
121148

122-
merge_client = Merge(
123-
api_key="<YOUR_API_KEY>",
124-
account_token="<YOUR_ACCOUNT_TOKEN>")
149+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
150+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
125151

126-
candidates_response = merge_client.ats.candidates.list(
127-
created_after="2030-01-01")
152+
```python
153+
from merge import Merge
128154

129-
print(candidates_response.results)
155+
client = Merge(
156+
...,
157+
)
158+
response = client.ats.activities.with_raw_response.create(...)
159+
print(response.headers) # access the response headers
160+
print(response.data) # access the underlying object
161+
pager = client.ats.activities.list(...)
162+
print(pager.response.headers) # access the response headers for the first page
163+
for item in pager:
164+
print(item) # access the underlying object(s)
165+
for page in pager.iter_pages():
166+
print(page.response.headers) # access the response headers for each page
167+
for item in page:
168+
print(item) # access the underlying object(s)
130169
```
131170

132-
### Get Contact
171+
### Retries
133172

134-
```python
135-
import merge
136-
from merge.client import Merge
173+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
174+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
175+
retry limit (default: 2).
137176

138-
merge_client = Merge(
139-
api_key="<YOUR_API_KEY>",
140-
account_token="<YOUR_ACCOUNT_TOKEN>")
177+
A request is deemed retryable when any of the following HTTP status codes is returned:
141178

142-
contact = merge_client.accounting.contacts.retrieve(
143-
id="c640b80b-fac9-409f-aa19-1f9221aec445")
144-
```
179+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
180+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
181+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
145182

146-
### Create Ticket
183+
Use the `max_retries` request option to configure this behavior.
147184

148185
```python
149-
import merge
150-
from merge.client import Merge
151-
from merge.resources.ticketing.types import TicketStatusEnum
152-
153-
merge_client = Merge(
154-
api_key="<YOUR_API_KEY>",
155-
account_token="<YOUR_ACCOUNT_TOKEN>")
156-
157-
merge_client.ticketing.tickets.create(
158-
model=merge.ticketing.TicketRequest(
159-
name="Please add more integrations",
160-
assignees=[
161-
"17a54124-287f-494d-965e-3c5b330c9a68"
162-
],
163-
creator="3fa85f64-5717-4562-b3fc-2c963f66afa6",
164-
due_date="2022-10-11T00:00:00Z",
165-
status=TicketStatusEnum.OPEN,
166-
))
186+
client.ats.activities.create(..., request_options={
187+
"max_retries": 1
188+
})
167189
```
168190

169-
## File Download
191+
### Timeouts
192+
193+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
170194

171195
```python
172-
import merge
173-
from merge.client import Merge
174196

175-
merge_client = Merge(
176-
api_key="<YOUR_API_KEY>",
177-
account_token="<YOUR_ACCOUNT_TOKEN>")
197+
from merge import Merge
178198

179-
files = merge_client.filestorage.files.list(name="<FILE_NAME>").results
199+
client = Merge(
200+
...,
201+
timeout=20.0,
202+
)
180203

181-
id = files[0].id
182-
name = files[0].name
183-
local_filename = f"<LOCAL_FILE_PATH>/{name}"
184204

185-
response = merge_client.filestorage.files.download_retrieve(id=id)
186-
with open(local_filename, "wb") as f:
187-
for chunk in response:
188-
f.write(chunk)
205+
# Override timeout for a specific method
206+
client.ats.activities.create(..., request_options={
207+
"timeout_in_seconds": 1
208+
})
189209
```
190210

191-
## Pagination
211+
### Custom Client
192212

193-
The SDK may return paginated results. Endpoints that return paginated results will
194-
include a `next` and `prev` property on the response. To get the next page, you can
195-
pass in the value of `next` to the cursor property on the request. Similarly, to
196-
get the previous page, you can pass in the value of `prev` to the cursor property on
197-
the request.
213+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
214+
and transports.
198215

199-
Below is an example of iterating over all pages:
200216
```python
201-
202-
# response contains the first page
203-
response = merge_client.hris.employees.list(created_after="2030-01-01")
204-
205-
# if there is a next page, load it by passing `next` to the cursor argument
206-
while response.next is not None:
207-
response = hris_client.employees.list(
208-
cursor=response.next,
209-
created_after="2030-01-01")
217+
import httpx
218+
from merge import Merge
219+
220+
client = Merge(
221+
...,
222+
httpx_client=httpx.Client(
223+
proxies="http://my.test.proxy.example.com",
224+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
225+
),
226+
)
210227
```
211228

212229
## Contributing
213230

214-
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
231+
While we value open-source contributions to this SDK, this library is generated programmatically.
232+
Additions made directly to this library would have to be moved over to our generation code,
233+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
234+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
235+
an issue first to discuss with us!
215236

216237
On the other hand, contributions to the README are always very welcome!

0 commit comments

Comments
 (0)