import { httpGet, httpPost } from "./http-config/http-base-service"; import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, httpPutInterceptor, } from "./http-config/http-interceptor-service"; export async function getPublicListPpidData(categoryId: number) { const headers = { "content-type": "application/json", }; return await httpGet(`/ppid-datas?categoryId=${categoryId}`, headers); } export async function getListCategories(size: number, page: number) { return await httpGetInterceptor( `/ppid-data-categories?page=${page}&size=${size}&isOnlyTop=true` ); } export async function updateCategoryPosition(category: any) { const pathUrl = `/ppid-data-categories/position`; return await httpPostInterceptor(pathUrl, category); } export async function getListSubCategories( size: number, page: number, parentId: number ) { const headers = { "content-type": "application/json", }; return await httpGetInterceptor( `/ppid-data-categories?page=${page}&size=${size}&parentId=${parentId}` ); } export async function getPublicListCategoriesByParentId( id: any, limit: number, levelGroup?: string ) { const headers = { "content-type": "application/json", }; return await httpGet( `/ppid-data-categories?parentId=${id}&isPpidDataIncluded=true&sort=asc&sortBy=position&limit=${limit}${ levelGroup ? `&levelGroup=${levelGroup}` : "" }`, headers ); } export async function getListCategoriesByParentId( id: any, limit: number, levelGroup?: string ) { const headers = { "content-type": "application/json", }; return await httpGetInterceptor( `/ppid-data-categories?parentId=${id}&isPpidDataIncluded=true&sort=asc&sortBy=position&limit=${limit}${ levelGroup ? `&levelGroup=${levelGroup}` : "" }` ); } export async function getListCategoriesById(id: any) { const headers = { "content-type": "application/json", }; return await httpGetInterceptor(`/ppid-data-categories/${id}`); } export async function getListCategoriesBySlug(slug: any) { const headers = { "content-type": "application/json", }; return await httpGetInterceptor(`/ppid-data-categories/slug/${slug}`); } export async function getPublicListCategoriesBySlug(slug: any) { const headers = { "content-type": "application/json", }; return await httpGet(`/ppid-data-categories/slug/${slug}`, headers); } export async function getList(categoryId: number) { const headers = { "content-type": "application/json", }; return await httpGetInterceptor(`/ppid-datas?categoryId=1`); } export async function createArticle(data: any) { const pathUrl = `/articles`; return await httpPostInterceptor(pathUrl, data); } export async function createPublicCategory(request: any) { const pathUrl = `/ppid-data-categories`; return await httpPostInterceptor(pathUrl, request); } export async function uploadPublicThumbnail(id: number, data: any) { const headers = { "Content-Type": "multipart/form-data", }; const pathUrl = `ppid-data-categories/thumbnail/${id}`; return await httpPost(pathUrl, headers, data); } export async function getPublicCategoryById(id: any) { const headers = { "content-type": "application/json", }; return await httpGetInterceptor(`/ppid-data-categories/${id}`); } export async function updatePublicCategory(id: any, request: any) { const headers = { "content-type": "application/json", }; return await httpPutInterceptor(`/ppid-data-categories/${id}`, request); } export async function deletePublicCategory(id: any) { const headers = { "content-type": "application/json", }; return await httpDeleteInterceptor(`/ppid-data-categories/${id}`); } export async function getParentCategories() { const headers = { "content-type": "application/json", }; return await httpGet(`ppid-data-categories?isOnlyTop=true`, headers); }