Skip to content

Commit 258efc0

Browse files
docs: add examples to tsdocs
1 parent a509ad2 commit 258efc0

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/resources/workbooks.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ export class Workbooks extends APIResource {
1414
* List the workbooks linked to an account.
1515
*
1616
* This endpoint returns a paginated list of workbooks.
17+
*
18+
* @example
19+
* ```ts
20+
* // Automatically fetches more pages as needed.
21+
* for await (const workbookListResponse of client.workbooks.list()) {
22+
* // ...
23+
* }
24+
* ```
1725
*/
1826
list(
1927
query: WorkbookListParams | null | undefined = {},
@@ -28,6 +36,14 @@ export class Workbooks extends APIResource {
2836
/**
2937
* Export a workbook as an .xlsx file. Cells can be updated before the workbook is
3038
* exported.
39+
*
40+
* @example
41+
* ```ts
42+
* const response = await client.workbooks.export('id');
43+
*
44+
* const content = await response.blob();
45+
* console.log(content);
46+
* ```
3147
*/
3248
export(id: string, body: WorkbookExportParams, options?: RequestOptions): APIPromise<Response> {
3349
return this._client.post(path`/v1/workbooks/${id}/export`, {
@@ -46,13 +62,30 @@ export class Workbooks extends APIResource {
4662
*
4763
* Send a JSON object with a `read` key to read values from cells and formulas.
4864
* Optionally, use the `apply` key to update cells before reading.
65+
*
66+
* @example
67+
* ```ts
68+
* const response = await client.workbooks.query('id', {
69+
* read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'],
70+
* });
71+
* ```
4972
*/
5073
query(id: string, body: WorkbookQueryParams, options?: RequestOptions): APIPromise<WorkbookQueryResponse> {
5174
return this._client.post(path`/v1/workbooks/${id}/query`, { body, ...options });
5275
}
5376

5477
/**
5578
* Render a chart using workbook data
79+
*
80+
* @example
81+
* ```ts
82+
* const response = await client.workbooks.renderChart('id', {
83+
* chart: { data: '=C2:C142' },
84+
* });
85+
*
86+
* const content = await response.blob();
87+
* console.log(content);
88+
* ```
5689
*/
5790
renderChart(id: string, body: WorkbookRenderChartParams, options?: RequestOptions): APIPromise<Response> {
5891
return this._client.post(path`/v1/workbooks/${id}/chart`, {
@@ -68,6 +101,13 @@ export class Workbooks extends APIResource {
68101
*
69102
* The workbook will be processed in the background. Once it's processed
70103
* successfully it will be available for querying and exporting.
104+
*
105+
* @example
106+
* ```ts
107+
* const response = await client.workbooks.upload({
108+
* file: fs.createReadStream('path/to/file'),
109+
* });
110+
* ```
71111
*/
72112
upload(body: WorkbookUploadParams, options?: RequestOptions): APIPromise<WorkbookUploadResponse> {
73113
return this._client.post(

0 commit comments

Comments
 (0)