2021-06-29 11:14:36 +02:00
|
|
|
import apiClient from './clients/api-client';
|
|
|
|
import { UserPack, UserPackIndexFilter } from '../models/user-pack';
|
|
|
|
import { AxiosResponse } from 'axios';
|
|
|
|
|
|
|
|
export default class UserPackAPI {
|
2021-07-01 12:04:48 +02:00
|
|
|
static async index (filters: UserPackIndexFilter): Promise<Array<UserPack>> {
|
2021-06-29 11:14:36 +02:00
|
|
|
const res: AxiosResponse<Array<UserPack>> = await apiClient.get(`/api/user_packs${this.filtersToQuery(filters)}`);
|
|
|
|
return res?.data;
|
|
|
|
}
|
|
|
|
|
2021-07-01 12:04:48 +02:00
|
|
|
private static filtersToQuery (filters?: UserPackIndexFilter): string {
|
2021-06-29 11:14:36 +02:00
|
|
|
if (!filters) return '';
|
|
|
|
|
|
|
|
return '?' + Object.entries(filters).map(f => `${f[0]}=${f[1]}`).join('&');
|
|
|
|
}
|
|
|
|
}
|