@@ -19,6 +19,24 @@ pip install MergePythonClient
19
19
20
20
A full reference for this library is available [ here] ( https://github.com/merge-api/merge-python-client/blob/HEAD/./reference.md ) .
21
21
22
+ ## Usage
23
+
24
+ Instantiate and use the client with the following:
25
+
26
+ ``` python
27
+ from merge import Merge
28
+ from merge.resources.ats import ActivityRequest
29
+
30
+ client = Merge(
31
+ account_token = " YOUR_ACCOUNT_TOKEN" ,
32
+ api_key = " YOUR_API_KEY" ,
33
+ )
34
+ client.ats.activities.create(
35
+ model = ActivityRequest(),
36
+ remote_user_id = " remote_user_id" ,
37
+ )
38
+ ```
39
+
22
40
## Instantiation
23
41
24
42
``` python
@@ -42,24 +60,6 @@ client.ats. # APIs specific to the ATS Category
42
60
client.hris. # APIs specific to the HRIS Category
43
61
```
44
62
45
- ## Usage
46
-
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
63
## Async Client
64
64
65
65
The SDK also exports an ` async ` client so that you can make non-blocking calls to our API.
@@ -101,49 +101,6 @@ except ApiError as e:
101
101
print (e.body)
102
102
```
103
103
104
- ## File Download
105
-
106
- ``` python
107
- import merge
108
- from merge.client import Merge
109
-
110
- merge_client = Merge(
111
- api_key = " <YOUR_API_KEY>" ,
112
- account_token = " <YOUR_ACCOUNT_TOKEN>" )
113
-
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)
124
- ```
125
-
126
- ## Pagination
127
-
128
- The SDK may return paginated results. Endpoints that return paginated results will
129
- include a ` next ` and ` prev ` property on the response. To get the next page, you can
130
- pass in the value of ` next ` to the cursor property on the request. Similarly, to
131
- get the previous page, you can pass in the value of ` prev ` to the cursor property on
132
- the request.
133
-
134
- Below is an example of iterating over all pages:
135
- ``` python
136
-
137
- # response contains the first page
138
- response = merge_client.hris.employees.list(created_after = " 2030-01-01" )
139
-
140
- # if there is a next page, load it by passing `next` to the cursor argument
141
- while response.next is not None :
142
- response = hris_client.employees.list(
143
- cursor = response.next,
144
- created_after = " 2030-01-01" )
145
- ```
146
-
147
104
## Advanced
148
105
149
106
### Access Raw Response Data
@@ -229,3 +186,46 @@ a proof of concept, but know that we will not be able to merge it as-is. We sugg
229
186
an issue first to discuss with us!
230
187
231
188
On the other hand, contributions to the README are always very welcome!
189
+ ## File Download
190
+
191
+ ``` python
192
+ import merge
193
+ from merge.client import Merge
194
+
195
+ merge_client = Merge(
196
+ api_key = " <YOUR_API_KEY>" ,
197
+ account_token = " <YOUR_ACCOUNT_TOKEN>" )
198
+
199
+ files = merge_client.filestorage.files.list(name = " <FILE_NAME>" ).results
200
+
201
+ id = files[0 ].id
202
+ name = files[0 ].name
203
+ local_filename = f " <LOCAL_FILE_PATH>/ { name} "
204
+
205
+ response = merge_client.filestorage.files.download_retrieve(id = id )
206
+ with open (local_filename, " wb" ) as f:
207
+ for chunk in response:
208
+ f.write(chunk)
209
+ ```
210
+
211
+ ## Pagination
212
+
213
+ The SDK may return paginated results. Endpoints that return paginated results will
214
+ include a ` next ` and ` prev ` property on the response. To get the next page, you can
215
+ pass in the value of ` next ` to the cursor property on the request. Similarly, to
216
+ get the previous page, you can pass in the value of ` prev ` to the cursor property on
217
+ the request.
218
+
219
+ Below is an example of iterating over all pages:
220
+ ``` python
221
+
222
+ # response contains the first page
223
+ response = merge_client.hris.employees.list(created_after = " 2030-01-01" )
224
+
225
+ # if there is a next page, load it by passing `next` to the cursor argument
226
+ while response.next is not None :
227
+ response = hris_client.employees.list(
228
+ cursor = response.next,
229
+ created_after = " 2030-01-01" )
230
+ ```
231
+
0 commit comments