import { httpGetInterceptor } from "../http-config/http-interceptor-service";
import { httpGet, httpPost } from "../http-config/nulisAIApi";

export async function generateDataArticle(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/save-article", headers, data);
}

export async function getGenerateTitle(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/generate-title", headers, data);
}

export async function getGenerateKeywords(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/generate-keywords", headers, data);
}

export async function getDetailArticle(id: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpGet(`ai-writer/article/findArticleById/${id}`, headers);
}

export async function getSeoScore(id: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpGet(`ai-writer/article/checkSEOScore/${id}`, headers);
}

export async function updateManualArticle(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/update-article", headers, data);
}

export async function getGenerateTopicKeywords(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/generate-topic-keywords", headers, data);
}

export async function saveBulkArticle(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/save-bulk-article", headers, data);
}

export async function getGenerateRewriter(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/create-rewriter", headers, data);
}

export async function generateSpeechToText(data: any) {
  const headers = {
    "content-type": "multipart/form-data",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/speech-to-text", headers, data);
}

export async function generateDataBulkArticle(data: any) {
  const headers = {
    "content-type": "application/json",
    Authorization:
      "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==",
  };
  return await httpPost("ai-writer/save-bulk-article", headers, data);
}

export async function listNulisAI(page: any, limit: any) {
  const url = `media/nulis-ai/pagination?enablePage=1&page=${page}&size=${limit}`;
  return httpGetInterceptor(url);
}

export async function detailMediaNulis(id: any) {
  const url = `media/nulis-ai?id=${id}`;
  return httpGetInterceptor({ url });
}


