Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
40
CMyTapper/robucks-front/api/archive-request.api.ts
Normal file
40
CMyTapper/robucks-front/api/archive-request.api.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { HttpInstanceFactory } from '@/utils/HttpInstanceFactory';
|
||||
import { IPlayer } from '@/interfaces/player.type';
|
||||
import { IExchangeRequest } from '@/api/exchange-request.api';
|
||||
|
||||
export interface IArchiveRequest {
|
||||
id: number;
|
||||
attributes: {
|
||||
player: IPlayer;
|
||||
exchange_requests: { data: IExchangeRequest[] };
|
||||
rejected_requests: { data: IExchangeRequest[] };
|
||||
};
|
||||
}
|
||||
|
||||
export class ArchiveRequestApi {
|
||||
private static instance: ArchiveRequestApi | null = null;
|
||||
private httpInstance: AxiosInstance;
|
||||
|
||||
private constructor(token: string) {
|
||||
this.httpInstance = HttpInstanceFactory.updateAuthorizedInstance(token);
|
||||
}
|
||||
|
||||
public static getInstance(token: string): ArchiveRequestApi {
|
||||
if (this.instance) return this.instance;
|
||||
this.instance = new ArchiveRequestApi(token);
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
async createArchiveRequest(playerId: number): Promise<IArchiveRequest> {
|
||||
return (
|
||||
await this.httpInstance.post<IArchiveRequest>(`/archive-requests`, {
|
||||
data: {
|
||||
player: {
|
||||
connect: [{ id: playerId }],
|
||||
},
|
||||
},
|
||||
})
|
||||
).data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user