Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
Merged

Dev #257

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5f99454
Merge pull request #1 from xUJYx/miss_spelling
xUJYx Apr 1, 2020
a85df3a
Added support of API calls using webhook (without access_token) inste…
xUJYx Apr 1, 2020
81864e5
add support company user fields
Jul 21, 2020
ac4ae38
Fix product.property "update" endpoint value
dipech Sep 5, 2020
9675093
Merge pull request #160 from xUJYx/add_webhook_call_support
mesilov Oct 18, 2020
edd251a
Merge pull request #165 from bilovol/add_company_user_fields
mesilov Oct 18, 2020
694856b
Merge pull request #166 from DiPech/patch-1
mesilov Oct 18, 2020
19243cf
режет глаз)
gilyazov Oct 26, 2020
89eeff5
Merge pull request #175 from gilyazov/patch-1
mesilov Oct 30, 2020
a938c73
Add getById method to User class
Nov 20, 2020
1ca35d4
Merge pull request #184 from waleev/user_getbyid_method
mesilov Nov 28, 2020
dfad157
add onApiCallMethod
camaxtly May 30, 2021
c2841a4
Merge pull request #218 from mesilov/issue#217
camaxtly May 30, 2021
8b6426d
fix error
camaxtly Jun 10, 2021
1f8b3af
Merge pull request #220 from mesilov/issue#217
camaxtly Jun 10, 2021
50d8d04
Merge branch '2.x'
mesilov Nov 14, 2021
6a273b0
fix errors in tests and stubs
mesilov Nov 14, 2021
327c8a2
fix error in integration test
mesilov Nov 14, 2021
bdbc52b
bump dependencies versions
mesilov Nov 24, 2021
1caade7
Merge pull request #227 from mesilov/224-fix-laravel8-support
mesilov Nov 24, 2021
c485cc3
delete old files
mesilov Nov 24, 2021
2ff2bbb
try to fix phpstan with phpunit
mesilov Nov 24, 2021
00d9907
try to fix phpstan with phpunit2
mesilov Nov 24, 2021
f23a448
try to fix phpstan with phpunit3
mesilov Nov 24, 2021
267df06
remove tests from phpstan check
mesilov Nov 24, 2021
e64546c
fix phpstan errors
mesilov Nov 26, 2021
4fad86d
fix phpstan errors on level 2
mesilov Nov 26, 2021
b037f16
fix phpstan errors on level 3
mesilov Nov 26, 2021
9b7e816
fix phpstan errors on level 5
mesilov Nov 26, 2021
7ca1ff5
fix errors on test suites
mesilov Nov 26, 2021
dd575fa
fix errors on test suites
mesilov Nov 26, 2021
ca3aec3
update documentation
mesilov Nov 26, 2021
6a4eabf
add method count by filter
mesilov Nov 26, 2021
3e184fb
Merge pull request #229 from mesilov/228-count-by-filter
mesilov Nov 26, 2021
6cee3f8
update Scope.php
mesilov Nov 27, 2021
ac7738b
add userfield type
mesilov Nov 27, 2021
68aea3d
add ContactUserfield service and test
mesilov Nov 27, 2021
0c06ed5
first contact userfields build
mesilov Nov 28, 2021
dfbcf44
Merge pull request #234 from mesilov/231-contact-userfields
mesilov Nov 28, 2021
88949f5
first deal userfields build
mesilov Nov 28, 2021
f08c7ec
Merge pull request #236 from mesilov/232-deal-userfields
mesilov Nov 28, 2021
ea1ea61
add types for deal
mesilov Nov 28, 2021
cf40ef9
update changelog
mesilov Nov 28, 2021
83f11ca
Merge pull request #235 from mesilov/dev
mesilov Nov 28, 2021
5e03f54
add validation for webhookUrl
mesilov Jan 15, 2022
1afa9de
fix demoDataGenerator
mesilov Jan 15, 2022
17b02ab
bump Symfony components version to 5.4.*
mesilov Jan 15, 2022
655834a
add Batch::deleteEntityItems
mesilov Jan 16, 2022
0eb45c9
add types for dto
mesilov Jan 17, 2022
4367647
add symfony/stopwatch
mesilov Jan 17, 2022
869a872
add transport layer debug info
mesilov Jan 18, 2022
eba8d90
add BulkItemsReader
mesilov Jan 18, 2022
b73426a
set info log level for apiClient
mesilov Feb 5, 2022
f8cf02b
add info level for Response
mesilov Feb 5, 2022
96017d4
fix BulkItemsReaderBuilder
mesilov Feb 5, 2022
6cd2c4b
add BulkItemsReaderBuilder for services
mesilov Feb 5, 2022
7e32e88
add BulkItemsReaderBuilder for integration test
mesilov Feb 5, 2022
b4cdbdd
add getTraversableList for batch
mesilov Feb 5, 2022
8d10bab
add fixes in batch system
mesilov Feb 5, 2022
d9e60a5
add DeletedItemResultInterface
mesilov Feb 5, 2022
edecbde
fix phpstan typecheck errors on level 5
mesilov Feb 5, 2022
9012764
add memory limit to phpstan
mesilov Feb 5, 2022
3e7a95e
add phpstan github action bage
mesilov Feb 5, 2022
fb8efc5
update readme
mesilov Feb 5, 2022
b3ba42b
update readme build status
mesilov Feb 5, 2022
4daed6f
add integration test for FilterWithBatchWithoutCountOrderTest
mesilov Feb 5, 2022
8aed9e2
fix integration tests for read strategies
mesilov Feb 5, 2022
bb6be7a
fix demo generator for contact
mesilov Feb 5, 2022
bb617f7
update performance benchmark
mesilov Feb 5, 2022
72a880d
fix integration tests
mesilov Feb 5, 2022
3cda0f8
add integration-tests workflow
mesilov Feb 5, 2022
80f6234
add integration-tests workflow2
mesilov Feb 5, 2022
93ac535
add integration-tests workflow settings
mesilov Feb 5, 2022
bb75c17
set secrets for integration-tests
mesilov Feb 5, 2022
87b9f18
обновили документацию
mesilov Feb 5, 2022
228f7f4
Merge pull request #254 from mesilov/248-fast-batch
mesilov Feb 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Integration tests"

