From fc01b558ea0b4884f06ab5c606c73b7b1b135156 Mon Sep 17 00:00:00 2001 From: KarlsonComplete Date: Sun, 3 Nov 2024 22:33:22 +0300 Subject: [PATCH 1/2] =?UTF-8?q?-=20=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20-=20=D0=9F=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D1=82=D0=B5=D1=81=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...x24Accounts.Entity.Bitrix24Account.dcm.xml | 8 +-- .../Entity/Bitrix24Account.php | 60 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml b/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml index 7204f98..605d064 100644 --- a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml +++ b/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml @@ -2,9 +2,7 @@ xmlns:xs="https://www.w3.org/2001/XMLSchema" xmlns:orm="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - - - + @@ -14,10 +12,12 @@ - + + + diff --git a/src/Bitrix24Accounts/Entity/Bitrix24Account.php b/src/Bitrix24Accounts/Entity/Bitrix24Account.php index 1de7dc3..3d33815 100644 --- a/src/Bitrix24Accounts/Entity/Bitrix24Account.php +++ b/src/Bitrix24Accounts/Entity/Bitrix24Account.php @@ -62,23 +62,23 @@ class Bitrix24Account implements Bitrix24AccountInterface, AggregateRootEventsEm public function __construct( #[ORM\Id] #[ORM\Column(type: UuidType::NAME, unique: true)] - private Uuid $uuid, + private Uuid $id, #[ORM\Column(name: 'b24_user_id', type: 'integer', nullable: false)] #[SerializedName('b24_user_id')] private readonly int $bitrix24UserId, #[ORM\Column(name: 'is_b24_user_admin', type: 'boolean', nullable: false)] #[SerializedName('is_b24_user_admin')] - private readonly bool $isBitrix24UserAdmin, + private readonly bool $isBitrix24UserAdmin, /** bitrix24 portal unique id */ #[ORM\Column(name: 'member_id', type: 'string', nullable: false)] #[SerializedName('member_id')] - private readonly string $memberId, + private readonly string $memberId, #[ORM\Column(name: 'domain_url', type: 'string', nullable: false)] #[SerializedName('domain_url')] private string $domainUrl, #[ORM\Column(name: 'account_status', type: 'string', nullable: false, enumType: Bitrix24AccountStatus::class)] - private Bitrix24AccountStatus $accountStatus, - AuthToken $authToken, + private Bitrix24AccountStatus $status, + AuthToken $authToken, #[ORM\Column(name: 'created_at_utc', type: 'carbon_immutable', precision: 3, nullable: false)] #[Ignore] private readonly CarbonImmutable $createdAt, @@ -101,7 +101,7 @@ public function __construct( #[Override] public function getId(): Uuid { - return $this->uuid; + return $this->id; } #[Override] @@ -131,7 +131,7 @@ public function getDomainUrl(): string #[Override] public function getStatus(): Bitrix24AccountStatus { - return $this->accountStatus; + return $this->status; } #[Override] @@ -151,7 +151,7 @@ public function renewAuthToken(RenewedAuthToken $renewedAuthToken): void sprintf( 'member id %s for bitrix24 account %s for domain %s mismatch with member id %s for renewed access token', $this->memberId, - $this->uuid->toRfc4122(), + $this->id->toRfc4122(), $this->domainUrl, $renewedAuthToken->memberId, ) @@ -189,13 +189,13 @@ public function changeDomainUrl(string $newDomainUrl): void throw new InvalidArgumentException('new domain url cannot be empty'); } - if (Bitrix24AccountStatus::blocked === $this->accountStatus || Bitrix24AccountStatus::deleted === $this->accountStatus) { + if (Bitrix24AccountStatus::blocked === $this->status || Bitrix24AccountStatus::deleted === $this->status) { throw new InvalidArgumentException( sprintf( 'bitrix24 account %s for domain %s must be in active or new state, now account in %s state. domain url cannot be changed', - $this->uuid->toRfc4122(), + $this->id->toRfc4122(), $this->domainUrl, - $this->accountStatus->name + $this->status->name ) ); } @@ -203,7 +203,7 @@ public function changeDomainUrl(string $newDomainUrl): void $this->domainUrl = $newDomainUrl; $this->updatedAt = new CarbonImmutable(); $this->events[] = new Bitrix24AccountDomainUrlChangedEvent( - $this->uuid, + $this->id, new CarbonImmutable() ); } @@ -214,21 +214,21 @@ public function changeDomainUrl(string $newDomainUrl): void #[Override] public function applicationInstalled(string $applicationToken): void { - if (Bitrix24AccountStatus::new !== $this->accountStatus) { + if (Bitrix24AccountStatus::new !== $this->status) { throw new InvalidArgumentException(sprintf( 'for finish installation bitrix24 account must be in status «new», current status - «%s»', - $this->accountStatus->name)); + $this->status->name)); } if ($applicationToken === '') { throw new InvalidArgumentException('application token cannot be empty'); } - $this->accountStatus = Bitrix24AccountStatus::active; + $this->status = Bitrix24AccountStatus::active; $this->applicationToken = $applicationToken; $this->updatedAt = new CarbonImmutable(); $this->events[] = new Bitrix24AccountApplicationInstalledEvent( - $this->uuid, + $this->id, new CarbonImmutable() ); } @@ -243,10 +243,10 @@ public function applicationUninstalled(string $applicationToken): void throw new InvalidArgumentException('application token cannot be empty'); } - if (Bitrix24AccountStatus::active !== $this->accountStatus) { + if (Bitrix24AccountStatus::active !== $this->status) { throw new InvalidArgumentException(sprintf( 'for uninstall account must be in status «active», current status - «%s»', - $this->accountStatus->name)); + $this->status->name)); } if ($this->applicationToken !== $applicationToken) { @@ -255,16 +255,16 @@ public function applicationUninstalled(string $applicationToken): void 'application token «%s» mismatch with application token «%s» for bitrix24 account %s for domain %s', $applicationToken, $this->applicationToken, - $this->uuid->toRfc4122(), + $this->id->toRfc4122(), $this->domainUrl ) ); } - $this->accountStatus = Bitrix24AccountStatus::deleted; + $this->status = Bitrix24AccountStatus::deleted; $this->updatedAt = new CarbonImmutable(); $this->events[] = new Bitrix24AccountApplicationUninstalledEvent( - $this->uuid, + $this->id, new CarbonImmutable() ); } @@ -293,8 +293,8 @@ public function getUpdatedAt(): CarbonImmutable #[Override] public function updateApplicationVersion(int $version, ?Scope $newScope): void { - if (Bitrix24AccountStatus::active !== $this->accountStatus) { - throw new InvalidArgumentException(sprintf('account must be in status «active», but now account in status «%s»', $this->accountStatus->name)); + if (Bitrix24AccountStatus::active !== $this->status) { + throw new InvalidArgumentException(sprintf('account must be in status «active», but now account in status «%s»', $this->status->name)); } if ($this->applicationVersion >= $version) { @@ -311,7 +311,7 @@ public function updateApplicationVersion(int $version, ?Scope $newScope): void $this->updatedAt = new CarbonImmutable(); $this->events[] = new Bitrix24AccountApplicationVersionUpdatedEvent( - $this->uuid, + $this->id, new CarbonImmutable() ); } @@ -322,13 +322,13 @@ public function updateApplicationVersion(int $version, ?Scope $newScope): void #[Override] public function markAsActive(?string $comment): void { - if (Bitrix24AccountStatus::blocked !== $this->accountStatus) { + if (Bitrix24AccountStatus::blocked !== $this->status) { throw new InvalidArgumentException( sprintf('you can activate account only in status blocked, now account in status %s', - $this->accountStatus->name)); + $this->status->name)); } - $this->accountStatus = Bitrix24AccountStatus::active; + $this->status = Bitrix24AccountStatus::active; $this->comment = $comment; $this->updatedAt = new CarbonImmutable(); } @@ -339,15 +339,15 @@ public function markAsActive(?string $comment): void #[Override] public function markAsBlocked(?string $comment): void { - if (Bitrix24AccountStatus::deleted === $this->accountStatus) { + if (Bitrix24AccountStatus::deleted === $this->status) { throw new InvalidArgumentException('you cannot block account in status «deleted»'); } - $this->accountStatus = Bitrix24AccountStatus::blocked; + $this->status = Bitrix24AccountStatus::blocked; $this->comment = $comment; $this->updatedAt = new CarbonImmutable(); $this->events[] = new Bitrix24AccountBlockedEvent( - $this->uuid, + $this->id, new CarbonImmutable() ); } From 0d169d35c2e1b7598fd4b7d85a65673243c30bad Mon Sep 17 00:00:00 2001 From: KarlsonComplete Date: Mon, 4 Nov 2024 18:00:12 +0300 Subject: [PATCH 2/2] =?UTF-8?q?-=20=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B8=D0=BF=20=D0=B2=20=D0=BC=D0=B0=D0=BF=D0=BF?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3=D0=B5=20=D1=81=20datetime=5Fimmutable=20?= =?UTF-8?q?=D0=BD=D0=B0=20carbon=5Fimmutable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml b/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml index 605d064..0d19a83 100644 --- a/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml +++ b/config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.Bitrix24Account.dcm.xml @@ -3,9 +3,11 @@ xmlns:orm="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + @@ -14,16 +16,16 @@ - - - + - + + + \ No newline at end of file