New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@2bad/bitrix

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@2bad/bitrix

Bitrix24 REST API client that doesn't suck

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

@2bad/bitrix

Bitrix24 REST API client that doesn't suck

Some testing examples:

import Bitrix from './bitrix'
import { Method } from './bitrix/types'

const BITRIX_ADDRESS = 'https://DOMAIN.bitrix24.ru'
const AUTH_TOKEN = 'AUTH_TOKEN'

const bitrix = Bitrix(`${BITRIX_ADDRESS}/rest`, AUTH_TOKEN)

// ----------------------
// Common methods
// ----------------------

bitrix.get(Method.GET_DEAL, { query: { ID: 3357 } })
  .then(console.log)
  .catch(console.error)

// Error example
bitrix.get(Method.GET_DEAL, { query: { ID: 9999999999999 } })
  .then(console.log)
  .catch(console.error)

// Get first 50
bitrix.getList(Method.LIST_DEALS, {})
  .then(console.log)
  .catch(console.error)

// ----------------------
// API
// ----------------------

// Get deal
bitrix.deals.get({ ID: 25 })
  .then(console.log)
  .catch(console.error)

// Get all deals
bitrix.deals.list({ select: ["*", "UF_*"] })
  .then(console.log)
  .catch(console.error)

FAQ

Is it finished?

Not yet. However, what's in the docs already works, and not yet covered Bitrix operations can be done with a provided low-level client methods.

Does it handle authentication?

Not yet. You have to init client with already obtained by any legal means authentication token.

Should I check payloads error properties for errors?

You shouldn't. Catch rejections instead, as the library will check it and reject if there are any errors in a payload.

I need to call a Bitrix method which isn't supported yet

Use appropriate provided low-level client methods, like that:

bitrix.get<SomeNewMethodType>('some.new.get.method' as any, { ID: 77 })
bitrix.list<SomeNewMethodType>('some.new.list.method' as any, { select: ["TITLE"] })

I need to call a specific set of commands. How to do that effectively?

Use low-level batch method. It will make minimum network requests and do all dirty work behind the curtains:

bitrix.batch<{
  lead: Lead,
  deals: Deal[]
}>({
  lead: { method: Method.GET_LEAD, params: { ID: 77 } },
  deals: { method: Method.LIST_DEALS }
})

Development

  • npm test — run all tests
  • npm run test:unit — run unit tests
  • npm run test:integration — run integration tests
  • npm run test:watch — watch for changes and run all tests
  • npm run test:unit:watch — watch for changes and run unit tests
  • npm run test:integration:watch — watch for changes and run integration tests
  • npm run build — build library for the release

Keywords

FAQs

Package last updated on 31 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc