UNPKG

contentful-management

Version:
35 lines (32 loc) 1.2 kB
import copy from 'fast-copy'; import { toPlainObject, freezeSys } from 'contentful-sdk-core'; import enhanceWithMethods from '../enhance-with-methods.js'; import { wrapCollection } from '../common-utils.js'; /** * @internal * @param makeRequest - function to make requests via an adapter * @param data - Raw access token data * @returns Wrapped access token */ function wrapAccessToken(makeRequest, data) { const AccessToken = toPlainObject(copy(data)); const accessTokenWithMethods = enhanceWithMethods(AccessToken, { revoke: function () { return makeRequest({ entityType: 'AccessToken', action: 'revoke', params: { tokenId: data.sys.id }, }).then((data) => wrapAccessToken(makeRequest, data)); }, }); return freezeSys(accessTokenWithMethods); } /** * @internal * @param makeRequest - function to make requests via an adapter * @param data - Raw access collection data * @returns Wrapped access token collection data */ const wrapAccessTokenCollection = wrapCollection(wrapAccessToken); export { wrapAccessToken, wrapAccessTokenCollection }; //# sourceMappingURL=access-token.js.map