@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
57 lines (53 loc) • 1.93 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 2.0.0
* @copyright (c) 2026 Bitrix24
* @license MIT
* @see https://github.com/bitrix24/b24jssdk
* @see https://bitrix24.github.io/b24jssdk/
*/
;
const abstractAction = require('../abstract-action.cjs');
const b24 = require('../../../types/b24.cjs');
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
class CallV2 extends abstractAction.AbstractAction {
static {
__name(this, "CallV2");
}
/**
* Calls the Bitrix24 REST API method.
*
* @template T - The expected data type in the response (default is `unknown`).
*
* @param {ActionCallV2} options - parameters for executing the request.
* - `method: string` - REST API method name (eg: `crm.item.get`)
* - `params?: TypeCallParams` - Parameters for calling the method.
* - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging.
*
* @returns {Promise<AjaxResult<T>>} A promise that resolves to the result of an REST API call.
*
* @example
* import { EnumCrmEntityTypeId } from '@bitrix24/b24jssdk'
*
* interface CrmItem { id: number, name: string, lastName: string }
* const response = await b24.actions.v2.call.make<{ item: CrmItem }>({
* method: 'crm.item.get',
* params: {
* entityTypeId: EnumCrmEntityTypeId.contact,
* id: 123
* },
* requestId: 'item-123'
* })
* if (!response.isSuccess) {
* throw new Error(`Problem: ${response.getErrorMessages().join('; ')}`)
* }
* console.log(response.getData().result.item.name)
*/
async make(options) {
const params = options.params || {};
return this._b24.getHttpClient(b24.ApiVersion.v2).call(options.method, params, options.requestId);
}
}
exports.CallV2 = CallV2;
//# sourceMappingURL=call.cjs.map