import {
  LoadArticleDetailResponse,
  LoadArticleResponse,
  LoadCategoryResponse,
} from "../services/article/types";
import { BaseApi } from "./baseApi";

class ArticleApi extends BaseApi {
  constructor() {
    super("/article");
  }

  async LoadCategory({ pageNumber, pageSize, parentId }) {
    return this.authPost<LoadCategoryResponse>("/category", {
      pageNumber,
      pageSize,
      parentId,
    });
  }

  async LoadArticle({ pageNumber, pageSize, categoryId, isFeatured }) {
    return this.authPost<LoadArticleResponse>("/load", {
      pageNumber,
      pageSize,
      categoryId,
      isFeatured,
    });
  }

  async LoadArticleDetail({ articleId }) {
    return this.authPost<LoadArticleDetailResponse>("/detail", {
      id: articleId,
    });
  }
}

export const articleApi = new ArticleApi();
