feat: create api service PAI
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import type { ApiService } from "@/types";
|
||||
import type { ApiService, ApiServiceCredentials } from "@/types";
|
||||
import { axios, handleApiError } from "..";
|
||||
|
||||
export interface FetchApiServicesResponse {
|
||||
@ -16,3 +16,31 @@ export const getApiServices = async (): Promise<FetchApiServicesResponse> => {
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export interface CreateApiServiceRequest {
|
||||
name: string;
|
||||
description: string;
|
||||
redirect_uris: string[];
|
||||
scopes: string[];
|
||||
grant_types: string[];
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
export interface CreateApiServiceResponse {
|
||||
service: ApiService;
|
||||
credentials: ApiServiceCredentials;
|
||||
}
|
||||
|
||||
export const postApiService = async (
|
||||
req: CreateApiServiceRequest,
|
||||
): Promise<CreateApiServiceResponse> => {
|
||||
const response = await axios.post<CreateApiServiceResponse>(
|
||||
"/api/v1/admin/api-services",
|
||||
req,
|
||||
);
|
||||
|
||||
if (response.status !== 200 && response.status !== 201)
|
||||
throw await handleApiError(response);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
Reference in New Issue
Block a user