-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FFWEB-2953: Add reporting for Shopware marketplace
Add reporting for Shopware marketplace
- Loading branch information
Showing
5 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omikron\FactFinder\Shopware6\ScheduledTask; | ||
|
||
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask; | ||
|
||
class MarketplaceReportTask extends ScheduledTask | ||
{ | ||
public static function getTaskName(): string | ||
{ | ||
return 'factfinder.marketplace_report_task'; | ||
} | ||
|
||
public static function getDefaultInterval(): int | ||
{ | ||
return 2592000; // 1 month in seconds | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omikron\FactFinder\Shopware6\ScheduledTask; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Request; | ||
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; | ||
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; | ||
use Symfony\Component\Messenger\Attribute\AsMessageHandler; | ||
|
||
#[AsMessageHandler(handles: MarketplaceReportTask::class)] | ||
class MarketplaceReportTaskHandler extends ScheduledTaskHandler | ||
{ | ||
public const API_IDENTIFIER = 'd7ae3439-1a5c-45bd-b5ca-172b42511c7f'; | ||
private Client $client; | ||
|
||
public function __construct( | ||
EntityRepository $scheduledTaskRepository, | ||
private readonly string $shopwareVersion, | ||
private readonly ?string $instanceId | ||
) { | ||
parent::__construct($scheduledTaskRepository); | ||
$this->client = new Client(); | ||
} | ||
|
||
public static function getHandledMessages(): iterable | ||
{ | ||
return [MarketplaceReportTask::class]; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
public function run(): void | ||
{ | ||
$now = new \DateTime(); | ||
$data = [ | ||
'identifier' => self::API_IDENTIFIER, | ||
'reportDate' => $now->format(\DateTimeInterface::ATOM), | ||
'instanceId' => $this->instanceId, | ||
'shopwareVersion' => $this->shopwareVersion, | ||
'reportDataKeys' => [ | ||
'numberOfSubscriptions' => 0, | ||
'numberOfCustomers' => 1, | ||
], | ||
]; | ||
$request = new Request( | ||
'POST', | ||
'https://api.shopware.com/shopwarepartners/reports/technology', | ||
[], | ||
json_encode($data) | ||
); | ||
$this->client->send($request); | ||
} | ||
} |