export type CompletesGoal = number; export type QuestionID = number; export type ProfileTargetsSelectionConditionsV3 = {object: 'selection', question_id: QuestionID, option: string}; export type ProfileTargetsRangeConditionsV3 = {object: 'range', question_id: QuestionID, min: number, max: number}; export type ProfileTargetsOpenEndedConditionsV3 = {object: 'open_ended', question_id: QuestionID, allow_all_values: true, open_ended_values: Array | null} | {object: 'open_ended', question_id: QuestionID, allow_all_values: false, open_ended_values: Array}; export type InterlockProfileConditionsV3 = ProfileTargetsSelectionConditionsV3 | ProfileTargetsRangeConditionsV3 | ProfileTargetsOpenEndedConditionsV3; export type RequestDraftQuotaNominalV3 = {conditions: Array, quota: {name?: string | undefined, completes_goal: number}}; export type RequestDraftQuotaPercentageV3 = {conditions: Array, quota: {name?: string | undefined, completes_goal_percentage: number}}; export type RequestDraftNoQuotaV3 = {object?: 'nominal' | undefined, conditions: Array, quota?: (Record | null) | undefined}; export type RequestDraftQuotaV3 = Array | Array | Array; export type RequestDraftRegularProfileV3 = {object: 'regular', name?: string | undefined, quotas_enabled: boolean, targets: RequestDraftQuotaV3} | {object: 'blended', blended_type?: ('interlock' | 'control') | undefined, name: string, quotas_enabled: boolean, targets: RequestDraftQuotaV3}; export type ValidateProfilesRequestV3 = {locale: string, completes_goal: CompletesGoal, profiling: {profile_adjustment_type: 'percentage' | 'nominal', profiles: Array}}; export type CreateApiDemandAccountsAccountIdProfilesValidateArgs = {body: ValidateProfilesRequestV3}; export type CreateApiDemandAccountsAccountIdProfilesValidateOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Validates a profile * * POST /demand/accounts/{account_id}/profiles/validate */ export const createApiDemandAccountsAccountIdProfilesValidate = async (args: CreateApiDemandAccountsAccountIdProfilesValidateArgs, options?: CreateApiDemandAccountsAccountIdProfilesValidateOptions) => { const {baseUrl = "https://api.cint.com/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/demand/accounts/${encodeURIComponent(String(args.account_id))}/profiles/validate${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };