Skip to content

Commit

Permalink
feat(client): support results endpoint (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 22, 2025
1 parent 628b55e commit db5fffe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fd67aea6883f1ee9e46f31a42d3940f0acb1749e787055bd9b9f278b20fa53ec.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-75f0573c3d6d79650bcbd8b1b4fcf93ce146d567afeb1061cd4afccf8d1d6799.yml
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Methods:
- <code title="get /v1/messages/batches">client.messages.batches.<a href="./src/resources/messages/batches.ts">list</a>({ ...params }) -> MessageBatchesPage</code>
- <code title="delete /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/resources/messages/batches.ts">delete</a>(messageBatchId) -> DeletedMessageBatch</code>
- <code title="post /v1/messages/batches/{message_batch_id}/cancel">client.messages.batches.<a href="./src/resources/messages/batches.ts">cancel</a>(messageBatchId) -> MessageBatch</code>
- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder&lt;MessageBatchIndividualResponse&gt;</code>

# Models

Expand Down Expand Up @@ -194,4 +194,4 @@ Methods:
- <code title="get /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">list</a>({ ...params }) -> BetaMessageBatchesPage</code>
- <code title="delete /v1/messages/batches/{message_batch_id}?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">delete</a>(messageBatchId, { ...params }) -> BetaDeletedMessageBatch</code>
- <code title="post /v1/messages/batches/{message_batch_id}/cancel?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">cancel</a>(messageBatchId, { ...params }) -> BetaMessageBatch</code>
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">results</a>(messageBatchId, { ...params }) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">results</a>(messageBatchId, { ...params }) -> JSONLDecoder&lt;BetaMessageBatchIndividualResponse&gt;</code>
18 changes: 16 additions & 2 deletions tests/api-resources/beta/messages/batches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,28 @@ describe('resource batches', () => {
).rejects.toThrow(Anthropic.NotFoundError);
});

test('results: request options instead of params are passed correctly', async () => {
// Prism doesn't support JSONL responses yet
test.skip('results', async () => {
const responsePromise = client.beta.messages.batches.results('message_batch_id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism doesn't support JSONL responses yet
test.skip('results: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
client.beta.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Anthropic.NotFoundError);
});

test('results: request options and params are passed correctly', async () => {
// Prism doesn't support JSONL responses yet
test.skip('results: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
client.beta.messages.batches.results(
Expand Down
15 changes: 14 additions & 1 deletion tests/api-resources/messages/batches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,20 @@ describe('resource batches', () => {
).rejects.toThrow(Anthropic.NotFoundError);
});

test('results: request options instead of params are passed correctly', async () => {
// Prism doesn't support JSONL responses yet
test.skip('results', async () => {
const responsePromise = client.messages.batches.results('message_batch_id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism doesn't support JSONL responses yet
test.skip('results: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
client.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
Expand Down

0 comments on commit db5fffe

Please # to comment.