UNPKG

contentful-management

Version:
30 lines (29 loc) 905 B
import copy from 'fast-copy'; import { toPlainObject } from 'contentful-sdk-core'; import enhanceWithMethods from '../enhance-with-methods'; function createEventSubscriptionApi(makeRequest) { const getParams = data => ({ organizationId: data.sys.organization.sys.id, appDefinitionId: data.sys.appDefinition.sys.id }); return { delete: function del() { const self = this; return makeRequest({ entityType: 'AppEventSubscription', action: 'delete', params: getParams(self) }); } }; } /** * @private * @param http - HTTP client instance * @param data - Raw AppEventSubscription data * @return Wrapped AppEventSubscription data */ export function wrapAppEventSubscription(makeRequest, data) { const eventSubscription = toPlainObject(copy(data)); return enhanceWithMethods(eventSubscription, createEventSubscriptionApi(makeRequest)); }