UNPKG

contentful-management

Version:
67 lines (64 loc) 2.44 kB
import copy from 'fast-copy'; import { toPlainObject } from 'contentful-sdk-core'; import enhanceWithMethods from '../enhance-with-methods.js'; /** * @internal */ function createAppActionCallApi(makeRequest, retryOptions) { return { createWithResponse: function (params, payload) { return makeRequest({ entityType: 'AppActionCall', action: 'createWithResponse', params: { ...params, ...retryOptions }, payload: payload, }).then((data) => wrapAppActionCallResponse(makeRequest, data)); }, getCallDetails: function getCallDetails(params) { return makeRequest({ entityType: 'AppActionCall', action: 'getCallDetails', params, }).then((data) => wrapAppActionCallResponse(makeRequest, data)); }, get: function get(params) { return makeRequest({ entityType: 'AppActionCall', action: 'get', params, }).then((data) => wrapAppActionCall(makeRequest, data)); }, createWithResult: function (params, payload) { return makeRequest({ entityType: 'AppActionCall', action: 'createWithResult', params: { ...params, ...retryOptions }, payload: payload, }).then((data) => wrapAppActionCall(makeRequest, data)); }, }; } /** * @internal * @param http - HTTP client instance * @param data - Raw AppActionCall data * @returns Wrapped AppActionCall data */ function wrapAppActionCall(makeRequest, data) { const signedRequest = toPlainObject(copy(data)); const signedRequestWithMethods = enhanceWithMethods(signedRequest, createAppActionCallApi(makeRequest)); return signedRequestWithMethods; } /** * @internal * @param http - HTTP client instance * @param data - Raw AppActionCall data * @returns Wrapped AppActionCall data */ function wrapAppActionCallResponse(makeRequest, data, retryOptions) { const appActionCallResponse = toPlainObject(copy(data)); const appActionCallResponseWithMethods = enhanceWithMethods(appActionCallResponse, createAppActionCallApi(makeRequest, retryOptions)); return appActionCallResponseWithMethods; } export { wrapAppActionCall, wrapAppActionCallResponse }; //# sourceMappingURL=app-action-call.js.map