From df93816848fec1beb64a6b3f518298fa2d002eb1 Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Fri, 10 Nov 2023 13:32:29 -0700 Subject: [PATCH] Update generateAltText to set level as optional parameter --- src/axios.ts | 8 +++++--- src/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/axios.ts b/src/axios.ts index 87833fe..165eade 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(verbosity: string, level: number, explain: string, data: object, title?: string): AxiosPromise; + generateAltText(verbosity: string, explain: string, 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(verbosity: string, level: number, explain: string, data: object, title?: string): AxiosPromise { + Proto.generateAltText = function(verbosity: string, explain: string, 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,12 +278,14 @@ export function multinetAxiosInstance(config: AxiosRequestConfig): MultinetAxios const formData = new FormData(); formData.append('verbosity', verbosity); - formData.append('level', level.toString()); formData.append('explain', explain); 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 7c7ad87..f95021d 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(verbosity: string, level: number, explain: string, data: object, title?: string): Promise { - return (await this.axios.generateAltText(verbosity, level, explain, data, title)).data; + public async generateAltText(verbosity: string, explain: string, data: object, title?: string, level?: number): Promise { + return (await this.axios.generateAltText(verbosity, explain, data, title, level)).data; } public async networkBuildRequests(workspace: string): Promise {