update document integration
This commit is contained in:
1 parent
c7fdcd0a4b
commit
798de13a35
14 files changed
+209
-151
No files matched your search
@@ -0,0 +1,2 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -0,0 +1,20 @@
|
||||
import { IApi } from '../api/models';
|
||||
|
||||
export interface IDocument {
|
||||
id?: string;
|
||||
name?: string;
|
||||
type: 'API' | 'TEXT';
|
||||
title?: string;
|
||||
content?: string;
|
||||
rank?: number;
|
||||
api?: IApi;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDocumentListResponse {
|
||||
count: number;
|
||||
items: IDocument[];
|
||||
}
|
||||
|
||||
export type IDocumentDetailResponse = IDocument;
|
||||
@@ -0,0 +1,36 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IDocument, IDocumentDetailResponse, IDocumentListResponse } from './models';
|
||||
|
||||
export interface IDocumentQuery {
|
||||
limit: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
class DocumentOperator {
|
||||
key = 'documents';
|
||||
|
||||
async getAll(query: IDocumentQuery): Promise<AxiosResponse<IDocumentListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IDocument): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IDocument): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const documentOperator = new DocumentOperator();
|
||||
Reference in new issue
Block a user