Skip to content

Commit

Permalink
Merge pull request #375 from mesilov/371-publish-b24-php-sdk-beta-2
Browse files Browse the repository at this point in the history
371 publish b24 php sdk beta 2
  • Loading branch information
mesilov committed Apr 12, 2024
2 parents eda95ae + a4c5246 commit b69341f
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,4 +7,5 @@ composer.lock
tools/.env.local
tools/logs
examples/logs
*.log
.env.local
14 changes: 14 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,19 @@
# bitrix24-php-sdk change log

## 2.0-beta.2 — 1.04.2024

### Added
### Changed
* updated [dependencies versions](https://github.com/mesilov/bitrix24-php-sdk/issues/373):
* require
* `psr/log` `1.4.0``3.0.*`
* `moneyphp/money` `4.3.*``4.5.*`
* require-dev
* `monolog/monolog` `2.9.*``3.5.*`
* `phpunit/phpunit` `10.5.*``11.0.*`
### Bugfix
### etc

## 2.0-beta.1 — 18.02.2024

### Added
Expand Down
27 changes: 25 additions & 2 deletions README.md
Expand Up @@ -29,7 +29,7 @@ Domain core events:
API - level features

- [x] Auto renew access tokens
- [ ] List queries with «start=-1» support
- [x] List queries with «start=-1» support
- [ ] offline queues

Performance improvements 🚀
Expand Down Expand Up @@ -67,7 +67,6 @@ Low-level tools to devs:
- Reliable:
- test coverage: unit, integration, contract
- typical examples typical for different modes of operation and they are optimized for memory \ performance

## Architecture

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

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

## Examples
### Work with webhook
```php
declare(strict_types=1);

use Bitrix24\SDK\Services\ServiceBuilderFactory;
use Monolog\Logger;
use Symfony\Component\EventDispatcher\EventDispatcher;

require_once 'vendor/autoload.php';

$webhookUrl = 'INSERT_HERE_YOUR_WEBHOOK_URL';

$log = new Logger('bitrix24-php-sdk');
$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);

// init bitrix24-php-sdk service
$b24Service = $b24ServiceFactory->initFromWebhook($webhookUrl);

// work with interested scope
var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile());
var_dump($b24Service->getCRMScope()->lead()->list([],[],['ID','TITLE'])->getLeads()[0]->TITLE);
```

## Tests

Tests locate in folder `tests` and we have two test types.
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Expand Up @@ -25,20 +25,20 @@
"ext-bcmath": "*",
"ext-curl": "*",
"ext-intl": "*",
"psr/log": "1.1.*",
"psr/log": "^2 || ^3",
"fig/http-message-util": "1.1.*",
"ramsey/uuid": "4.7.*",
"moneyphp/money": "4.3.*",
"symfony/http-client": "7.0.*",
"symfony/http-client-contracts": "3.4.*",
"symfony/http-foundation": "7.0.*",
"symfony/event-dispatcher": "7.0.*",
"symfony/uid": "7.0.*"
"ramsey/uuid": "^3 ||^4",
"moneyphp/money": "^3 || ^4",
"symfony/http-client": "^6 || ^7",
"symfony/http-client-contracts": "^2 || ^3",
"symfony/http-foundation": "^6 || ^7",
"symfony/event-dispatcher": "^6 || ^7",
"symfony/uid": "^6 || ^7"
},
"require-dev": {
"monolog/monolog": "2.9.*",
"monolog/monolog": "3.5.*",
"phpstan/phpstan": "1.10.*",
"phpunit/phpunit": "10.5.*",
"phpunit/phpunit": "11.0.*",
"symfony/console": "7.0.*",
"symfony/dotenv": "7.0.*",
"symfony/debug-bundle": "7.0.*",
Expand Down
5 changes: 5 additions & 0 deletions examples/webhook/.env
@@ -0,0 +1,5 @@
# bitrix24 webhook url
BITRIX24_WEBHOOK_URL=
# monolog
LOG_LEVEL=100
LOG_FILE_NAME=bitrix24-php-sdk.log
20 changes: 20 additions & 0 deletions examples/webhook/composer.json
@@ -0,0 +1,20 @@
{
"name": "mesilov/bitrix24-php-sdk-webhook-example",
"description": "Example for work with bitrix24-php-sdk via webhook",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "Maksim Mesilov",
"email": "mesilov.maxim@gmail.com"
}
],
"require": {
"mesilov/bitrix24-php-sdk": "dev-371-publish-b24-php-sdk-beta-2",
"monolog/monolog": "3.5.*",
"symfony/dotenv": "7.0.*"
},
"require-dev": {
"roave/security-advisories": "dev-latest"
}
}
30 changes: 30 additions & 0 deletions examples/webhook/example.php
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);

use Bitrix24\SDK\Services\ServiceBuilderFactory;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Processor\MemoryUsageProcessor;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\EventDispatcher\EventDispatcher;

require_once 'vendor/autoload.php';

// load credentials for work with bitrix24 portal
(new Dotenv())->loadEnv('.env');
$webhookUrl = $_ENV['BITRIX24_WEBHOOK_URL'];

// configure logger for debug queries
$log = new Logger('bitrix24-php-sdk');
$log->pushHandler(new StreamHandler($_ENV['LOG_FILE_NAME'], (int)$_ENV['LOG_LEVEL']));
$log->pushProcessor(new MemoryUsageProcessor(true, true));
$log->pushProcessor(new IntrospectionProcessor());

// create factory for build service from multiple sources: webhook, request, bitrix24 account with oauth2.0 tokens
$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);
// init bitrix24-php-sdk service with webhook credentials
$b24Service = $b24ServiceFactory->initFromWebhook($webhookUrl);

$deal = $b24Service->getCRMScope()->deal()->get(1)->deal();
var_dump($deal->TITLE);

0 comments on commit b69341f

Please sign in to comment.