Skip to content

Commit

Permalink
Add UUID and member ID properties to Bitrix24Account
Browse files Browse the repository at this point in the history
Updated the Bitrix24Account class with UUID and member ID properties, leveraging Symfony and Doctrine annotations. Additionally, replaced the deprecated SDK package and adjusted the PHPUnit testsuite configuration.

Signed-off-by: mesilov <[email protected]>
  • Loading branch information
mesilov committed Oct 6, 2024
1 parent ef8ab43 commit 6d8d5bd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ test-run-phpstan:

# unit-tests
test-run-unit-tests:
docker-compose run --rm php-cli php vendor/bin/phpunit --testsuite=unit --testdox
docker-compose run --rm php-cli php vendor/bin/phpunit --testsuite=unit_tests --testdox

# functional-tests, work with test database
test-run-functional-tests:
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"darsyn/ip": "^5",
"nesbot/carbon": "^3",
"moneyphp/money": "^4",
"mesilov/bitrix24-php-sdk": "^2",
"bitrix24/b24phpsdk": "^1",
"doctrine/orm": "^3",
"doctrine/doctrine-bundle": "*",
"doctrine/doctrine-migrations-bundle": "*",
Expand All @@ -52,8 +52,7 @@
"symfony/yaml": "^7",
"symfony/cache": "^7",
"symfony/console": "^7",
"symfony/dotenv": "^7",
"symfony/framework-bundle": "^7"
"symfony/dotenv": "^7"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.59",
Expand All @@ -75,7 +74,7 @@
"autoload-dev": {
"psr-4": {
"Bitrix24\\SDK\\Lib\\Tests\\": "tests",
"Bitrix24\\SDK\\Tests\\": "vendor/mesilov/bitrix24-php-sdk/tests"
"Bitrix24\\SDK\\Tests\\": "vendor/bitrix24/b24phpsdk/tests"
}
}
}
36 changes: 27 additions & 9 deletions src/Bitrix24Accounts/Entity/Bitrix24Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,24 @@
use Bitrix24\SDK\Core\Response\DTO\RenewedAuthToken;
use Carbon\CarbonImmutable;
use Override;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Uid\Uuid;
use Doctrine\ORM\Mapping as ORM;

class Bitrix24Account implements Bitrix24AccountInterface
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
private readonly Uuid $id;
#[ORM\Column(name: 'b24_user_id', type: 'integer', nullable: false)]
#[SerializedName('b24_user_id')]
private readonly int $bitrix24UserId;
/** bitrix24 portal unique id */
#[ORM\Column(name: 'member_id', type: 'string', nullable: false)]
#[SerializedName('member_id')]
private readonly string $memberId;

private string $accessToken;

private string $refreshToken;
Expand All @@ -38,10 +52,10 @@ class Bitrix24Account implements Bitrix24AccountInterface
private ?string $comment = null;

public function __construct(
private readonly Uuid $id,
private readonly int $bitrix24UserId,
Uuid $id,
int $bitrix24UserId,
private readonly bool $isBitrix24UserAdmin,
private readonly string $memberId,
string $memberId,
private string $domainUrl,
private Bitrix24AccountStatus $accountStatus,
AuthToken $authToken,
Expand All @@ -51,9 +65,13 @@ public function __construct(
Scope $applicationScope,
)
{
$this->accessToken = $authToken->getAccessToken();
$this->refreshToken = $authToken->getRefreshToken();
$this->expires = $authToken->getExpires();
$this->id = $id;
$this->bitrix24UserId = $bitrix24UserId;
$this->memberId = $memberId;

$this->accessToken = $authToken->accessToken;
$this->refreshToken = $authToken->refreshToken;
$this->expires = $authToken->expires;
$this->applicationScope = $applicationScope->getScopeCodes();
}

Expand Down Expand Up @@ -117,9 +135,9 @@ public function renewAuthToken(RenewedAuthToken $renewedAuthToken): void
);
}

$this->accessToken = $renewedAuthToken->authToken->getAccessToken();
$this->refreshToken = $renewedAuthToken->authToken->getRefreshToken();
$this->expires = $renewedAuthToken->authToken->getExpires();
$this->accessToken = $renewedAuthToken->authToken->accessToken;
$this->refreshToken = $renewedAuthToken->authToken->refreshToken;
$this->expires = $renewedAuthToken->authToken->expires;
$this->updatedAt = new CarbonImmutable();
}

Expand Down

0 comments on commit 6d8d5bd

Please sign in to comment.