mergepythonclient 2.0.0__py3-none-any.whl → 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- merge/client.py +14 -4
- merge/core/client_wrapper.py +16 -4
- {mergepythonclient-2.0.0.dist-info → mergepythonclient-2.1.0.dist-info}/METADATA +63 -63
- {mergepythonclient-2.0.0.dist-info → mergepythonclient-2.1.0.dist-info}/RECORD +6 -6
- {mergepythonclient-2.0.0.dist-info → mergepythonclient-2.1.0.dist-info}/LICENSE.md +0 -0
- {mergepythonclient-2.0.0.dist-info → mergepythonclient-2.1.0.dist-info}/WHEEL +0 -0
merge/client.py
CHANGED
|
@@ -33,6 +33,9 @@ class Merge:
|
|
|
33
33
|
|
|
34
34
|
account_token : typing.Optional[str]
|
|
35
35
|
api_key : typing.Union[str, typing.Callable[[], str]]
|
|
36
|
+
headers : typing.Optional[typing.Dict[str, str]]
|
|
37
|
+
Additional headers to send with every request.
|
|
38
|
+
|
|
36
39
|
timeout : typing.Optional[float]
|
|
37
40
|
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
38
41
|
|
|
@@ -59,6 +62,7 @@ class Merge:
|
|
|
59
62
|
environment: MergeEnvironment = MergeEnvironment.PRODUCTION,
|
|
60
63
|
account_token: typing.Optional[str] = None,
|
|
61
64
|
api_key: typing.Union[str, typing.Callable[[], str]],
|
|
65
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
62
66
|
timeout: typing.Optional[float] = None,
|
|
63
67
|
follow_redirects: typing.Optional[bool] = True,
|
|
64
68
|
httpx_client: typing.Optional[httpx.Client] = None,
|
|
@@ -70,6 +74,7 @@ class Merge:
|
|
|
70
74
|
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
71
75
|
account_token=account_token,
|
|
72
76
|
api_key=api_key,
|
|
77
|
+
headers=headers,
|
|
73
78
|
httpx_client=httpx_client
|
|
74
79
|
if httpx_client is not None
|
|
75
80
|
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
@@ -78,10 +83,10 @@ class Merge:
|
|
|
78
83
|
timeout=_defaulted_timeout,
|
|
79
84
|
)
|
|
80
85
|
self.ats = AtsClient(client_wrapper=self._client_wrapper)
|
|
81
|
-
self.filestorage = FilestorageClient(client_wrapper=self._client_wrapper)
|
|
82
|
-
self.ticketing = TicketingClient(client_wrapper=self._client_wrapper)
|
|
83
86
|
self.crm = CrmClient(client_wrapper=self._client_wrapper)
|
|
87
|
+
self.filestorage = FilestorageClient(client_wrapper=self._client_wrapper)
|
|
84
88
|
self.hris = HrisClient(client_wrapper=self._client_wrapper)
|
|
89
|
+
self.ticketing = TicketingClient(client_wrapper=self._client_wrapper)
|
|
85
90
|
self.accounting = AccountingClient(client_wrapper=self._client_wrapper)
|
|
86
91
|
|
|
87
92
|
|
|
@@ -105,6 +110,9 @@ class AsyncMerge:
|
|
|
105
110
|
|
|
106
111
|
account_token : typing.Optional[str]
|
|
107
112
|
api_key : typing.Union[str, typing.Callable[[], str]]
|
|
113
|
+
headers : typing.Optional[typing.Dict[str, str]]
|
|
114
|
+
Additional headers to send with every request.
|
|
115
|
+
|
|
108
116
|
timeout : typing.Optional[float]
|
|
109
117
|
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
110
118
|
|
|
@@ -131,6 +139,7 @@ class AsyncMerge:
|
|
|
131
139
|
environment: MergeEnvironment = MergeEnvironment.PRODUCTION,
|
|
132
140
|
account_token: typing.Optional[str] = None,
|
|
133
141
|
api_key: typing.Union[str, typing.Callable[[], str]],
|
|
142
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
134
143
|
timeout: typing.Optional[float] = None,
|
|
135
144
|
follow_redirects: typing.Optional[bool] = True,
|
|
136
145
|
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
@@ -142,6 +151,7 @@ class AsyncMerge:
|
|
|
142
151
|
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
143
152
|
account_token=account_token,
|
|
144
153
|
api_key=api_key,
|
|
154
|
+
headers=headers,
|
|
145
155
|
httpx_client=httpx_client
|
|
146
156
|
if httpx_client is not None
|
|
147
157
|
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
@@ -150,10 +160,10 @@ class AsyncMerge:
|
|
|
150
160
|
timeout=_defaulted_timeout,
|
|
151
161
|
)
|
|
152
162
|
self.ats = AsyncAtsClient(client_wrapper=self._client_wrapper)
|
|
153
|
-
self.filestorage = AsyncFilestorageClient(client_wrapper=self._client_wrapper)
|
|
154
|
-
self.ticketing = AsyncTicketingClient(client_wrapper=self._client_wrapper)
|
|
155
163
|
self.crm = AsyncCrmClient(client_wrapper=self._client_wrapper)
|
|
164
|
+
self.filestorage = AsyncFilestorageClient(client_wrapper=self._client_wrapper)
|
|
156
165
|
self.hris = AsyncHrisClient(client_wrapper=self._client_wrapper)
|
|
166
|
+
self.ticketing = AsyncTicketingClient(client_wrapper=self._client_wrapper)
|
|
157
167
|
self.accounting = AsyncAccountingClient(client_wrapper=self._client_wrapper)
|
|
158
168
|
|
|
159
169
|
|
merge/core/client_wrapper.py
CHANGED
|
@@ -12,20 +12,23 @@ class BaseClientWrapper:
|
|
|
12
12
|
*,
|
|
13
13
|
account_token: typing.Optional[str] = None,
|
|
14
14
|
api_key: typing.Union[str, typing.Callable[[], str]],
|
|
15
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
15
16
|
base_url: str,
|
|
16
17
|
timeout: typing.Optional[float] = None,
|
|
17
18
|
):
|
|
18
19
|
self._account_token = account_token
|
|
19
20
|
self._api_key = api_key
|
|
21
|
+
self._headers = headers
|
|
20
22
|
self._base_url = base_url
|
|
21
23
|
self._timeout = timeout
|
|
22
24
|
|
|
23
25
|
def get_headers(self) -> typing.Dict[str, str]:
|
|
24
26
|
headers: typing.Dict[str, str] = {
|
|
25
|
-
"User-Agent": "MergePythonClient/2.
|
|
27
|
+
"User-Agent": "MergePythonClient/2.1.0",
|
|
26
28
|
"X-Fern-Language": "Python",
|
|
27
29
|
"X-Fern-SDK-Name": "MergePythonClient",
|
|
28
|
-
"X-Fern-SDK-Version": "2.
|
|
30
|
+
"X-Fern-SDK-Version": "2.1.0",
|
|
31
|
+
**(self.get_custom_headers() or {}),
|
|
29
32
|
}
|
|
30
33
|
if self._account_token is not None:
|
|
31
34
|
headers["X-Account-Token"] = self._account_token
|
|
@@ -38,6 +41,9 @@ class BaseClientWrapper:
|
|
|
38
41
|
else:
|
|
39
42
|
return self._api_key()
|
|
40
43
|
|
|
44
|
+
def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
|
|
45
|
+
return self._headers
|
|
46
|
+
|
|
41
47
|
def get_base_url(self) -> str:
|
|
42
48
|
return self._base_url
|
|
43
49
|
|
|
@@ -51,11 +57,14 @@ class SyncClientWrapper(BaseClientWrapper):
|
|
|
51
57
|
*,
|
|
52
58
|
account_token: typing.Optional[str] = None,
|
|
53
59
|
api_key: typing.Union[str, typing.Callable[[], str]],
|
|
60
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
54
61
|
base_url: str,
|
|
55
62
|
timeout: typing.Optional[float] = None,
|
|
56
63
|
httpx_client: httpx.Client,
|
|
57
64
|
):
|
|
58
|
-
super().__init__(
|
|
65
|
+
super().__init__(
|
|
66
|
+
account_token=account_token, api_key=api_key, headers=headers, base_url=base_url, timeout=timeout
|
|
67
|
+
)
|
|
59
68
|
self.httpx_client = HttpClient(
|
|
60
69
|
httpx_client=httpx_client,
|
|
61
70
|
base_headers=self.get_headers,
|
|
@@ -70,11 +79,14 @@ class AsyncClientWrapper(BaseClientWrapper):
|
|
|
70
79
|
*,
|
|
71
80
|
account_token: typing.Optional[str] = None,
|
|
72
81
|
api_key: typing.Union[str, typing.Callable[[], str]],
|
|
82
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
73
83
|
base_url: str,
|
|
74
84
|
timeout: typing.Optional[float] = None,
|
|
75
85
|
httpx_client: httpx.AsyncClient,
|
|
76
86
|
):
|
|
77
|
-
super().__init__(
|
|
87
|
+
super().__init__(
|
|
88
|
+
account_token=account_token, api_key=api_key, headers=headers, base_url=base_url, timeout=timeout
|
|
89
|
+
)
|
|
78
90
|
self.httpx_client = AsyncHttpClient(
|
|
79
91
|
httpx_client=httpx_client,
|
|
80
92
|
base_headers=self.get_headers,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mergepythonclient
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary:
|
|
5
5
|
Requires-Python: >=3.8,<4.0
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -20,7 +20,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
20
20
|
Classifier: Typing :: Typed
|
|
21
21
|
Requires-Dist: httpx (>=0.21.2)
|
|
22
22
|
Requires-Dist: pydantic (>=1.9.2)
|
|
23
|
-
Requires-Dist: pydantic-core (>=2.18.2
|
|
23
|
+
Requires-Dist: pydantic-core (>=2.18.2)
|
|
24
24
|
Requires-Dist: typing_extensions (>=4.0.0)
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
|
|
@@ -45,6 +45,24 @@ pip install MergePythonClient
|
|
|
45
45
|
|
|
46
46
|
A full reference for this library is available [here](https://github.com/merge-api/merge-python-client/blob/HEAD/./reference.md).
|
|
47
47
|
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
Instantiate and use the client with the following:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from merge import Merge
|
|
54
|
+
from merge.resources.ats import ActivityRequest
|
|
55
|
+
|
|
56
|
+
client = Merge(
|
|
57
|
+
account_token="YOUR_ACCOUNT_TOKEN",
|
|
58
|
+
api_key="YOUR_API_KEY",
|
|
59
|
+
)
|
|
60
|
+
client.ats.activities.create(
|
|
61
|
+
model=ActivityRequest(),
|
|
62
|
+
remote_user_id="remote_user_id",
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
48
66
|
## Instantiation
|
|
49
67
|
|
|
50
68
|
```python
|
|
@@ -68,24 +86,6 @@ client.ats. # APIs specific to the ATS Category
|
|
|
68
86
|
client.hris. # APIs specific to the HRIS Category
|
|
69
87
|
```
|
|
70
88
|
|
|
71
|
-
## Usage
|
|
72
|
-
|
|
73
|
-
Instantiate and use the client with the following:
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
from merge import Merge
|
|
77
|
-
from merge.resources.ats import ActivityRequest
|
|
78
|
-
|
|
79
|
-
client = Merge(
|
|
80
|
-
account_token="YOUR_ACCOUNT_TOKEN",
|
|
81
|
-
api_key="YOUR_API_KEY",
|
|
82
|
-
)
|
|
83
|
-
client.ats.activities.create(
|
|
84
|
-
model=ActivityRequest(),
|
|
85
|
-
remote_user_id="remote_user_id",
|
|
86
|
-
)
|
|
87
|
-
```
|
|
88
|
-
|
|
89
89
|
## Async Client
|
|
90
90
|
|
|
91
91
|
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
|
|
@@ -127,49 +127,6 @@ except ApiError as e:
|
|
|
127
127
|
print(e.body)
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
## File Download
|
|
131
|
-
|
|
132
|
-
```python
|
|
133
|
-
import merge
|
|
134
|
-
from merge.client import Merge
|
|
135
|
-
|
|
136
|
-
merge_client = Merge(
|
|
137
|
-
api_key="<YOUR_API_KEY>",
|
|
138
|
-
account_token="<YOUR_ACCOUNT_TOKEN>")
|
|
139
|
-
|
|
140
|
-
files = merge_client.filestorage.files.list(name="<FILE_NAME>").results
|
|
141
|
-
|
|
142
|
-
id = files[0].id
|
|
143
|
-
name = files[0].name
|
|
144
|
-
local_filename = f"<LOCAL_FILE_PATH>/{name}"
|
|
145
|
-
|
|
146
|
-
response = merge_client.filestorage.files.download_retrieve(id=id)
|
|
147
|
-
with open(local_filename, "wb") as f:
|
|
148
|
-
for chunk in response:
|
|
149
|
-
f.write(chunk)
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Pagination
|
|
153
|
-
|
|
154
|
-
The SDK may return paginated results. Endpoints that return paginated results will
|
|
155
|
-
include a `next` and `prev` property on the response. To get the next page, you can
|
|
156
|
-
pass in the value of `next` to the cursor property on the request. Similarly, to
|
|
157
|
-
get the previous page, you can pass in the value of `prev` to the cursor property on
|
|
158
|
-
the request.
|
|
159
|
-
|
|
160
|
-
Below is an example of iterating over all pages:
|
|
161
|
-
```python
|
|
162
|
-
|
|
163
|
-
# response contains the first page
|
|
164
|
-
response = merge_client.hris.employees.list(created_after="2030-01-01")
|
|
165
|
-
|
|
166
|
-
# if there is a next page, load it by passing `next` to the cursor argument
|
|
167
|
-
while response.next is not None:
|
|
168
|
-
response = hris_client.employees.list(
|
|
169
|
-
cursor=response.next,
|
|
170
|
-
created_after="2030-01-01")
|
|
171
|
-
```
|
|
172
|
-
|
|
173
130
|
## Advanced
|
|
174
131
|
|
|
175
132
|
### Access Raw Response Data
|
|
@@ -255,4 +212,47 @@ a proof of concept, but know that we will not be able to merge it as-is. We sugg
|
|
|
255
212
|
an issue first to discuss with us!
|
|
256
213
|
|
|
257
214
|
On the other hand, contributions to the README are always very welcome!
|
|
215
|
+
## File Download
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
import merge
|
|
219
|
+
from merge.client import Merge
|
|
220
|
+
|
|
221
|
+
merge_client = Merge(
|
|
222
|
+
api_key="<YOUR_API_KEY>",
|
|
223
|
+
account_token="<YOUR_ACCOUNT_TOKEN>")
|
|
224
|
+
|
|
225
|
+
files = merge_client.filestorage.files.list(name="<FILE_NAME>").results
|
|
226
|
+
|
|
227
|
+
id = files[0].id
|
|
228
|
+
name = files[0].name
|
|
229
|
+
local_filename = f"<LOCAL_FILE_PATH>/{name}"
|
|
230
|
+
|
|
231
|
+
response = merge_client.filestorage.files.download_retrieve(id=id)
|
|
232
|
+
with open(local_filename, "wb") as f:
|
|
233
|
+
for chunk in response:
|
|
234
|
+
f.write(chunk)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Pagination
|
|
238
|
+
|
|
239
|
+
The SDK may return paginated results. Endpoints that return paginated results will
|
|
240
|
+
include a `next` and `prev` property on the response. To get the next page, you can
|
|
241
|
+
pass in the value of `next` to the cursor property on the request. Similarly, to
|
|
242
|
+
get the previous page, you can pass in the value of `prev` to the cursor property on
|
|
243
|
+
the request.
|
|
244
|
+
|
|
245
|
+
Below is an example of iterating over all pages:
|
|
246
|
+
```python
|
|
247
|
+
|
|
248
|
+
# response contains the first page
|
|
249
|
+
response = merge_client.hris.employees.list(created_after="2030-01-01")
|
|
250
|
+
|
|
251
|
+
# if there is a next page, load it by passing `next` to the cursor argument
|
|
252
|
+
while response.next is not None:
|
|
253
|
+
response = hris_client.employees.list(
|
|
254
|
+
cursor=response.next,
|
|
255
|
+
created_after="2030-01-01")
|
|
256
|
+
```
|
|
257
|
+
|
|
258
258
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
merge/__init__.py,sha256=Z0AgfVpF84nlRCCgnrDZOwBo1TpY5yK7otpaSWcgo-U,449
|
|
2
|
-
merge/client.py,sha256=
|
|
2
|
+
merge/client.py,sha256=kU02MZFiaoEyFdw6kMEkaqof-j40fTjMLPFBAsFreTM,7342
|
|
3
3
|
merge/core/__init__.py,sha256=tpn7rjb6C2UIkYZYIqdrNpI7Yax2jw88sXh2baxaxAI,1715
|
|
4
4
|
merge/core/api_error.py,sha256=44vPoTyWN59gonCIZMdzw7M1uspygiLnr3GNFOoVL2Q,614
|
|
5
|
-
merge/core/client_wrapper.py,sha256=
|
|
5
|
+
merge/core/client_wrapper.py,sha256=sE52VmKOT-IeeN7XwaJFBmBr9tD-_j6psNnnKBPMwJM,3096
|
|
6
6
|
merge/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
|
7
7
|
merge/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
|
|
8
8
|
merge/core/force_multipart.py,sha256=awxh5MtcRYe74ehY8U76jzv6fYM_w_D3Rur7KQQzSDk,429
|
|
@@ -2259,7 +2259,7 @@ merge/resources/ticketing/types/viewer_user.py,sha256=VrOx8xWvNadSYjdErIMg2pPsHV
|
|
|
2259
2259
|
merge/resources/ticketing/types/warning_validation_problem.py,sha256=RXDtt3t3FwIeGGXkIr_OHOAybDZg44L_5hOqa2sLlJ0,736
|
|
2260
2260
|
merge/resources/ticketing/types/webhook_receiver.py,sha256=g4KQnc-vZPJGlXK-OOFIn2WGyTLKoeaq9TPWQ46VwFY,623
|
|
2261
2261
|
merge/version.py,sha256=kLtHrVsKjnCqlIC_JtezQUWrCPQkXhjpD_2pdlcGh18,84
|
|
2262
|
-
mergepythonclient-2.
|
|
2263
|
-
mergepythonclient-2.
|
|
2264
|
-
mergepythonclient-2.
|
|
2265
|
-
mergepythonclient-2.
|
|
2262
|
+
mergepythonclient-2.1.0.dist-info/LICENSE.md,sha256=WKO7xLnLSUInldiq5i25eVqKAjwIUKenaS4Cgir2Iuw,3275
|
|
2263
|
+
mergepythonclient-2.1.0.dist-info/METADATA,sha256=NWTuIqZiBROho-ox_4TEVIIH32XMXysb5aTm9DzE-j0,7265
|
|
2264
|
+
mergepythonclient-2.1.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
2265
|
+
mergepythonclient-2.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|