UNPKG

contentful-management

Version:
43 lines (40 loc) 1.68 kB
import { del as del$1, get as get$1, put } from './raw.mjs'; import { normalizeSelect, normalizeSpaceId } from './utils.mjs'; import copy from 'fast-copy'; const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/app_installations`; const getBaseUrlForOrgInstallations = (params) => `/app_definitions/${params.appDefinitionId}/app_installations`; const getAppInstallationUrl = (params) => getBaseUrl(params) + `/${params.appDefinitionId}`; const get = (http, params) => { return get$1(http, getAppInstallationUrl(params), { params: normalizeSelect(params.query), }); }; const getMany = (http, params) => { return get$1(http, getBaseUrl(params), { params: normalizeSelect(params.query), }); }; const upsert = (http, params, rawData, headers) => { const data = copy(rawData); return put(http, getAppInstallationUrl(params), data, { headers: { ...headers, ...(params.acceptAllTerms && { 'X-Contentful-Marketplace': 'i-accept-end-user-license-agreement,i-accept-marketplace-terms-of-service,i-accept-privacy-policy', }), }, }); }; const del = (http, params) => { return del$1(http, getAppInstallationUrl(params)); }; const getForOrganization = (http, params) => { return get$1(http, getBaseUrlForOrgInstallations(params), { params: { ...normalizeSpaceId(normalizeSelect(params.query)), 'sys.organization.sys.id[in]': params.organizationId, }, }); }; export { del, get, getAppInstallationUrl, getForOrganization, getMany, upsert }; //# sourceMappingURL=app-installation.mjs.map