update proxy management
This commit is contained in:
1 parent
d34e578868
commit
f22d21bb53
10 files changed
+209
-10
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { IApi } from '../api';
|
||||
import { IProxy } from '../proxy';
|
||||
|
||||
export enum IApplicationType {
|
||||
API = 'Api',
|
||||
@@ -23,6 +24,7 @@ export interface ICredential {
|
||||
export interface IApplication {
|
||||
id?: string;
|
||||
api?: IApi;
|
||||
proxy?: IProxy;
|
||||
type?: IApplicationType;
|
||||
api_id?: string;
|
||||
proxy_id?: string;
|
||||
|
||||
@@ -5,3 +5,4 @@ export * from './user';
|
||||
export * from './api';
|
||||
export * from './document';
|
||||
export * from './order';
|
||||
export * from './proxy';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -0,0 +1,28 @@
|
||||
import { IDocument } from '../document';
|
||||
import { IService } from '../service';
|
||||
|
||||
export interface IProxy {
|
||||
id: string;
|
||||
path: string;
|
||||
endpoint: string;
|
||||
price?: number;
|
||||
title?: string;
|
||||
introduction?: string;
|
||||
apply_count?: number;
|
||||
free_count?: number;
|
||||
applied?: boolean;
|
||||
tags?: string[];
|
||||
document?: IDocument;
|
||||
document_id?: string;
|
||||
service?: IService;
|
||||
service_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IProxyListResponse {
|
||||
count: number;
|
||||
items: IProxy[];
|
||||
}
|
||||
|
||||
export type IProxyDetailResponse = IProxy;
|
||||
@@ -0,0 +1,40 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IProxy, IProxyDetailResponse, IProxyListResponse } from '../proxy/models';
|
||||
|
||||
export interface IProxyQuery {
|
||||
limit: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
class ProxyOperator {
|
||||
key = 'proxies';
|
||||
|
||||
async getAll(query: IProxyQuery): Promise<AxiosResponse<IProxyListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IProxyDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IProxy): Promise<AxiosResponse<IProxyDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IProxy): Promise<AxiosResponse<IProxyDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async getAllForService(serviceId: string): Promise<AxiosResponse<IProxyListResponse>> {
|
||||
return await httpClient.get(`/services/${serviceId}/${this.key}/`);
|
||||
}
|
||||
}
|
||||
|
||||
export const proxyOperator = new ProxyOperator();
|
||||
Reference in new issue
Block a user