This repository has been archived by the owner on Feb 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into release/v0.6.0
- Loading branch information
Showing
7 changed files
with
324 additions
and
1 deletion.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
module/notification/src/Application/Controller/Api/NotificationCheckAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Bold Brand Commerce Sp. z o.o. All rights reserved. | ||
* See LICENSE.txt for license details. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Ergonode\Notification\Application\Controller\Api; | ||
|
||
use Ergonode\Account\Infrastructure\Provider\AuthenticatedUserProviderInterface; | ||
use Ergonode\Api\Application\Response\SuccessResponse; | ||
use Ergonode\Notification\Domain\Query\NotificationQueryInterface; | ||
use Swagger\Annotations as SWG; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
/** | ||
* @Route("/profile/notifications/check", methods={"GET"}) | ||
*/ | ||
class NotificationCheckAction | ||
{ | ||
/** | ||
* @var NotificationQueryInterface | ||
*/ | ||
private $query; | ||
|
||
/** | ||
* @var AuthenticatedUserProviderInterface | ||
*/ | ||
private $userProvider; | ||
|
||
/** | ||
* @param NotificationQueryInterface $query | ||
* @param AuthenticatedUserProviderInterface $userProvider | ||
*/ | ||
public function __construct(NotificationQueryInterface $query, AuthenticatedUserProviderInterface $userProvider) | ||
{ | ||
$this->query = $query; | ||
$this->userProvider = $userProvider; | ||
} | ||
|
||
/** | ||
* @SWG\Tag(name="Profile") | ||
* @SWG\Parameter( | ||
* name="language", | ||
* in="path", | ||
* type="string", | ||
* required=true, | ||
* default="EN", | ||
* description="Language Code", | ||
* ) | ||
* @SWG\Response( | ||
* response=200, | ||
* description="Returns notification information for current user", | ||
* ) | ||
* | ||
* @return Response | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function __invoke(): Response | ||
{ | ||
$user = $this->userProvider->provide(); | ||
$result = $this->query->check($user->getId()); | ||
|
||
return new SuccessResponse($result); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
module/notification/src/Application/Controller/Api/NotificationMarkUpdateAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Bold Brand Commerce Sp. z o.o. All rights reserved. | ||
* See LICENSE.txt for license details. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Ergonode\Notification\Application\Controller\Api; | ||
|
||
use Ergonode\Account\Infrastructure\Provider\AuthenticatedUserProviderInterface; | ||
use Ergonode\Api\Application\Response\AcceptedResponse; | ||
use Ergonode\Api\Application\Response\SuccessResponse; | ||
use Ergonode\EventSourcing\Infrastructure\Bus\CommandBusInterface; | ||
use Ergonode\Notification\Domain\Command\MarkNotificationCommand; | ||
use Ramsey\Uuid\Uuid; | ||
use Swagger\Annotations as SWG; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
/** | ||
* @Route("/profile/notifications/{notification}/mark", methods={"POST"}) | ||
*/ | ||
class NotificationMarkUpdateAction | ||
{ | ||
/** | ||
* @var AuthenticatedUserProviderInterface | ||
*/ | ||
private $userProvider; | ||
|
||
/** | ||
* @var CommandBusInterface | ||
*/ | ||
private $commandBud; | ||
|
||
/** | ||
* @param AuthenticatedUserProviderInterface $userProvider | ||
* @param CommandBusInterface $commandBud | ||
*/ | ||
public function __construct(AuthenticatedUserProviderInterface $userProvider, CommandBusInterface $commandBud) | ||
{ | ||
$this->userProvider = $userProvider; | ||
$this->commandBud = $commandBud; | ||
} | ||
|
||
/** | ||
* @SWG\Tag(name="Profile") | ||
* @SWG\Parameter( | ||
* name="language", | ||
* in="path", | ||
* type="string", | ||
* required=true, | ||
* default="EN", | ||
* description="Language Code", | ||
* ) | ||
* @SWG\Parameter( | ||
* name="notification", | ||
* in="path", | ||
* type="string", | ||
* description="Notification id", | ||
* ) | ||
* @SWG\Response( | ||
* response=200, | ||
* description="Returns notifications", | ||
* ) | ||
* | ||
* @param string $notification | ||
* | ||
* @return Response | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function __invoke(string $notification): Response | ||
{ | ||
$user = $this->userProvider->provide(); | ||
$command = new MarkNotificationCommand(Uuid::fromString($notification), $user->getId(), new \DateTime()); | ||
|
||
$this->commandBud->dispatch($command); | ||
|
||
return new AcceptedResponse(); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
module/notification/src/Domain/Command/MarkNotificationCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Bold Brand Commerce Sp. z o.o. All rights reserved. | ||
* See LICENSE.txt for license details. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Ergonode\Notification\Domain\Command; | ||
|
||
use Ergonode\Account\Domain\Entity\UserId; | ||
use Ergonode\EventSourcing\Infrastructure\DomainCommandInterface; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
/** | ||
*/ | ||
class MarkNotificationCommand implements DomainCommandInterface | ||
{ | ||
/** | ||
* @var Uuid | ||
*/ | ||
private $notificationId; | ||
|
||
/** | ||
* @var UserId | ||
*/ | ||
private $userId; | ||
|
||
/** | ||
* @var \DateTime | ||
*/ | ||
private $readAt; | ||
|
||
/** | ||
* @param Uuid $notificationId | ||
* @param UserId $userId | ||
* @param \DateTime $readAt | ||
*/ | ||
public function __construct(Uuid $notificationId, UserId $userId, \DateTime $readAt) | ||
{ | ||
$this->notificationId = $notificationId; | ||
$this->userId = $userId; | ||
$this->readAt = $readAt; | ||
} | ||
|
||
/** | ||
* @return Uuid | ||
*/ | ||
public function getNotificationId(): Uuid | ||
{ | ||
return $this->notificationId; | ||
} | ||
|
||
/** | ||
* @return UserId | ||
*/ | ||
public function getUserId(): UserId | ||
{ | ||
return $this->userId; | ||
} | ||
|
||
/** | ||
* @return \DateTime | ||
*/ | ||
public function getReadAt(): \DateTime | ||
{ | ||
return $this->readAt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
module/notification/src/Infrastructure/Handler/MarkNotificationCommandHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Copyright © Bold Brand Commerce Sp. z o.o. All rights reserved. | ||
* See LICENSE.txt for license details. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Ergonode\Notification\Infrastructure\Handler; | ||
|
||
use Ergonode\Notification\Domain\Command\MarkNotificationCommand; | ||
use Ergonode\Notification\Domain\Query\NotificationQueryInterface; | ||
use Ergonode\Notification\Infrastructure\Sender\NotificationMarker; | ||
|
||
/** | ||
*/ | ||
class MarkNotificationCommandHandler | ||
{ | ||
/** | ||
* @var NotificationQueryInterface | ||
*/ | ||
private $query; | ||
|
||
/** | ||
* @param NotificationQueryInterface $query | ||
*/ | ||
public function __construct(NotificationQueryInterface $query) | ||
{ | ||
$this->query = $query; | ||
} | ||
|
||
/** | ||
* @param MarkNotificationCommand $command | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function __invoke(MarkNotificationCommand $command) | ||
{ | ||
$this->query->mark($command->getNotificationId(), $command->getUserId(), $command->getReadAt()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters