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

Commit f67bc8a

Browse files
authored
Merge pull request #398 from mesilov/feature/383-refactor-app-contracts-and-add-documentation-for-use-cases
refactor app contracts and add documentation for use cases
2 parents 67c94ce + b890fc4 commit f67bc8a

File tree

169 files changed

+11057
-1284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+11057
-1284
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161

6262
### Changed
6363
* ❗️ migrate from `ramsey/uuid` to `symfony/uid`
64+
* ❗️ refactor `Bitrix24\SDK\Application\Contracts`:
65+
6466
* ❗️ update scope `telephony`, scope fully rewritten
6567
* `ExternalCall` – work with external call:
6668
* `getCallRecordUploadUrl` – get url for upload call record file

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ lint-rector-fix:
1010
vendor/bin/rector process
1111

1212
test-unit:
13-
vendor/bin/phpunit --testsuite unit_tests
13+
vendor/bin/phpunit --testsuite unit_tests --display-warnings
1414

1515
# integration tests with granularity by api-scope
1616
test-integration-scope-telephony:

README.md

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ A powerful PHP library for the Bitrix24 REST API
77

88
## Build status
99

10-
| CI\CD [status](https://github.com/mesilov/bitrix24-php-sdk/actions) on `master` |
10+
| CI\CD [status](https://github.com/mesilov/bitrix24-php-sdk/actions) on `master` |
1111
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1212
| [![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) |
1313
| [![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) |
1414
| [![integration-tests status](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/integration.yml/badge.svg)](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/integration.yml) |
1515

16-
Integration tests run in GitHub actions with real Bitrix24 portal
16+
Integration tests run in GitHub actions with real Bitrix24 portal
1717

1818
## BITRIX24-PHP-SDK ✨FEATURES✨
1919

@@ -23,8 +23,9 @@ Support both auth modes:
2323
- [x] work with incoming webhooks for simple integration projects for current portal
2424

2525
Domain core events:
26-
- [x] Access Token expired
27-
- [x] Bitrix24 portal domain url changed
26+
27+
- [x] Access Token expired
28+
- [x] Bitrix24 portal domain url changed
2829

2930
API - level features
3031

@@ -34,18 +35,10 @@ API - level features
3435

3536
Performance improvements 🚀
3637

37-
- Batch queries implemented with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php) – constant low memory and
38-
low CPI usage
39-
- [x] batch read data from bitrix24
40-
- [x] batch write data to bitrix24
41-
- [ ] write and read in one batch package
42-
- [ ] composite batch queries to many entities (work in progress)
43-
- [ ] read without count flag
44-
45-
Low-level tools to devs:
46-
- [ ] Rate-limit strategy
47-
- [ ] Retry strategy for safe methods
48-
38+
- [x] Batch queries implemented with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php) – constant low memory and low CPI usage:
39+
- [x] batch read data from bitrix24
40+
- [x] batch write data to bitrix24
41+
- [x] read without count flag
4942

5043
## Development principles
5144

@@ -67,6 +60,7 @@ Low-level tools to devs:
6760
- Reliable:
6861
- test coverage: unit, integration, contract
6962
- typical examples typical for different modes of operation and they are optimized for memory \ performance
63+
7064
## Architecture
7165

7266
### Abstraction layers
@@ -83,6 +77,7 @@ Low-level tools to devs:
8377
output: b24 response dto
8478
process: b24 entities, operate with immutable objects
8579
```
80+
8681
## Sponsors
8782

8883
Help bitrix24-php-sdk by [boosty.to/bitrix24-php-sdk](https://boosty.to/bitrix24-php-sdk)
@@ -98,7 +93,9 @@ Help bitrix24-php-sdk by [boosty.to/bitrix24-php-sdk](https://boosty.to/bitrix24
9893
Add `"mesilov/bitrix24-php-sdk": "2.x"` to `composer.json` of your application. Or clone repo to your project.
9994

10095
## Examples
96+
10197
### Work with webhook
98+
10299
```php
103100
declare(strict_types=1);
104101

@@ -121,17 +118,58 @@ var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserPr
121118
var_dump($b24Service->getCRMScope()->lead()->list([],[],['ID','TITLE'])->getLeads()[0]->TITLE);
122119
```
123120

121+
### Create application for Bitrix24 marketplace
122+
123+
if you want to create application you can use production-ready contracts in namespace
124+
`Bitrix24\SDK\Application\Contracts`:
125+
126+
- `Bitrix24Accounts` — Store auth tokens and
127+
provides [methods](src/Application/Contracts/Bitrix24Accounts/Docs/Bitrix24Accounts.md) for work with Bitrix24
128+
account.
129+
- `ApplicationInstallations` — Store information about [application installation](src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md), linked with Bitrix24 Account with auth
130+
tokens. Optional can store links to:
131+
- Client contact person: client person who responsible for application usage
132+
- Bitrix24 Partner contact person: partner contact person who supports client and configure application
133+
- Bitrix24 Partner: partner who supports client portal
134+
- `ContactPersons` – Store information [about person](src/Application/Contracts/ContactPersons/Docs/ContactPersons.md) who installed application.
135+
- `Bitrix24Partners` – Store information about [Bitrix24 Partner](src/Application/Contracts/Bitrix24Partners/Docs/Bitrix24Partners.md) who supports client portal and install or configure application.
136+
137+
Steps:
138+
1. Create own entity of this bounded contexts.
139+
2. Implement all methods in contract interfaces.
140+
3. Test own implementation behavior with contract-tests `tests/Unit/Application/Contracts/*` – examples.
141+
124142
## Tests
125143

126144
Tests locate in folder `tests` and we have two test types.
127145
In folder tests create file `.env.local` and fill environment variables from `.env`.
128146

147+
### PHP Static Analysis Tool – phpstan
148+
149+
Call in command line
150+
151+
```shell
152+
make lint-phpstan
153+
```
154+
### PHP Static Analysis Tool – rector
155+
156+
Call in command line for validate
157+
158+
```shell
159+
make lint-rector
160+
```
161+
Call in command line for fix codebase
162+
163+
```shell
164+
make lint-rector-fix
165+
```
166+
129167
### Unit tests
130168

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

133171
```shell
134-
composer phpunit-run-unit-test
172+
make test-unit
135173
```
136174

137175
### Integration tests
@@ -142,12 +180,12 @@ composer phpunit-run-unit-test
142180

143181
For run integration test you must:
144182

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

153191
```yaml
@@ -159,15 +197,10 @@ INTEGRATION_TEST_LOG_LEVEL=500
159197
8. call in command line
160198

161199
```shell
162-
composer composer phpunit-run-integration-tests
163-
```
164-
165-
#### PHP Static Analysis Tool – phpstan
166-
167-
Call in command line
168-
169-
```shell
170-
composer phpstan-analyse
200+
make test-integration-core
201+
make test-integration-scope-telephony
202+
make test-integration-scope-workflows
203+
make test-integration-scope-user
171204
```
172205

173206
## Submitting bugs and feature requests
@@ -182,16 +215,13 @@ bitrix24-php-sdk is licensed under the MIT License - see the `MIT-LICENSE.txt` f
182215

183216
Maksim Mesilov - mesilov.maxim@gmail.com
184217

185-
See also the list of [contributors](https://github.com/mesilov/bitrix24-php-sdk/graphs/contributors) which participated in this project.
218+
See also the list of [contributors](https://github.com/mesilov/bitrix24-php-sdk/graphs/contributors) which participated
219+
in this project.
186220

187221
## Need custom Bitrix24 application?
188222

189223
mesilov.maxim@gmail.com for private consultations or dedicated support
190224

191225
## Documentation
192226

193-
[Bitrix24 API documentation - Russian](http://dev.1c-bitrix.ru/rest_help/)
194-
195227
[Bitrix24 API documentation - English](https://training.bitrix24.com/rest_help/)
196-
197-
[Register new Bitrix24 account](https://www.bitrix24.ru/create.php?p=255670)

composer.json

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@
1717
}
1818
],
1919
"config": {
20-
"sort-packages": true
20+
"sort-packages": true,
21+
"allow-plugins": {
22+
"dealerdirect/phpcodesniffer-composer-installer": true
23+
}
2124
},
2225
"require": {
2326
"php": "8.2.* || 8.3.*",
2427
"ext-json": "*",
25-
"ext-bcmath": "*",
2628
"ext-curl": "*",
2729
"ext-intl": "*",
2830
"psr/log": "^2 || ^3",
29-
"fig/http-message-util": "1.1.*",
30-
"nesbot/carbon": "3.3.*",
31+
"fig/http-message-util": "^1",
32+
"giggsey/libphonenumber-for-php": "^8",
33+
"darsyn/ip": "^4 || ^5",
34+
"nesbot/carbon": "^3",
3135
"moneyphp/money": "^3 || ^4",
3236
"symfony/http-client": "^6 || ^7",
3337
"symfony/console": "^6 || ^7",
@@ -40,14 +44,16 @@
4044
"symfony/uid": "^6 || ^7"
4145
},
4246
"require-dev": {
43-
"monolog/monolog": "3.5.*",
44-
"phpstan/phpstan": "1.10.*",
45-
"phpunit/phpunit": "11.0.*",
46-
"symfony/debug-bundle": "7.0.*",
47-
"symfony/stopwatch": "7.0.*",
47+
"fakerphp/faker": "^1",
48+
"monolog/monolog": "^3",
49+
"nunomaduro/phpinsights": "^2",
50+
"phpstan/phpstan": "1.11.7",
51+
"phpunit/phpunit": "^10 || ^11",
52+
"psalm/phar": "^5",
53+
"rector/rector": "^1",
4854
"roave/security-advisories": "dev-master",
49-
"fakerphp/faker": "1.23.*",
50-
"rector/rector": "^1.0"
55+
"symfony/debug-bundle": "^6 || ^7",
56+
"symfony/stopwatch": "^6 || ^7"
5157
},
5258
"autoload": {
5359
"psr-4": {

docs/RU/Application/new-local-application.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/RU/Core/Auth/auth.md

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)