import APIHandler from "./APIHandler"; import { ARTICLE_CATEGORY_URL, ARTICLE_COMMENTS_URL, ARTICLE_DETAIL_URL, ARTICLE_RECOMMENDATIONS_URL, ARTICLE_SEARCH_URL, MENUS_URL, TRENDING_URL } from "./urls"; /** * Fetch Trending News via API * @return {Axios.get()} Get Axios Method for Trending New URL. */ export const getTrendingNews = () => APIHandler.get(TRENDING_URL) /** * Fetch Menu Data via API * @return {Axios.get} Get Axios Method for Menu URL . */ export const getMenus = () => APIHandler.get(MENUS_URL) /** * Fetch Articles By Specified Category with Pagination * @param {String} category - Category Name * @param {number} page - Page Number * @return {Axios.get} - Get Axios Method for Articles by Category */ export const getArticlesByCategory = (category,page = 1) => APIHandler.get(ARTICLE_CATEGORY_URL(category,page)) /** * Fetch Articles By Specified Category with Pagination * @param {String} category - Category Name * @param {number} page - Page Number * @param {String} filters - Additional Filters * @return {Axios.get} - Get Axios Method for Articles by Search Query */ export const getArticlesBySearch = (category,page = 1,filters="") => {console.log(ARTICLE_SEARCH_URL(category,page,filters));return APIHandler.get(ARTICLE_SEARCH_URL(category,page,filters))} /** * Fetch Article By Slug * @param {String} slug - Slug Name * @return {Axios.get} - Get Axios Method for Article by Slug */ export const getArticleBySlug = (slug) => APIHandler.get(ARTICLE_DETAIL_URL(slug)) /** * Fetch Comments by Article ID * @param {String} id - Slug Name * @return {Axios.get} - Get Axios Method for Comments by Article ID */ export const getCommentByArticleID = (id) => APIHandler.get(ARTICLE_COMMENTS_URL(id)) /** * Fetch Recommendations By Article ID * @param {String} id - Article ID * @return {Axios.get} - Get Axios Method for Recommendations By Article ID */ export const getRecommendationByArticleID = (id) => APIHandler.get(ARTICLE_RECOMMENDATIONS_URL(id)) /** * Fetch Category Data By Article ID * @param {String} id - Article ID * @return {Axios.get} - Get Axios Method for Category Data By Article ID */ export const getCategories = () => APIHandler.get(MENUS_URL)