update distribution
This commit is contained in:
1 parent
51dc05a655
commit
0525d87711
32 files changed
+1362
-252
No files matched your search
@@ -0,0 +1,2 @@
|
||||
export * from './operator';
|
||||
export * from './models';
|
||||
@@ -0,0 +1,54 @@
|
||||
import { IOrder } from '../order';
|
||||
|
||||
export interface IDistributionHistory {
|
||||
id: string;
|
||||
user_id: string;
|
||||
invitee_id: string;
|
||||
order?: IOrder;
|
||||
order_id?: string;
|
||||
price: number;
|
||||
reward: number;
|
||||
percentage: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDistributionLevel {
|
||||
id: string;
|
||||
level: number;
|
||||
threshold: number;
|
||||
percentage: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDistributionStatus {
|
||||
id: string;
|
||||
user_id: string;
|
||||
price: number;
|
||||
reward: number;
|
||||
level_id?: string;
|
||||
level?: IDistributionLevel;
|
||||
percentage: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDistributionStatusListResponse {
|
||||
count: number;
|
||||
items: IDistributionStatus[];
|
||||
}
|
||||
|
||||
export type IDistributionStatusDetailResponse = IDistributionStatus;
|
||||
|
||||
export interface IDistributionHistoryListResponse {
|
||||
count: number;
|
||||
items: IDistributionHistory[];
|
||||
}
|
||||
|
||||
export type IDistributionHistoryDetailResponse = IDistributionHistory;
|
||||
|
||||
export interface IDistributionLevelListResponse {
|
||||
count: number;
|
||||
items: IDistributionLevel[];
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import {
|
||||
IDistributionHistoryListResponse,
|
||||
IDistributionLevelListResponse,
|
||||
IDistributionStatusDetailResponse,
|
||||
IDistributionStatusListResponse
|
||||
} from './models';
|
||||
|
||||
export interface IDistributionHistoryQuery {
|
||||
user_id?: string;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
ordering: string;
|
||||
}
|
||||
|
||||
class DistributionHistoryService {
|
||||
key = 'distribution-histories';
|
||||
|
||||
async getAll(query: IDistributionHistoryQuery): Promise<AxiosResponse<IDistributionHistoryListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const distributionHistoryOperator = new DistributionHistoryService();
|
||||
|
||||
export interface IDistributionStatusQuery {
|
||||
user_id?: string;
|
||||
}
|
||||
|
||||
class DistributionStatusService {
|
||||
key = 'distribution-statuses';
|
||||
|
||||
async getAll(query: IDistributionStatusQuery): Promise<AxiosResponse<IDistributionStatusListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async initialize(): Promise<AxiosResponse<IDistributionStatusDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/initialize/`);
|
||||
}
|
||||
}
|
||||
|
||||
export const distributionStatusOperator = new DistributionStatusService();
|
||||
|
||||
class DistributionLevelService {
|
||||
key = 'distribution-levels';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IDistributionLevelListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
}
|
||||
|
||||
export const distributionLevelOperator = new DistributionLevelService();
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface IUser {
|
||||
id?: string;
|
||||
id: string;
|
||||
username?: string;
|
||||
first_name?: string;
|
||||
last_name?: string;
|
||||
@@ -12,4 +12,9 @@ export interface IUser {
|
||||
avatar?: string;
|
||||
}
|
||||
|
||||
export interface IUserListResponse {
|
||||
count: number;
|
||||
items: IUser[];
|
||||
}
|
||||
|
||||
export interface IUserDetailResponse extends IUser {}
|
||||
@@ -1,12 +1,23 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IUserDetailResponse, IUser } from './models';
|
||||
import { IUserDetailResponse, IUser, IUserListResponse } from './models';
|
||||
|
||||
export interface IInviteesQuery {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
class UserOperator {
|
||||
async getMe(): Promise<AxiosResponse<IUserDetailResponse>> {
|
||||
return httpClient.get('/me');
|
||||
}
|
||||
|
||||
async getInvitees(query: IInviteesQuery): Promise<AxiosResponse<IUserListResponse>> {
|
||||
return httpClient.get('/me/invitees', {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async updateMe(data: IUser): Promise<AxiosResponse<IUserDetailResponse>> {
|
||||
return httpClient.put('/me', data);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user