Add feature support for qrart (#34)

This commit is contained in:
AceDataCloud committed 2024-04-28 13:32:02 +00:00
1 parent 091fa4d18a
commit 2fe1cb4e1d
110 files changed
+5767 -334

No files matched your search

+1
View File
@@ -11,3 +11,4 @@ export * from './chatdoc';
export * from './auth';
export * from './service';
export * from './credential';
export * from './qrart';
+83
View File
@@ -0,0 +1,83 @@
import axios, { AxiosResponse } from 'axios';
import { IQrartGenerateRequest, IQrartGenerateResponse, IQrartTaskResponse, IQrartTasksResponse } from '@/models';
import { BASE_URL_API } from '@/constants';
class QrartOperator {
async task(id: string, options: { token: string }): Promise<AxiosResponse<IQrartTaskResponse>> {
return await axios.post(
`/qrart/tasks`,
{
action: 'retrieve',
id: id
},
{
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: `Bearer ${options.token}`,
'x-record-exempt': 'true'
},
baseURL: BASE_URL_API
}
);
}
async tasks(
filter: { ids?: string[]; applicationId?: string; limit?: number; offset?: number },
options: { token: string }
): Promise<AxiosResponse<IQrartTasksResponse>> {
return await axios.post(
`/qrart/tasks`,
{
action: 'retrieve_batch',
...(filter.ids
? {
ids: filter.ids
}
: {}),
...(filter.applicationId
? {
application_id: filter.applicationId
}
: {}),
...(filter.limit !== undefined
? {
limit: filter.limit
}
: {}),
...(filter.offset !== undefined
? {
offset: filter.offset
}
: {})
},
{
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: `Bearer ${options.token}`,
'x-record-exempt': 'true'
},
baseURL: BASE_URL_API
}
);
}
async generate(
data: IQrartGenerateRequest,
options: {
token: string;
}
): Promise<AxiosResponse<IQrartGenerateResponse>> {
return await axios.post('/qrart/generate', data, {
headers: {
authorization: `Bearer ${options.token}`,
'content-type': 'application/json',
accept: 'application/x-ndjson'
},
baseURL: BASE_URL_API
});
}
}
export const qrartOperator = new QrartOperator();