on:
push:
branches:
- 'master'
- 'dev'
- '2.x'
paths:
- 'src/**'
- 'tests/**'

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
BITRIX24_PHP_SDK_PLAYGROUND_WEBHOOK: ${{ secrets.BITRIX24_PHP_SDK_PLAYGROUND_WEBHOOK }}
jobs:
tests:
name: "Integration tests"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "7.4"
dependencies: [ highest ]

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Install dependencies"
run: |
composer update ${{ env.COMPOSER_FLAGS }}

- name: "run unit tests"
run: "composer phpunit-run-integration-tests"
37 changes: 30 additions & 7 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,39 @@ on:
name: PHPStan checks

jobs:
phpstan:
name: PHPStan
static-analysis:
name: "PHPStan"
runs-on: "ubuntu-latest"

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
dependencies:
- "lowest"
- "highest"

steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: "actions/checkout@v2"

- name: PHPStan
uses: docker://oskarstark/phpstan-ga
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
args: analyse
coverage: "none"
php-version: "${{ matrix.php-version }}"
extensions: mbstring
tools: composer:v2

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "PHPStan"
run: "composer phpstan-analyse"
7 changes: 2 additions & 5 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,5 @@ jobs:
run: |
composer update ${{ env.COMPOSER_FLAGS }}

- name: "Run tests"
run: "composer exec phpunit -- --verbose"

- name: Run test suite
run: composer run-script unit-tests
- name: "run unit tests"
run: "composer phpunit-run-unit-tests"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ composer.lock
.phpunit.result.cache
tools/.env.local
tools/logs
examples/logs
examples/logs
.env.local
69 changes: 66 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,68 @@
# bitrix24-php-sdk change log

## 2.0-alpha.3(14.11.2021)
## 2.0-alpha.6 — 20.01.2021

### Added

