Skip to content

Commit f09d0a2

Browse files
feat(api): update via SDK Studio (#12)
1 parent a21a03b commit f09d0a2

File tree

1 file changed

+18
-48
lines changed

1 file changed

+18
-48
lines changed

README.md

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ const client = new Zeroentropy({
5252
});
5353

5454
async function main() {
55-
const params: Zeroentropy.DocumentAddParams = {
56-
collection_name: 'example_collection',
57-
content: { type: 'text', text: 'Example Content' },
58-
path: 'my_document.txt',
59-
};
60-
const response: Zeroentropy.DocumentAddResponse = await client.documents.add(params);
55+
const response: Zeroentropy.StatusGetStatusResponse = await client.status.getStatus();
6156
}
6257

6358
main();
@@ -74,21 +69,15 @@ a subclass of `APIError` will be thrown:
7469
<!-- prettier-ignore -->
7570
```ts
7671
async function main() {
77-
const response = await client.documents
78-
.add({
79-
collection_name: 'example_collection',
80-
content: { type: 'text', text: 'Example Content' },
81-
path: 'my_document.txt',
82-
})
83-
.catch(async (err) => {
84-
if (err instanceof Zeroentropy.APIError) {
85-
console.log(err.status); // 400
86-
console.log(err.name); // BadRequestError
87-
console.log(err.headers); // {server: 'nginx', ...}
88-
} else {
89-
throw err;
90-
}
91-
});
72+
const response = await client.status.getStatus().catch(async (err) => {
73+
if (err instanceof Zeroentropy.APIError) {
74+
console.log(err.status); // 400
75+
console.log(err.name); // BadRequestError
76+
console.log(err.headers); // {server: 'nginx', ...}
77+
} else {
78+
throw err;
79+
}
80+
});
9281
}
9382

9483
main();
@@ -123,7 +112,7 @@ const client = new Zeroentropy({
123112
});
124113

125114
// Or, configure per-request:
126-
await client.documents.add({ collection_name: 'example_collection', content: { type: 'text', text: 'Example Content' }, path: 'my_document.txt' }, {
115+
await client.status.getStatus({
127116
maxRetries: 5,
128117
});
129118
```
@@ -140,7 +129,7 @@ const client = new Zeroentropy({
140129
});
141130

142131
// Override per-request:
143-
await client.documents.add({ collection_name: 'example_collection', content: { type: 'text', text: 'Example Content' }, path: 'my_document.txt' }, {
132+
await client.status.getStatus({
144133
timeout: 5 * 1000,
145134
});
146135
```
@@ -194,25 +183,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
194183
```ts
195184
const client = new Zeroentropy();
196185

197-
const response = await client.documents
198-
.add({
199-
collection_name: 'example_collection',
200-
content: { type: 'text', text: 'Example Content' },
201-
path: 'my_document.txt',
202-
})
203-
.asResponse();
186+
const response = await client.status.getStatus().asResponse();
204187
console.log(response.headers.get('X-My-Header'));
205188
console.log(response.statusText); // access the underlying Response object
206189

207-
const { data: response, response: raw } = await client.documents
208-
.add({
209-
collection_name: 'example_collection',
210-
content: { type: 'text', text: 'Example Content' },
211-
path: 'my_document.txt',
212-
})
213-
.withResponse();
190+
const { data: response, response: raw } = await client.status.getStatus().withResponse();
214191
console.log(raw.headers.get('X-My-Header'));
215-
console.log(response.message);
192+
console.log(response.num_documents);
216193
```
217194

218195
### Making custom/undocumented requests
@@ -316,16 +293,9 @@ const client = new Zeroentropy({
316293
});
317294

318295
// Override per-request:
319-
await client.documents.add(
320-
{
321-
collection_name: 'example_collection',
322-
content: { type: 'text', text: 'Example Content' },
323-
path: 'my_document.txt',
324-
},
325-
{
326-
httpAgent: new http.Agent({ keepAlive: false }),
327-
},
328-
);
296+
await client.status.getStatus({
297+
httpAgent: new http.Agent({ keepAlive: false }),
298+
});
329299
```
330300

331301
## Semantic versioning

0 commit comments

Comments
 (0)