UNPKG

contentful-management

Version:
31 lines (28 loc) 1.22 kB
import copy from 'fast-copy'; import { toPlainObject, freezeSys } from 'contentful-sdk-core'; import enhanceWithMethods from '../enhance-with-methods.js'; import createOrganizationApi from '../create-organization-api.js'; import { wrapCollection } from '../common-utils.js'; /** * This method creates the API for the given organization with all the methods for * reading and creating other entities. It also passes down a clone of the * http client with an organization id, so the base path for requests now has the * organization id already set. * @internal * @param makeRequest - function to make requests via an adapter * @param data - API response for an Organization * @returns {Organization} */ function wrapOrganization(makeRequest, data) { const org = toPlainObject(copy(data)); const orgApi = createOrganizationApi(makeRequest); const enhancedOrganization = enhanceWithMethods(org, orgApi); return freezeSys(enhancedOrganization); } /** * This method normalizes each organization in a collection. * @internal */ const wrapOrganizationCollection = wrapCollection(wrapOrganization); export { wrapOrganization, wrapOrganizationCollection }; //# sourceMappingURL=organization.js.map