diff --git a/src/axios.ts b/src/axios.ts index dd442cb..1e00a5e 100644 --- a/src/axios.ts +++ b/src/axios.ts @@ -73,7 +73,7 @@ export interface MultinetAxiosInstance extends AxiosInstance { updateSession(workspace: string, sessionId: number, type: 'network' | 'table', state: object): AxiosPromise; renameSession(workspace: string, sessionId: number, type: 'network' | 'table', name: string): AxiosPromise; getSession(workspace: string, sessionId: number, type: 'network' | 'table'): AxiosPromise; - generateAltText(level: number, structured: boolean, data: object, title?: string): AxiosPromise; + generateAltText(structured: boolean, data: object, title?: string, level?: number): AxiosPromise; networkBuildRequests(workspace: string): AxiosPromise; } @@ -270,7 +270,7 @@ export function multinetAxiosInstance(config: AxiosRequestConfig): MultinetAxios return this.get(`workspaces/${workspace}/sessions/${type}/${sessionId}/`); }; - Proto.generateAltText = function(level: number, structured: boolean, data: object, title?: string): AxiosPromise { + Proto.generateAltText = function(structured: boolean, data: object, title?: string, level?: number): AxiosPromise { const jsonString = JSON.stringify(data); const blob = new Blob([jsonString], { type: 'application/json' }); const file = new File([blob], 'data.json'); @@ -278,11 +278,13 @@ export function multinetAxiosInstance(config: AxiosRequestConfig): MultinetAxios const formData = new FormData(); formData.append('structured', structured.toString()); - formData.append('level', level.toString()); formData.append('data', file); if (title) { formData.append('title', title); } + if (level) { + formData.append('level', level.toString()); + } return this.post(`alttxt/`, formData); }; diff --git a/src/index.ts b/src/index.ts index 0a36394..c5b5ed4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -285,8 +285,8 @@ class MultinetAPI { return (await this.axios.getSession(workspace, sessionId, type)).data; } - public async generateAltText(level: number, structured: boolean, data: object, title?: string): Promise { - return (await this.axios.generateAltText(level, structured, data, title)).data; + public async generateAltText(structured: boolean, data: object, title?: string, level?: number): Promise { + return (await this.axios.generateAltText(structured, data, title, level)).data; } public async networkBuildRequests(workspace: string): Promise {