UNPKG

@bitrix24/b24jssdk

Version:

Bitrix24 REST API JavaScript SDK

1 lines 2.61 kB
{"version":3,"file":"call.cjs","sources":["../../../../../src/core/actions/v3/call.ts"],"sourcesContent":["import type { ActionOptions } from '../abstract-action'\nimport type { TypeCallParams } from '../../../types/http'\nimport type { AjaxResult } from '../../http/ajax-result'\nimport { AbstractAction } from '../abstract-action'\nimport { ApiVersion } from '../../../types/b24'\n\nexport type ActionCallV3 = ActionOptions & {\n method: string\n params?: TypeCallParams\n requestId?: string\n}\n\n/**\n * Calls the Bitrix24 REST API method `restApi:v3`\n *\n * @todo add docs\n */\nexport class CallV3 extends AbstractAction {\n /**\n * Calls the Bitrix24 REST API method.\n *\n * @template T - The expected data type in the response (default is `unknown`).\n *\n * @param {ActionCallV3} options - parameters for executing the request.\n * - `method: string` - REST API method name (eg: `crm.item.get`)\n * - `params?: TypeCallParams` - Parameters for calling the method.\n * - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.\n *\n * @returns {Promise<AjaxResult<T>>} A promise that resolves to the result of an REST API call.\n *\n * @example\n * interface TaskItem { id: number, title: string }\n * const response = await b24.actions.v3.call.make<{ item: TaskItem }>({\n * method: 'tasks.task.get',\n * params: { id: 123, select: ['id', 'title'] },\n * requestId: 'task-123'\n * })\n * if (!response.isSuccess) {\n * throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)\n * }\n * console.log(response.getData().result.item.title)\n */\n public override async make<T = unknown>(options: ActionCallV3): Promise<AjaxResult<T>> {\n // No client-side allowlist: the method is sent straight to the v3 endpoint\n // and the server decides (an unknown method returns METHODNOTFOUNDEXCEPTION).\n const params = options.params || {}\n return this._b24.getHttpClient(ApiVersion.v3).call<T>(options.method, params, options.requestId)\n }\n}\n"],"names":["AbstractAction","ApiVersion"],"mappings":";;;;;;;;;;;;;;;AAiBO,MAAM,eAAeA,6BAAA,CAAe;AAAA,EAjB3C;AAiB2C,IAAA,MAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBzC,MAAsB,KAAkB,OAAA,EAA+C;AAGrF,IAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,MAAA,IAAU,EAAC;AAClC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,aAAA,CAAcC,cAAA,CAAW,EAAE,CAAA,CAAE,IAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,MAAA,EAAQ,OAAA,CAAQ,SAAS,CAAA;AAAA,EACjG;AACF;;;;"}