UNPKG

contentful-management

Version:
32 lines (29 loc) 1.17 kB
import copy from 'fast-copy'; import { put, del as del$1, get as get$1 } from './raw.mjs'; const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/tags`; const getTagUrl = (params) => getBaseUrl(params) + `/${params.tagId}`; const get = (http, params) => get$1(http, getTagUrl(params)); const getMany = (http, params) => get$1(http, getBaseUrl(params), { params: params.query, }); const createWithId = (http, params, rawData) => { const data = copy(rawData); return put(http, getTagUrl(params), data, { headers: { 'X-Contentful-Tag-Visibility': rawData.sys.visibility ?? 'private' }, }); }; const update = (http, params, rawData, headers) => { const data = copy(rawData); delete data.sys; return put(http, getTagUrl(params), data, { headers: { 'X-Contentful-Version': rawData.sys.version ?? 0, ...headers, }, }); }; const del = (http, { version, ...params }) => { return del$1(http, getTagUrl(params), { headers: { 'X-Contentful-Version': version } }); }; export { createWithId, del, get, getMany, update }; //# sourceMappingURL=tag.mjs.map