contentful-management
Version:
Client for Contentful's Content Management API
86 lines (83 loc) • 3.66 kB
JavaScript
import copy from 'fast-copy';
import { post, put, del as del$1, get as get$1 } from './raw.js';
import { normalizeSelect } from './utils.js';
const getBaseUrl = (params) => `/spaces/${params.spaceId}/webhook_definitions`;
const getWebhookCallBaseUrl = (params) => `/spaces/${params.spaceId}/webhooks`;
const getWebhookUrl = (params) => `${getBaseUrl(params)}/${params.webhookDefinitionId}`;
const getWebhookCallUrl = (params) => `${getWebhookCallBaseUrl(params)}/${params.webhookDefinitionId}/calls`;
const getWebhookCallDetailsUrl = (params) => `${getWebhookCallBaseUrl(params)}/${params.webhookDefinitionId}/calls/${params.callId}`;
const getWebhookHealthUrl = (params) => `${getWebhookCallBaseUrl(params)}/${params.webhookDefinitionId}/health`;
const getWebhookSettingsUrl = (params) => `/spaces/${params.spaceId}/webhook_settings`;
const getWebhookSigningSecretUrl = (params) => `${getWebhookSettingsUrl(params)}/signing_secret`;
const getWebhookRetryPolicyUrl = (params) => `${getWebhookSettingsUrl(params)}/retry_policy`;
const get = (http, params) => {
return get$1(http, getWebhookUrl(params));
};
const getManyCallDetails = (http, params) => {
return get$1(http, getWebhookCallUrl(params), {
params: normalizeSelect(params.query),
});
};
const getCallDetails = (http, params) => {
return get$1(http, getWebhookCallDetailsUrl(params));
};
const getHealthStatus = (http, params) => {
return get$1(http, getWebhookHealthUrl(params));
};
const getMany = (http, params) => {
return get$1(http, getBaseUrl(params), {
params: normalizeSelect(params.query),
});
};
const getSigningSecret = (http, params) => {
return get$1(http, getWebhookSigningSecretUrl(params));
};
/**
* @deprecated The EAP for this feature has ended. This method will be removed in the next major version.
*/
const getRetryPolicy = (http, params) => {
return get$1(http, getWebhookRetryPolicyUrl(params));
};
const create = (http, params, rawData, headers) => {
const data = copy(rawData);
return post(http, getBaseUrl(params), data, { headers });
};
const createWithId = (http, params, rawData, headers) => {
const data = copy(rawData);
return put(http, getWebhookUrl(params), data, { headers });
};
const update = async (http, params, rawData, headers) => {
const data = copy(rawData);
delete data.sys;
return put(http, getWebhookUrl(params), data, {
headers: {
'X-Contentful-Version': rawData.sys.version ?? 0,
...headers,
},
});
};
const upsertSigningSecret = async (http, params, rawData) => {
const data = copy(rawData);
return put(http, getWebhookSigningSecretUrl(params), data);
};
/**
* @deprecated The EAP for this feature has ended. This method will be removed in the next major version.
*/
const upsertRetryPolicy = async (http, params, rawData) => {
const data = copy(rawData);
return put(http, getWebhookRetryPolicyUrl(params), data);
};
const del = (http, params) => {
return del$1(http, getWebhookUrl(params));
};
const deleteSigningSecret = async (http, params) => {
return del$1(http, getWebhookSigningSecretUrl(params));
};
/**
* @deprecated The EAP for this feature has ended. This method will be removed in the next major version.
*/
const deleteRetryPolicy = async (http, params) => {
return del$1(http, getWebhookRetryPolicyUrl(params));
};
export { create, createWithId, del, deleteRetryPolicy, deleteSigningSecret, get, getCallDetails, getHealthStatus, getMany, getManyCallDetails, getRetryPolicy, getSigningSecret, update, upsertRetryPolicy, upsertSigningSecret };
//# sourceMappingURL=webhook.js.map