export type PluId = {list_code: string, code: string}; export type ProductIdentification = {product_id?: string | undefined, plu_ids?: Array | undefined}; export type ThirdPartyRecommendation = {third_party_recommendation_id?: string | undefined, customer_id?: string | undefined, products: Array, recommended_product: ProductIdentification, recommendation_system_id: string, recommendation_system_dataset_id: string, score: number, state?: (0 | 1 | 2) | undefined, last_change?: string | undefined}; export type ErrorProcessing = 1 | 2; export type CreateApiThirdPartyRecommendationsBatchArgs = {'Accept-Language'?: string | undefined, body: {third_party_recommendations: Array, error_processing?: ErrorProcessing | undefined}}; export type CreateApiThirdPartyRecommendationsBatchOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a batch of the third party recommendations * * POST /third-party-recommendations/batch * * Also accepts auth: basicAuth */ export const createApiThirdPartyRecommendationsBatch = async (args: CreateApiThirdPartyRecommendationsBatchArgs, options?: CreateApiThirdPartyRecommendationsBatchOptions) => { const {baseUrl = "https://sandbox.crmcarecloud.com/webservice/rest-api/enterprise-interface/v1.0", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/third-party-recommendations/batch${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 };