Skip to content

Commit eb87919

Browse files
feat(api): update via SDK Studio (#12)
1 parent 3eb5960 commit eb87919

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
@@ -50,12 +50,7 @@ const client = new Zeroentropy({
5050
});
5151

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

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

9281
main();
@@ -121,7 +110,7 @@ const client = new Zeroentropy({
121110
});
122111

123112
// Or, configure per-request:
124-
await client.documents.add({ collection_name: 'example_collection', content: { type: 'text', text: 'Example Content' }, path: 'my_document.txt' }, {
113+
await client.status.getStatus({
125114
maxRetries: 5,
126115
});
127116
```
@@ -138,7 +127,7 @@ const client = new Zeroentropy({
138127
});
139128

140129
// Override per-request:
141-
await client.documents.add({ collection_name: 'example_collection', content: { type: 'text', text: 'Example Content' }, path: 'my_document.txt' }, {
130+
await client.status.getStatus({
142131
timeout: 5 * 1000,
143132
});
144133
```
@@ -192,25 +181,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
192181
```ts
193182
const client = new Zeroentropy();
194183

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

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

216193
### Making custom/undocumented requests
@@ -314,16 +291,9 @@ const client = new Zeroentropy({
314291
});
315292

316293
// Override per-request:
317-
await client.documents.add(
318-
{
319-
collection_name: 'example_collection',
320-
content: { type: 'text', text: 'Example Content' },
321-
path: 'my_document.txt',
322-
},
323-
{
324-
httpAgent: new http.Agent({ keepAlive: false }),
325-
},
326-
);
294+
await client.status.getStatus({
295+
httpAgent: new http.Agent({ keepAlive: false }),
296+
});
327297
```
328298

329299
## Semantic versioning

0 commit comments

Comments
 (0)