Skip to content

Commit 963bd9d

Browse files
docs: update examples
1 parent cdb0d9f commit 963bd9d

4 files changed

Lines changed: 30 additions & 15 deletions

File tree

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ const client = new Grid({
2626
apiKey: process.env['GRID_API_TOKEN'], // This is the default and can be omitted
2727
});
2828

29-
const response = await client.workbooks.query('YOUR_WORKBOOK_ID', {
30-
read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'],
31-
});
29+
const response = await client.workbooks.query('YOUR_WORKBOOK_ID', { read: ['A1:A4'] });
3230

3331
console.log(response.read);
3432
```
@@ -45,7 +43,7 @@ const client = new Grid({
4543
apiKey: process.env['GRID_API_TOKEN'], // This is the default and can be omitted
4644
});
4745

48-
const params: Grid.WorkbookQueryParams = { read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] };
46+
const params: Grid.WorkbookQueryParams = { read: ['A1:A4'] };
4947
const response: Grid.WorkbookQueryResponse = await client.workbooks.query(
5048
'YOUR_WORKBOOK_ID',
5149
params,
@@ -92,7 +90,7 @@ a subclass of `APIError` will be thrown:
9290
<!-- prettier-ignore -->
9391
```ts
9492
const response = await client.workbooks
95-
.query('YOUR_WORKBOOK_ID', { read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] })
93+
.query('YOUR_WORKBOOK_ID', { read: ['A1:A4'] })
9694
.catch(async (err) => {
9795
if (err instanceof Grid.APIError) {
9896
console.log(err.status); // 400
@@ -133,7 +131,7 @@ const client = new Grid({
133131
});
134132

135133
// Or, configure per-request:
136-
await client.workbooks.query('YOUR_WORKBOOK_ID', { read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] }, {
134+
await client.workbooks.query('YOUR_WORKBOOK_ID', { read: ['A1:A4'] }, {
137135
maxRetries: 5,
138136
});
139137
```
@@ -150,7 +148,7 @@ const client = new Grid({
150148
});
151149

152150
// Override per-request:
153-
await client.workbooks.query('YOUR_WORKBOOK_ID', { read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] }, {
151+
await client.workbooks.query('YOUR_WORKBOOK_ID', { read: ['A1:A4'] }, {
154152
timeout: 5 * 1000,
155153
});
156154
```
@@ -203,7 +201,7 @@ const client = new Grid();
203201

204202
const response = await client.workbooks.query(
205203
'YOUR_WORKBOOK_ID',
206-
{ read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] },
204+
{ read: ['A1:A4'] },
207205
{ headers: { 'X-Client-Name': 'My-Custom-Value' } },
208206
);
209207
```
@@ -222,14 +220,12 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
222220
```ts
223221
const client = new Grid();
224222

225-
const response = await client.workbooks
226-
.query('YOUR_WORKBOOK_ID', { read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] })
227-
.asResponse();
223+
const response = await client.workbooks.query('YOUR_WORKBOOK_ID', { read: ['A1:A4'] }).asResponse();
228224
console.log(response.headers.get('X-My-Header'));
229225
console.log(response.statusText); // access the underlying Response object
230226

231227
const { data: response, response: raw } = await client.workbooks
232-
.query('YOUR_WORKBOOK_ID', { read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] })
228+
.query('YOUR_WORKBOOK_ID', { read: ['A1:A4'] })
233229
.withResponse();
234230
console.log(raw.headers.get('X-My-Header'));
235231
console.log(response.read);

src/resources/beta.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,39 @@ import { path } from '../internal/utils/path';
1111
export class Beta extends APIResource {
1212
/**
1313
* Retrieve labels automatically detected for cells and ranges in the workbook.
14+
*
15+
* @example
16+
* ```ts
17+
* const response = await client.beta.getWorkbookLabels('id');
18+
* ```
1419
*/
1520
getWorkbookLabels(id: string, options?: RequestOptions): APIPromise<BetaGetWorkbookLabelsResponse> {
1621
return this._client.get(path`/v1/workbooks/${id}/labels`, options);
1722
}
1823

1924
/**
2025
* Retrieve labels automatically detected for cells and ranges in the workbook.
26+
*
27+
* @example
28+
* ```ts
29+
* const response = await client.beta.getWorkbookParameters(
30+
* 'id',
31+
* );
32+
* ```
2133
*/
2234
getWorkbookParameters(id: string, options?: RequestOptions): APIPromise<BetaGetWorkbookParametersResponse> {
2335
return this._client.get(path`/v1/workbooks/${id}/parameters`, options);
2436
}
2537

2638
/**
2739
* Search data labels across all spreadsheets uploaded to an account
40+
*
41+
* @example
42+
* ```ts
43+
* const response = await client.beta.searchLabels({
44+
* query: 'profit',
45+
* });
46+
* ```
2847
*/
2948
searchLabels(body: BetaSearchLabelsParams, options?: RequestOptions): APIPromise<BetaSearchLabelsResponse> {
3049
return this._client.post('/v1/workbooks/search/labels', { body, ...options });

src/resources/workbooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class Workbooks extends APIResource {
8383
* @example
8484
* ```ts
8585
* const response = await client.workbooks.query('id', {
86-
* read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'],
86+
* read: ['A1:A4'],
8787
* });
8888
* ```
8989
*/

tests/api-resources/workbooks.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('resource workbooks', () => {
5555

5656
// Mock server tests are disabled
5757
test.skip('query: only required params', async () => {
58-
const responsePromise = client.workbooks.query('id', { read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'] });
58+
const responsePromise = client.workbooks.query('id', { read: ['A1:A4'] });
5959
const rawResponse = await responsePromise.asResponse();
6060
expect(rawResponse).toBeInstanceOf(Response);
6161
const response = await responsePromise;
@@ -68,7 +68,7 @@ describe('resource workbooks', () => {
6868
// Mock server tests are disabled
6969
test.skip('query: required and optional params', async () => {
7070
const response = await client.workbooks.query('id', {
71-
read: ['A1', 'Sheet2!B3', '=SUM(A1:A4)'],
71+
read: ['A1:A4'],
7272
apply: [{ target: 'A2', value: 1234 }],
7373
goalSeek: {
7474
controlCell: 'Sheet1!A1:B2',

0 commit comments

Comments
 (0)