import { recommendations } from "../components/c3-help-center/recommendations";
import { request } from "./api";
export const getConfig = async (accessToken, audience, orgId) => {
    return await request({
        url: `https://helpcenter.${audience}/helpcenter/config/${orgId}`,
        camundaAuth: {
            token: accessToken,
        },
    });
};
export const getTiles = async ({ accessToken, tileConfig, salesPlanType, clusterIds, persona, flags, cloudAudience, }) => {
    const availableTileTypes = recommendations(persona, flags, tileConfig, salesPlanType, clusterIds?.length > 0);
    return await request({
        url: `https://helpcenter.${cloudAudience}/cards?card_id=${availableTileTypes.join(",")}`,
        responseType: "json",
        camundaAuth: { token: accessToken },
    });
};
export const getOnboardingConfig = ({ camundaAuth, audience, orgId, }) => request({
    url: `https://helpcenter.${audience}/survey/config/${orgId}`,
    camundaAuth,
    type: "json",
});
export const updatePersona = async ({ newPersona, audience, accessToken, orgId, userId, }) => request({
    url: `https://helpcenter.${audience}/persona`,
    method: "patch",
    camundaAuth: { token: accessToken },
    type: "json",
    body: { persona: newPersona, userId, orgId },
    responseType: "text",
});
export const submitSurvey = async ({ audience, token, data, }) => request({
    method: "post",
    url: `https://helpcenter.${audience}/survey/submit`,
    camundaAuth: { token },
    type: "json",
    body: { data },
    responseType: "text",
});
export const submitFeedback = async ({ token, audience, formData, }) => request({
    method: "post",
    url: `https://helpcenter.${audience}/feedback/submit`,
    camundaAuth: { token },
    body: formData,
    type: "form",
    responseType: "text",
});
