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

Commit b69341f

Browse files
authored
Merge pull request #375 from mesilov/371-publish-b24-php-sdk-beta-2
371 publish b24 php sdk beta 2
2 parents eda95ae + a4c5246 commit b69341f

File tree

7 files changed

+105
-12
lines changed

7 files changed

+105
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ composer.lock
77
tools/.env.local
88
tools/logs
99
examples/logs
10+
*.log
1011
.env.local

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# bitrix24-php-sdk change log
22

3+
## 2.0-beta.2 — 1.04.2024
4+
5+
### Added
6+
### Changed
7+
* updated [dependencies versions](https://github.com/mesilov/bitrix24-php-sdk/issues/373):
8+
* require
9+
* `psr/log` `1.4.0``3.0.*`
10+
* `moneyphp/money` `4.3.*``4.5.*`
11+
* require-dev
12+
* `monolog/monolog` `2.9.*``3.5.*`
13+
* `phpunit/phpunit` `10.5.*``11.0.*`
14+
### Bugfix
15+
### etc
16+
317
## 2.0-beta.1 — 18.02.2024
418

519
### Added

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Domain core events:
2929
API - level features
3030

3131
- [x] Auto renew access tokens
32-
- [ ] List queries with «start=-1» support
32+
- [x] List queries with «start=-1» support
3333
- [ ] offline queues
3434

3535
Performance improvements 🚀
@@ -67,7 +67,6 @@ Low-level tools to devs:
6767
- Reliable:
6868
- test coverage: unit, integration, contract
6969
- typical examples typical for different modes of operation and they are optimized for memory \ performance
70-
7170
## Architecture
7271

7372
### Abstraction layers
@@ -98,6 +97,30 @@ Help bitrix24-php-sdk by [boosty.to/bitrix24-php-sdk](https://boosty.to/bitrix24
9897

9998
Add `"mesilov/bitrix24-php-sdk": "2.x"` to `composer.json` of your application. Or clone repo to your project.
10099

100+
## Examples
101+
### Work with webhook
102+
```php
103+
declare(strict_types=1);
104+
105+
use Bitrix24\SDK\Services\ServiceBuilderFactory;
106+
use Monolog\Logger;
107+
use Symfony\Component\EventDispatcher\EventDispatcher;
108+
109+
require_once 'vendor/autoload.php';
110+
111+
$webhookUrl = 'INSERT_HERE_YOUR_WEBHOOK_URL';
112+
113+
$log = new Logger('bitrix24-php-sdk');
114+
$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);
115+
116+
// init bitrix24-php-sdk service
117+
$b24Service = $b24ServiceFactory->initFromWebhook($webhookUrl);
118+
119+
// work with interested scope
120+
var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile());
121+
var_dump($b24Service->getCRMScope()->lead()->list([],[],['ID','TITLE'])->getLeads()[0]->TITLE);
122+
```
123+
101124
## Tests
102125

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

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
"ext-bcmath": "*",
2626
"ext-curl": "*",
2727
"ext-intl": "*",
28-
"psr/log": "1.1.*",
28+
"psr/log": "^2 || ^3",
2929
"fig/http-message-util": "1.1.*",
30-
"ramsey/uuid": "4.7.*",
31-
"moneyphp/money": "4.3.*",
32-
"symfony/http-client": "7.0.*",
33-
"symfony/http-client-contracts": "3.4.*",
34-
"symfony/http-foundation": "7.0.*",
35-
"symfony/event-dispatcher": "7.0.*",
36-
"symfony/uid": "7.0.*"
30+
"ramsey/uuid": "^3 ||^4",
31+
"moneyphp/money": "^3 || ^4",
32+
"symfony/http-client": "^6 || ^7",
33+
"symfony/http-client-contracts": "^2 || ^3",
34+
"symfony/http-foundation": "^6 || ^7",
35+
"symfony/event-dispatcher": "^6 || ^7",
36+
"symfony/uid": "^6 || ^7"
3737
},
3838
"require-dev": {
39-
"monolog/monolog": "2.9.*",
39+
"monolog/monolog": "3.5.*",
4040
"phpstan/phpstan": "1.10.*",
41-
"phpunit/phpunit": "10.5.*",
41+
"phpunit/phpunit": "11.0.*",
4242
"symfony/console": "7.0.*",
4343
"symfony/dotenv": "7.0.*",
4444
"symfony/debug-bundle": "7.0.*",

examples/webhook/.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# bitrix24 webhook url
2+
BITRIX24_WEBHOOK_URL=
3+
# monolog
4+
LOG_LEVEL=100
5+
LOG_FILE_NAME=bitrix24-php-sdk.log

examples/webhook/composer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "mesilov/bitrix24-php-sdk-webhook-example",
3+
"description": "Example for work with bitrix24-php-sdk via webhook",
4+
"minimum-stability": "stable",
5+
"license": "proprietary",
6+
"authors": [
7+
{
8+
"name": "Maksim Mesilov",
9+
"email": "mesilov.maxim@gmail.com"
10+
}
11+
],
12+
"require": {
13+
"mesilov/bitrix24-php-sdk": "dev-371-publish-b24-php-sdk-beta-2",
14+
"monolog/monolog": "3.5.*",
15+
"symfony/dotenv": "7.0.*"
16+
},
17+
"require-dev": {
18+
"roave/security-advisories": "dev-latest"
19+
}
20+
}

examples/webhook/example.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Bitrix24\SDK\Services\ServiceBuilderFactory;
5+
use Monolog\Handler\StreamHandler;
6+
use Monolog\Logger;
7+
use Monolog\Processor\IntrospectionProcessor;
8+
use Monolog\Processor\MemoryUsageProcessor;
9+
use Symfony\Component\Dotenv\Dotenv;
10+
use Symfony\Component\EventDispatcher\EventDispatcher;
11+
12+
require_once 'vendor/autoload.php';
13+
14+
// load credentials for work with bitrix24 portal
15+
(new Dotenv())->loadEnv('.env');
16+
$webhookUrl = $_ENV['BITRIX24_WEBHOOK_URL'];
17+
18+
// configure logger for debug queries
19+
$log = new Logger('bitrix24-php-sdk');
20+
$log->pushHandler(new StreamHandler($_ENV['LOG_FILE_NAME'], (int)$_ENV['LOG_LEVEL']));
21+
$log->pushProcessor(new MemoryUsageProcessor(true, true));
22+
$log->pushProcessor(new IntrospectionProcessor());
23+
24+
// create factory for build service from multiple sources: webhook, request, bitrix24 account with oauth2.0 tokens
25+
$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);
26+
// init bitrix24-php-sdk service with webhook credentials
27+
$b24Service = $b24ServiceFactory->initFromWebhook($webhookUrl);
28+
29+
$deal = $b24Service->getCRMScope()->deal()->get(1)->deal();
30+
var_dump($deal->TITLE);

0 commit comments

Comments
 (0)