UnisKB/ui/src/api/application-overview.ts

77 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-12-08 08:55:29 +00:00
import { Result } from '@/request/Result'
2024-03-20 02:38:59 +00:00
import { get, post, del, put } from '@/request/index'
2023-12-08 08:55:29 +00:00
import { type Ref } from 'vue'
const prefix = '/application'
/**
* API_KEY
2024-04-15 10:46:03 +00:00
* @param application_id
2023-12-08 08:55:29 +00:00
*/
2024-04-15 10:46:03 +00:00
const getAPIKey: (application_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
application_id,
2023-12-08 08:55:29 +00:00
loading
) => {
2024-04-15 10:46:03 +00:00
return get(`${prefix}/${application_id}/api_key`, undefined, loading)
2023-12-08 08:55:29 +00:00
}
/**
* API_KEY
2024-04-15 10:46:03 +00:00
* @param application_id
2023-12-08 08:55:29 +00:00
*/
2024-04-15 10:46:03 +00:00
const postAPIKey: (application_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
application_id,
2023-12-08 08:55:29 +00:00
loading
) => {
2024-04-15 10:46:03 +00:00
return post(`${prefix}/${application_id}/api_key`, {}, undefined, loading)
2023-12-08 08:55:29 +00:00
}
/**
* API_KEY
2024-04-15 10:46:03 +00:00
* @param application_id api_key_id
2023-12-08 08:55:29 +00:00
*/
const delAPIKey: (
2024-04-15 10:46:03 +00:00
application_id: String,
2023-12-08 08:55:29 +00:00
api_key_id: String,
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<boolean>> = (application_id, api_key_id, loading) => {
return del(`${prefix}/${application_id}/api_key/${api_key_id}`, undefined, undefined, loading)
2023-12-08 08:55:29 +00:00
}
/**
* API_KEY
2024-04-15 10:46:03 +00:00
* @param application_id,api_key_id
2023-12-08 08:55:29 +00:00
* data {
* is_active: boolean
* }
*/
const putAPIKey: (
2024-04-15 10:46:03 +00:00
application_id: string,
2023-12-08 08:55:29 +00:00
api_key_id: String,
data: any,
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<any>> = (application_id, api_key_id, data, loading) => {
return put(`${prefix}/${application_id}/api_key/${api_key_id}`, data, undefined, loading)
2023-12-08 08:55:29 +00:00
}
2024-03-29 07:45:04 +00:00
/**
*
2024-04-15 10:46:03 +00:00
* @param application_id, data
2024-03-29 07:45:04 +00:00
*/
const getStatistics: (
2024-04-15 10:46:03 +00:00
application_id: string,
2024-03-29 07:45:04 +00:00
data: any,
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<any>> = (application_id, data, loading) => {
return get(`${prefix}/${application_id}/statistics/chat_record_aggregate_trend`, data, loading)
2024-03-29 07:45:04 +00:00
}
2023-12-08 08:55:29 +00:00
export default {
getAPIKey,
postAPIKey,
delAPIKey,
2024-03-29 07:45:04 +00:00
putAPIKey,
getStatistics
2023-12-08 08:55:29 +00:00
}