1.4.1 • Published 3 years ago

bx24-api v1.4.1

Weekly downloads
19
License
ISC
Repository
github
Last release
3 years ago

bx24-api

This library is an improved interface for working with the official Bitrix JavaScript library.

The library cannot be used for external applications and webhooks.

Advantage:

  • Promise is used instead of callback in functions.
  • Auto loading and initialize the official Bitrix library when calling any function.

Это библиотека представляет собой улучшений интерфейс для работы с официальной JavaScript библитекой Bitrix.

Для внешних приложений и вебхуков библиотека использоваться не может.

Плюсы:

  • Использование Promise вместо callback в функциях.
  • Автоматическая загрузка и инициализация официальной библиотеки Bitrix при вызове любой функции

Installation / Установка

npm install bx24-api

Use / Использование

import BX24 from 'bx24-api'

let leads = [];
BX24.callMethod('crm.lead.get').then(data => {
    leads = data.answer.result
})

You don't need to call init() before using any functions, because init() is always called at the beginning of these functions, except install()

All function from official library duplicate for this library interface.


Вам не нужно постоянно вызывать функцию init() перед использованием любой функции, так как init() вызывается автоматически при вызове функции, исключение функция install().

Все функции официальной библиотеки дублированы под интерфейс данной библиотеки.

Additions / Дополнения

Request next data chunk / Запрос следующей страницы данных

ajaxResult.next() will return Promise like callMethod


ajaxResult.next() будет возращать Promise, как callMethod

let lastCall = null
let users = []
callMethod('user.get').then(result => {
  lastCall = result.more()? result: null
  users.push(...result.data())
})

function nextPage() {
  if(lastCall) {
    lastCall.next().then(result => {
      lastCall = result.more()? result: null
      users.push(...result.data())
    })
  }
}

Import Large Data Batches / Выгрузка больших объемов данных

Additional function callMethodAll(method, params) is designed to import large amounts of data. Based on advice in the documentation.

Supports only methods for calling the list of entities that have an ID parameter in their structure and support query parameters: filter, order and select


Дополнительная функция callMethodAll(method, params) разработана для загрузки больших объемов данных. Основана на примере с документации.

Поддерживает только методы вызова списка сущностей которые имеют в своей структуре параметр ID и поддерживают параметры запроса: filter, order, select

BX24.callMethodAll('crm.lead.get').then(result => {
  // ...
})

Throw exception mode / Режим генерации ошибок

By default, if the functions callMethod, callBatch, callBind and callUnBind response returns with errors, then an error will be thrown.

You can turn off throw errors BX24.throwOn(false).


По дефолду если запросы функций callMethod, callBatch, callBind and callUnBind возвращают ответ с ошибкой будет вызываться throw.

Вы можете выключить вызов ошибки BX24.throwOn(false).

// When throw on
BX24.callMethod('crm.lead.get').then(result => {
    leads = result.data()
}).catch(error => {
    // ...
})
1.4.1

3 years ago

1.4.0

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago