UNPKG

contentful-management

Version:
53 lines (50 loc) 1.73 kB
import copy from 'fast-copy'; import { post, del as del$1, get as get$1, put } from './raw.js'; const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/experiences`; const getMany = (http, params, headers) => { return get$1(http, getBaseUrl(params), { params: params.query, headers, }); }; const get = (http, params, headers) => { return get$1(http, getBaseUrl(params) + `/${params.experienceId}`, { headers, }); }; const create = (http, params, rawData, headers) => { const data = copy(rawData); return post(http, getBaseUrl(params), data, { headers }); }; const upsert = (http, params, rawData, headers) => { const { sys, ...body } = copy(rawData); return put(http, getBaseUrl(params) + `/${params.experienceId}`, body, { headers: { ...(sys.version !== undefined && { 'X-Contentful-Version': sys.version, }), ...headers, }, }); }; const del = (http, params) => { return del$1(http, getBaseUrl(params) + `/${params.experienceId}`); }; const publish = (http, params, payload, headers) => { return put(http, getBaseUrl(params) + `/${params.experienceId}/published`, payload ?? null, { headers: { 'X-Contentful-Version': params.version, ...headers, }, }); }; const unpublish = (http, params, headers) => { return del$1(http, getBaseUrl(params) + `/${params.experienceId}/published`, { headers: { 'X-Contentful-Version': params.version, ...headers, }, }); }; export { create, del, get, getMany, publish, unpublish, upsert }; //# sourceMappingURL=experience.js.map