added action API & interfaces
This commit is contained in:
parent
be5c516db8
commit
a33074af79
60
app/client/src/api/ActionAPI.tsx
Normal file
60
app/client/src/api/ActionAPI.tsx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import Api, { HttpMethod } from "./Api"
|
||||
import { ContainerWidgetProps } from "../widgets/ContainerWidget"
|
||||
import { ApiResponse } from "./ApiResponses"
|
||||
import { APIRequest } from './ApiRequests';
|
||||
|
||||
export interface CreateActionRequest<T> extends APIRequest {
|
||||
resourceId: string
|
||||
actionConfiguration: T
|
||||
}
|
||||
|
||||
export interface UpdateActionRequest<T> extends CreateActionRequest<T> {
|
||||
actionId: string
|
||||
}
|
||||
|
||||
export interface APIConfig {
|
||||
requestHeaders: Record<string, string>
|
||||
method: HttpMethod
|
||||
path: string
|
||||
APIName: string
|
||||
body: JSON
|
||||
queryParams: Record<string, string>
|
||||
}
|
||||
|
||||
export interface QueryConfig {
|
||||
queryString: string
|
||||
}
|
||||
|
||||
export interface PageResponse extends ApiResponse {
|
||||
pageWidget: ContainerWidgetProps<any>;
|
||||
}
|
||||
|
||||
export interface SavePageResponse {
|
||||
pageId: string;
|
||||
}
|
||||
|
||||
class ActionAPI extends Api {
|
||||
static url = "/actions"
|
||||
|
||||
static createAPI(createAPI: CreateActionRequest<APIConfig>): Promise<PageResponse> {
|
||||
return Api.post(ActionAPI.url, createAPI)
|
||||
}
|
||||
|
||||
static updateAPI(updateAPI: UpdateActionRequest<APIConfig>): Promise<PageResponse> {
|
||||
return Api.post(ActionAPI.url, updateAPI)
|
||||
}
|
||||
|
||||
static createQuery(createQuery: CreateActionRequest<QueryConfig>): Promise<PageResponse> {
|
||||
return Api.post(ActionAPI.url, createQuery)
|
||||
}
|
||||
|
||||
static updateQuery(updateQuery: UpdateActionRequest<QueryConfig>): Promise<PageResponse> {
|
||||
return Api.post(ActionAPI.url, updateQuery)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export default ActionAPI
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import { ContentType, DataType, EncodingType } from "../constants/ApiConstants";
|
||||
import { HttpMethod } from './Api';
|
||||
|
||||
export interface APIHeaders {
|
||||
Accept: ContentType
|
||||
|
|
@ -11,16 +10,3 @@ export interface APIRequest {
|
|||
|
||||
}
|
||||
|
||||
export interface CreateAPIRequest extends APIRequest {
|
||||
requestHeaders: Record<string, string>
|
||||
method: HttpMethod
|
||||
baseUrl: string
|
||||
path: string
|
||||
APIName: string
|
||||
body: JSON
|
||||
queryParams: Record<string, string>
|
||||
}
|
||||
|
||||
export interface UpdateAPIRequest extends CreateAPIRequest {
|
||||
apiId: string
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user