* add «fast» batch-query without counting elements in result
recordset [Добавить поддержку выгрузки большого количества данных без подсчёта элементов (-1](https://github.com/mesilov/bitrix24-php-sdk/issues/248)
* add method `Core\Batch::deleteEntityItems` for delete items in batch mode and integration test
* add integration test for read strategy `FilterWithBatchWithoutCountOrderTest`
* add type check in method `Core\Batch::deleteEntityItems` - only integer id allowed
* add interface `Core\Contracts\DeletedItemResultInterface`
* add in scope «CRM» `Services\CRM\Deal\Service\Batch::delete` batch delete deals
* add `symfony/stopwatch` component for integration tests
* add `/Infrastructure/HttpClient/TransportLayer/NetworkTimingsParser` for parse `curl_info` network data structures for debug logs
in `Bitrix24\SDK\Core\Response::__destruct()`
* add `/Infrastructure/HttpClient/TransportLayer/ResponseInfoParser` for parse `bitrix24_rest_api` timing info for debug logs
in `Bitrix24\SDK\Core\Response::__destruct()`
* add `Bitrix24\SDK\Core\BulkItemsReader` for data-intensive applications for bulk export data from Bitrix24, read strategies located in
folder `ReadStrategies`, in services read model **must** use most effective read strategy.

### Changed

* switch `symfony/http-client` to `5.4.*` version requirement.
* switch `symfony/http-client-contracts` to `^2.5` version requirement.
* switch `symfony/event-dispatcher` to `5.4.*` version requirement.
* switch `ramsey/uuid` to `^4.2.3` version requirement.

## 2.0-alpha.5 – 28.11.2021

### Added

* add method `countByFilter` for all related services, see
issue [Добавить для всех сущностей метод подсчёта количества элементов по фильтру #228](https://github.com/mesilov/bitrix24-php-sdk/issues/228)
* add in scope «CRM» Userfield service and integration test
* add in scope «CRM» ContactUserfield service and integration test, see
issue [Добавить сервис по работе с юзерфилдами контакта #231](https://github.com/mesilov/bitrix24-php-sdk/issues/231)
* add method getUserfieldByFieldName for `ContactItemResult`
* add in scope «CRM» DealUserfield service and integration test, see
issue [Добавить сервис по работе с юзерфилдами cделки #232](https://github.com/mesilov/bitrix24-php-sdk/issues/232)
* add method getUserfieldByFieldName for `DealItemResult`
* add exception `UserfieldNotFoundException`

### Removed

* remove all `0.*` and `1.*` code from `2.*` branch

### Changed

* update type definition for `ContactItemResult`, now return types will be cast to real types: DateTimeInterface, int, boolean etc

## 2.0-alpha.4 – 25.11.2021

### Changed

* switch `symfony/http-client` to `5.3` version requirement.
* switch `symfony/http-client-contracts` to `^2.4` version requirement.
* switch `symfony/event-dispatcher` to `5.3.*` version requirement.
* switch `ramsey/uuid` to `^4.0` version requirement.

### Fixed

* issue [Несовместимость с Laravel 8 #224](https://github.com/mesilov/bitrix24-php-sdk/issues/224)

## 2.0-alpha.3 – 14.11.2021

* add php8 version support
* change in scope «CRM» Product service and integration tests
Expand All @@ -11,7 +73,7 @@
* bump phpunit version
* bump phpstan version

## 2.0-alpha.2 (31.01.2021)
## 2.0-alpha.2 31.01.2021

* remove Travis CI and migrate to Github Actions
* add unit-tests in independent github action
Expand All @@ -26,7 +88,7 @@
* add in scope «IM» IM service and integration test
* add in default scope «Main» default service

## 2.0-alpha.1 (11.07.2020)
## 2.0-alpha.1 11.07.2020

* remove all v1 code
* migrate to Symfony HttpClient
Expand All @@ -35,6 +97,7 @@
* add Events support

## 0.1.0 (14.11.2021)

branch version 1.x – bugfix and security releases only

## 0.7.0 (11.07.2020)
Expand Down
141 changes: 105 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,71 @@
bitrix24-php-sdk [![Build Status](https://travis-ci.org/mesilov/bitrix24-php-sdk.svg?branch=master)](https://travis-ci.org/mesilov/bitrix24-php-sdk)
bitrix24-php-sdk – Bitrix24 REST API PHP SDK
================
[![License](https://poser.pugx.org/mesilov/bitrix24-php-sdk/license.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk) [![Total Downloads](https://poser.pugx.org/mesilov/bitrix24-php-sdk/downloads.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk)
[![Latest Stable Version](https://img.shields.io/packagist/v/mesilov/bitrix24-php-sdk.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk)

A powerful PHP library for the Bitrix24 REST API

[Bitrix24 API documentation - Russian](http://dev.1c-bitrix.ru/rest_help/)<br />
[Bitrix24 API documentation - English](https://training.bitrix24.com/rest_help/)<br />
[Register new Bitrix24 account](https://www.bitrix24.ru/create.php?p=255670)<br />
### Build status

### SDK 2.0 core features
[![phpstan check](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpstan.yml/badge.svg)](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpstan.yml)
[![phpunit unit-tests status](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpunit.yml/badge.svg)](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpunit.yml)

Bitrix24 auth features
### BITRIX24-PHP-SDK Documentation

- ~~work with auth tokens~~
- ~~work with incoming webhooks~~

add low-level tools to devs:
- [Russian](/docs/RU/documentation.md)
- [English](/docs/EN/documentation.md)

- ~~2.1 events (token expired, domain url changed)~~
- 2.2 rate-limiter - wait for symfony/symfony#37471
- 2.3 RetryHttpClient - symfony/symfony#38182
### BITRIX24-PHP-SDK ✨FEATURES✨

API - level features
Support both auth modes:

- ~~3.1 auto renew access tokens~~
- 3.2 batch queries (work in progress)
- ~~3.2.1 read~~
- ~~3.2.2 write~~
- 3.2.3 read + write
- 3.2.4 read without count flag
- 3.3 list queries with «start=-1» support
- 3.4 offline queues
- 3.5 add change domain URL support
- [x] work with auth tokens for Bitrix24 applications in marketplace
- [x] work with incoming webhooks for simple integration projects for current portal

Core DTO
Low-level tools to devs:

- ~~Response~~
- ~~Scope~~
- ~~Time~~
- ~~OAuthToken~~
- ~~ApplicationProfile~~
- ~~Pagination~~
- Domain core events:
- [x] Access Token expired
- [ ] Bitrix24 portal domain url changed
- [ ] Rate-limit strategy
- [ ] Retry strategy for safe methods

### SDK Documentation
API - level features

- [Russian](/docs/RU/documentation.md)
- [English](/docs/EN/documentation.md)
- [x] Auto renew access tokens
- [ ] List queries with «start=-1» support
- [ ] offline queues

Performance improvements 🚀

- Batch queries implemented with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php) – constant low memory and
low CPI usage
- [x] batch read data from bitrix24
- [x] batch write data to bitrix24
- [ ] write and read in one batch package
- [ ] composite batch queries to many entities (work in progress)
- [ ] read without count flag

### Development principles

- Good developer experience
- auto-completion of methods at the IDE
- typed method call signatures
- typed results of method calls
- helpers for typical operations
- Good documentation
- documentation on the operation of a specific method containing a link to the official documentation
- documentation for working with the SDK
- Performance first:
- minimal impact on client code
- ability to work with large amounts of data with constant memory consumption
- efficient operation of the API using butch requests
- Modern technology stack
- based on [Symfony HttpClient](https://symfony.com/doc/current/http_client.html)
- actual PHP versions language features
- Reliable:
- test coverage: unit, integration, contract
- typical examples typical for different modes of operation and they are optimized for memory \ performance

### Architecture

Expand Down Expand Up @@ -95,10 +115,51 @@ Add `"mesilov/bitrix24-php-sdk": "2.x"` to `composer.json` of your application.

### Tests

SDK test locate in folder `tests` and we have two test types
Tests locate in folder `tests` and we have two test types

#### Unit tests

**Fast**, in-memory tests without a network I\O For run unit tests you must call in command line

```shell
composer phpunit-run-unit-test
```

#### Integration tests

**Slow** tests with full lifecycle with your **test** Bitrix24 portal via webhook.

❗️Do not run integration tests with production portals ❗️

- Unit: **fast**, in-memory tests without a network I\O
- Integration: **slow** tests with full lifecycle with test Bitrix24 portal via webhook
For run integration test you must:

1. Create [new Bitrix24 portal](https://www.bitrix24.ru/create.php?p=255670) for development tests
2. Go to left menu, click «Sitemap»
3. Find menu item «Developer resources»
4. Click on menu item «Other»
5. Click on menu item «Inbound webhook»
6. Assign all permisions with webhook and click «save» button
7. Create file `/tests/.env.local` with same settings, see comments in `/tests/.env` file.

```yaml
APP_ENV=dev
BITRIX24_WEBHOOK=https:// your portal webhook url
INTEGRATION_TEST_LOG_LEVEL=500
```

8. call in command line

```shell
composer composer phpunit-run-integration-tests
```

#### PHP Static Analysis Tool – phpstan

Call in command line

```shell
composer phpstan-analyse
```

### Submitting bugs and feature requests

Expand All @@ -119,6 +180,14 @@ email: <mesilov.maxim@gmail.com>

### Sponsors

### Documentation

[Bitrix24 API documentation - Russian](http://dev.1c-bitrix.ru/rest_help/)

[Bitrix24 API documentation - English](https://training.bitrix24.com/rest_help/)

[Register new Bitrix24 account](https://www.bitrix24.ru/create.php?p=255670)

## Русский

### Принципы по которым ведётся разработка
Expand Down
Loading