@@ -7,6 +7,18 @@ import { RequestOptions } from '../internal/request-options';
77import { path } from '../internal/utils/path' ;
88
99export class Workbooks extends APIResource {
10+ /**
11+ * List the workbooks linked to an account.
12+ *
13+ * This endpoint returns a paginated list of workbooks.
14+ */
15+ list (
16+ query : WorkbookListParams | null | undefined = { } ,
17+ options ?: RequestOptions ,
18+ ) : APIPromise < WorkbookListResponse > {
19+ return this . _client . get ( '/v1/workbooks' , { query, ...options } ) ;
20+ }
21+
1022 /**
1123 * Export a workbook as an .xlsx file. Cells can be updated before the workbook is
1224 * exported.
@@ -44,6 +56,88 @@ export class Workbooks extends APIResource {
4456 __binaryResponse : true ,
4557 } ) ;
4658 }
59+
60+ /**
61+ * Upload an Excel workbook file and make it available in the API.
62+ *
63+ * The workbook will be processed in the background. Once it's processed
64+ * successfully it will be available for querying and exporting.
65+ */
66+ upload ( params : WorkbookUploadParams , options ?: RequestOptions ) : APIPromise < WorkbookUploadResponse > {
67+ const { body, 'X-Uploaded-Filename' : xUploadedFilename } = params ;
68+ return this . _client . post ( '/v1/workbooks' , {
69+ body : body ,
70+ ...options ,
71+ headers : buildHeaders ( [
72+ { 'Content-Type' : 'application/octet-stream' , 'X-Uploaded-Filename' : xUploadedFilename } ,
73+ options ?. headers ,
74+ ] ) ,
75+ } ) ;
76+ }
77+ }
78+
79+ export interface WorkbookListResponse {
80+ items : Array < WorkbookListResponse . Item > ;
81+
82+ pagination : WorkbookListResponse . Pagination ;
83+ }
84+
85+ export namespace WorkbookListResponse {
86+ export interface Item {
87+ /**
88+ * A workbook's unique identifier
89+ */
90+ id : string ;
91+
92+ /**
93+ * The date/time the workbook was created
94+ */
95+ created : string ;
96+
97+ /**
98+ * The defect that was found in the most recent version of the workbook, if any
99+ */
100+ defect :
101+ | ''
102+ | 'too_big'
103+ | 'converted_workbook_too_big'
104+ | 'unrecognized_format'
105+ | 'cannot_fetch_from_remote'
106+ | 'processing_timeout'
107+ | 'conversion_error' ;
108+
109+ /**
110+ * The original filename of the uploaded workbook
111+ */
112+ filename : string ;
113+
114+ /**
115+ * The date/time the workbook was last modified
116+ */
117+ modified : string ;
118+
119+ /**
120+ * The current state of the most recent version of the workbook
121+ */
122+ state : 'processing' | 'ready' | 'error' ;
123+
124+ /**
125+ * The most recent version of the workbook
126+ */
127+ version : number ;
128+
129+ /**
130+ * The latest version of the workbook that has a 'ready' state
131+ */
132+ latest_ready_version ?: number | null ;
133+ }
134+
135+ export interface Pagination {
136+ /**
137+ * The cursor to pass on as query parameter for the next batch of items, if any
138+ */
139+ next_cursor ?: string | null ;
140+ }
47141}
48142
49143/**
@@ -393,6 +487,26 @@ export namespace WorkbookQueryResponse {
393487 }
394488}
395489
490+ export interface WorkbookUploadResponse {
491+ /**
492+ * The id of the newly uploaded workbook
493+ */
494+ id : string ;
495+ }
496+
497+ export interface WorkbookListParams {
498+ /**
499+ * Cursor for the next page of items. If not provided, the first batch of items
500+ * will be returned.
501+ */
502+ cursor ?: string ;
503+
504+ /**
505+ * Number of items to return per page
506+ */
507+ limit ?: number ;
508+ }
509+
396510export interface WorkbookExportParams {
397511 /**
398512 * Cells to update before exporting
@@ -611,11 +725,27 @@ export namespace WorkbookRenderChartParams {
611725 }
612726}
613727
728+ export interface WorkbookUploadParams {
729+ /**
730+ * Body param:
731+ */
732+ body : string | ArrayBuffer | ArrayBufferView | Blob | DataView ;
733+
734+ /**
735+ * Header param: The name of the workbook file
736+ */
737+ 'X-Uploaded-Filename' : string ;
738+ }
739+
614740export declare namespace Workbooks {
615741 export {
742+ type WorkbookListResponse as WorkbookListResponse ,
616743 type WorkbookQueryResponse as WorkbookQueryResponse ,
744+ type WorkbookUploadResponse as WorkbookUploadResponse ,
745+ type WorkbookListParams as WorkbookListParams ,
617746 type WorkbookExportParams as WorkbookExportParams ,
618747 type WorkbookQueryParams as WorkbookQueryParams ,
619748 type WorkbookRenderChartParams as WorkbookRenderChartParams ,
749+ type WorkbookUploadParams as WorkbookUploadParams ,
620750 } ;
621751}
0 commit comments