Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
39
CMyTapper/robucks-front/api/shop-item.api.ts
Normal file
39
CMyTapper/robucks-front/api/shop-item.api.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { HttpInstanceFactory } from '@/utils/HttpInstanceFactory';
|
||||
|
||||
export interface IShopItem {
|
||||
id: number;
|
||||
attributes: {
|
||||
isDecimal: boolean;
|
||||
name: string;
|
||||
price: number;
|
||||
icon: {
|
||||
data: {
|
||||
id: number;
|
||||
attributes: {
|
||||
url: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export class ShopItemApi {
|
||||
private static instance: ShopItemApi | null = null;
|
||||
private httpInstance: AxiosInstance;
|
||||
|
||||
private constructor(token?: string) {
|
||||
this.httpInstance = HttpInstanceFactory.getAuthorizedInstance(token);
|
||||
}
|
||||
|
||||
public static getInstance(token?: string): ShopItemApi {
|
||||
if (this.instance) return this.instance;
|
||||
this.instance = new ShopItemApi(token);
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
async getAllShopItems(): Promise<IShopItem[]> {
|
||||
return (await this.httpInstance.get<{ data: IShopItem[] }>(`/shop-items?populate=*`)).data
|
||||
.data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user