Skip to content

Commit 825bb76

Browse files
feat(api): update via SDK Studio
1 parent 3252195 commit 825bb76

6 files changed

Lines changed: 86 additions & 23 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 2
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/grid%2Fspreadsheet-api-9c32b0e4ddfdf467e980af727cd6cb85e7c60d4df9924a4a06a5abc38dbaf671.yml
1+
configured_endpoints: 3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/grid%2Fspreadsheet-api-4f7e4249cd44e912120dd6531cc506a8c0c0e3e3b5f0c91b18c37177b850b590.yml

api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
Types:
44

55
- <code><a href="./src/resources/workbooks.ts">WorkbookQueryResponse</a></code>
6-
- <code><a href="./src/resources/workbooks.ts">WorkbookRenderChartResponse</a></code>
76

87
Methods:
98

9+
- <code title="post /v1/workbooks/{id}/export">client.workbooks.<a href="./src/resources/workbooks.ts">export</a>(id, { ...params }) -> Response</code>
1010
- <code title="post /v1/workbooks/{id}/query">client.workbooks.<a href="./src/resources/workbooks.ts">query</a>(id, { ...params }) -> WorkbookQueryResponse</code>
11-
- <code title="post /v1/workbooks/{id}/chart">client.workbooks.<a href="./src/resources/workbooks.ts">renderChart</a>(id, { ...params }) -> unknown</code>
11+
- <code title="post /v1/workbooks/{id}/chart">client.workbooks.<a href="./src/resources/workbooks.ts">renderChart</a>(id, { ...params }) -> Response</code>

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import { type Fetch } from './internal/builtin-types';
1919
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
2020
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
2121
import {
22+
WorkbookExportParams,
2223
WorkbookQueryParams,
2324
WorkbookQueryResponse,
2425
WorkbookRenderChartParams,
25-
WorkbookRenderChartResponse,
2626
Workbooks,
2727
} from './resources/workbooks';
2828
import { readEnv } from './internal/utils/env';
@@ -632,7 +632,7 @@ export declare namespace GRID {
632632
export {
633633
Workbooks as Workbooks,
634634
type WorkbookQueryResponse as WorkbookQueryResponse,
635-
type WorkbookRenderChartResponse as WorkbookRenderChartResponse,
635+
type WorkbookExportParams as WorkbookExportParams,
636636
type WorkbookQueryParams as WorkbookQueryParams,
637637
type WorkbookRenderChartParams as WorkbookRenderChartParams,
638638
};

src/resources/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export {
44
Workbooks,
55
type WorkbookQueryResponse,
6-
type WorkbookRenderChartResponse,
6+
type WorkbookExportParams,
77
type WorkbookQueryParams,
88
type WorkbookRenderChartParams,
99
} from './workbooks';

src/resources/workbooks.ts

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@
22

33
import { APIResource } from '../resource';
44
import { APIPromise } from '../api-promise';
5+
import { buildHeaders } from '../internal/headers';
56
import { RequestOptions } from '../internal/request-options';
67
import { path } from '../internal/utils/path';
78

89
export class Workbooks extends APIResource {
10+
/**
11+
* Export a workbook as an .xlsx file. Cells can be updated before the workbook is
12+
* exported.
13+
*/
14+
export(id: string, body: WorkbookExportParams, options?: RequestOptions): APIPromise<Response> {
15+
return this._client.post(path`/v1/workbooks/${id}/export`, {
16+
body,
17+
...options,
18+
headers: buildHeaders([
19+
{ Accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' },
20+
options?.headers,
21+
]),
22+
__binaryResponse: true,
23+
});
24+
}
25+
926
/**
1027
* Read cell data or apply temporary changes.
1128
*
@@ -19,8 +36,13 @@ export class Workbooks extends APIResource {
1936
/**
2037
* Render a chart using workbook data
2138
*/
22-
renderChart(id: string, body: WorkbookRenderChartParams, options?: RequestOptions): APIPromise<unknown> {
23-
return this._client.post(path`/v1/workbooks/${id}/chart`, { body, ...options });
39+
renderChart(id: string, body: WorkbookRenderChartParams, options?: RequestOptions): APIPromise<Response> {
40+
return this._client.post(path`/v1/workbooks/${id}/chart`, {
41+
body,
42+
...options,
43+
headers: buildHeaders([{ Accept: 'image/png' }, options?.headers]),
44+
__binaryResponse: true,
45+
});
2446
}
2547
}
2648

@@ -371,7 +393,60 @@ export namespace WorkbookQueryResponse {
371393
}
372394
}
373395

374-
export type WorkbookRenderChartResponse = unknown;
396+
export interface WorkbookExportParams {
397+
/**
398+
* Cells to update before exporting
399+
*/
400+
apply?: Array<WorkbookExportParams.Apply> | null;
401+
402+
/**
403+
* Goal seek. Use this to calculate the required input value for a formula to
404+
* achieve a specified target result. This is particularly useful when the desired
405+
* outcome is known, but the corresponding input is not.
406+
*/
407+
goalSeek?: WorkbookExportParams.GoalSeek | null;
408+
}
409+
410+
export namespace WorkbookExportParams {
411+
/**
412+
* Specifies a temporary change to a workbook cell, including the `target` cell
413+
* reference and the `value` to apply. The API has no state, and so any changes
414+
* made are cleared after each request.
415+
*/
416+
export interface Apply {
417+
/**
418+
* A1-style reference for the cell to write to
419+
*/
420+
target: string;
421+
422+
/**
423+
* Value to write to the target cell
424+
*/
425+
value: number | string | boolean | null;
426+
}
427+
428+
/**
429+
* Goal seek. Use this to calculate the required input value for a formula to
430+
* achieve a specified target result. This is particularly useful when the desired
431+
* outcome is known, but the corresponding input is not.
432+
*/
433+
export interface GoalSeek {
434+
/**
435+
* Reference for the cell that will contain the solution
436+
*/
437+
controlCell: string;
438+
439+
/**
440+
* Reference for the cell that contains the formula you want to resolve
441+
*/
442+
targetCell: string;
443+
444+
/**
445+
* The value you want the formula to return
446+
*/
447+
targetValue: number;
448+
}
449+
}
375450

376451
export interface WorkbookQueryParams {
377452
/**
@@ -539,7 +614,7 @@ export namespace WorkbookRenderChartParams {
539614
export declare namespace Workbooks {
540615
export {
541616
type WorkbookQueryResponse as WorkbookQueryResponse,
542-
type WorkbookRenderChartResponse as WorkbookRenderChartResponse,
617+
type WorkbookExportParams as WorkbookExportParams,
543618
type WorkbookQueryParams as WorkbookQueryParams,
544619
type WorkbookRenderChartParams as WorkbookRenderChartParams,
545620
};

tests/api-resources/workbooks.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ describe('resource workbooks', () => {
3030
});
3131
});
3232

33-
// skipped: tests are disabled for the time being
34-
test.skip('renderChart: only required params', async () => {
35-
const responsePromise = client.workbooks.renderChart('id', { chart: { data: '=C2:C142' } });
36-
const rawResponse = await responsePromise.asResponse();
37-
expect(rawResponse).toBeInstanceOf(Response);
38-
const response = await responsePromise;
39-
expect(response).not.toBeInstanceOf(Response);
40-
const dataAndResponse = await responsePromise.withResponse();
41-
expect(dataAndResponse.data).toBe(response);
42-
expect(dataAndResponse.response).toBe(rawResponse);
43-
});
44-
4533
// skipped: tests are disabled for the time being
4634
test.skip('renderChart: required and optional params', async () => {
4735
const response = await client.workbooks.renderChart('id', {

0 commit comments

Comments
 (0)