UNPKG

@datocms/cma-client

Version:
149 lines 6.07 kB
var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; import * as Utils from '@datocms/rest-client-utils'; import BaseResource from '../../BaseResource'; export default class WebhookCall extends BaseResource { /** * List all webhooks calls * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/instances * * @throws {ApiError} * @throws {TimeoutError} */ list(queryParams) { return this.rawList(queryParams).then((body) => Utils.deserializeResponseBody(body)); } /** * List all webhooks calls * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/instances * * @throws {ApiError} * @throws {TimeoutError} */ rawList(queryParams) { return this.client.request({ method: 'GET', url: '/webhook_calls', queryParams, }); } /** * Async iterator to auto-paginate over elements returned by list() * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/instances * * @throws {ApiError} * @throws {TimeoutError} */ listPagedIterator(queryParams, iteratorOptions) { return __asyncGenerator(this, arguments, function* listPagedIterator_1() { var _a, e_1, _b, _c; try { for (var _d = true, _e = __asyncValues(this.rawListPagedIterator(queryParams, iteratorOptions)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) { _c = _f.value; _d = false; try { const element = _c; yield yield __await(Utils.deserializeJsonEntity(element)); } finally { _d = true; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e)); } finally { if (e_1) throw e_1.error; } } }); } /** * Async iterator to auto-paginate over elements returned by rawList() * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/instances * * @throws {ApiError} * @throws {TimeoutError} */ rawListPagedIterator(queryParams, iteratorOptions) { Utils.warnOnPageQueryParam(queryParams); return Utils.rawPageIterator({ defaultLimit: 30, maxLimit: 500, }, (page) => this.rawList(Object.assign(Object.assign({}, queryParams), { page })), iteratorOptions); } /** * Retrieve a webhook call * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/self * * @throws {ApiError} * @throws {TimeoutError} */ find(webhookCallId) { return this.rawFind(Utils.toId(webhookCallId)).then((body) => Utils.deserializeResponseBody(body)); } /** * Retrieve a webhook call * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/self * * @throws {ApiError} * @throws {TimeoutError} */ rawFind(webhookCallId) { return this.client.request({ method: 'GET', url: `/webhook_calls/${webhookCallId}`, }); } /** * Re-send the webhook call * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/resend_webhook * * @throws {ApiError} * @throws {TimeoutError} */ resendWebhook(webhookCallId) { return this.rawResendWebhook(Utils.toId(webhookCallId)); } /** * Re-send the webhook call * * Read more: https://www.datocms.com/docs/content-management-api/resources/webhook-call/resend_webhook * * @throws {ApiError} * @throws {TimeoutError} */ rawResendWebhook(webhookCallId) { return this.client.request({ method: 'POST', url: `/webhook_calls/${webhookCallId}/resend_webhook`, }); } } WebhookCall.TYPE = 'webhook_call'; //# sourceMappingURL=WebhookCall.js.map