add console application
This commit is contained in:
1 parent
6aebeba477
commit
7f3a50e787
21 files changed
+503
-51
No files matched your search
@@ -0,0 +1,2 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -0,0 +1,17 @@
|
||||
export interface IApplication {
|
||||
id: string;
|
||||
service: string;
|
||||
apiKey: string;
|
||||
userId: string;
|
||||
remainingCount: number;
|
||||
usedCount: number;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface IApplicationListResponse {
|
||||
count: number;
|
||||
items: IApplication[];
|
||||
}
|
||||
|
||||
export type IApplicationDetailResponse = IApplication;
|
||||
@@ -0,0 +1,36 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IApplication, IApplicationDetailResponse, IApplicationListResponse } from './models';
|
||||
import { camelizeKeys, decamelizeKeys } from 'humps';
|
||||
|
||||
export interface IApplicationQuery {
|
||||
userId: string;
|
||||
}
|
||||
|
||||
class ApplicationOperator {
|
||||
key = 'applications';
|
||||
|
||||
async getAll(query: IApplicationQuery): Promise<AxiosResponse<IApplicationListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: decamelizeKeys(query)
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IApplication): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IApplication): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const applicationOperator = new ApplicationOperator();
|
||||
Reference in new issue
Block a user