= $e($t('settings.erli.import.description')) ?>
+ + += $e($t('settings.erli.test.description')) ?>
diff --git a/routes/web.php b/routes/web.php index 8f58f5a..f286413 100644 --- a/routes/web.php +++ b/routes/web.php @@ -32,6 +32,9 @@ use App\Modules\Settings\CarrierDeliveryMethodMappingRepository; use App\Modules\Settings\ErliApiClient; use App\Modules\Settings\ErliIntegrationController; use App\Modules\Settings\ErliIntegrationRepository; +use App\Modules\Settings\ErliOrderMapper; +use App\Modules\Settings\ErliOrderSyncStateRepository; +use App\Modules\Settings\ErliOrdersSyncService; use App\Modules\Settings\FakturowniaApiClient; use App\Modules\Settings\FakturowniaIntegrationController; use App\Modules\Settings\FakturowniaIntegrationRepository; @@ -236,14 +239,6 @@ return static function (Application $app): void { $app->db(), (string) $app->config('app.integrations.secret', '') ); - $erliIntegrationController = new ErliIntegrationController( - $template, - $translator, - $auth, - $erliIntegrationRepository, - new ErliApiClient(), - new IntegrationsRepository($app->db()) - ); $notificationRepository = new NotificationRepository($app->db()); $smsMessageRepository = new SmsMessageRepository($app->db()); $smsConversationService = new SmsConversationService( @@ -388,6 +383,25 @@ return static function (Application $app): void { $shipmentPackageRepositoryForOrders, $receiptService ); + $erliOrdersSyncService = new ErliOrdersSyncService( + $erliIntegrationRepository, + new ErliOrderSyncStateRepository($app->db()), + new ErliApiClient(), + new OrderImportRepository($app->db()), + new OrdersRepository($app->db()), + new ErliOrderMapper(), + $automationService + ); + $erliIntegrationController = new ErliIntegrationController( + $template, + $translator, + $auth, + $erliIntegrationRepository, + new ErliApiClient(), + new IntegrationsRepository($app->db()), + $cronRepository, + $erliOrdersSyncService + ); $allegroIntegrationController = new AllegroIntegrationController( $template, $translator, @@ -635,6 +649,7 @@ return static function (Application $app): void { $router->get('/settings/integrations/erli', [$erliIntegrationController, 'index'], [$authMiddleware]); $router->post('/settings/integrations/erli/save', [$erliIntegrationController, 'save'], [$authMiddleware]); $router->post('/settings/integrations/erli/test', [$erliIntegrationController, 'test'], [$authMiddleware]); + $router->post('/settings/integrations/erli/import', [$erliIntegrationController, 'importNow'], [$authMiddleware]); $router->get('/settings/integrations/shoppro', [$shopproIntegrationsController, 'index'], [$authMiddleware]); $router->post('/settings/integrations/shoppro/save', [$shopproIntegrationsController, 'save'], [$authMiddleware]); $router->post('/settings/integrations/shoppro/test', [$shopproIntegrationsController, 'test'], [$authMiddleware]); diff --git a/src/Core/Constants/IntegrationSources.php b/src/Core/Constants/IntegrationSources.php index f593dcd..8af1cfe 100644 --- a/src/Core/Constants/IntegrationSources.php +++ b/src/Core/Constants/IntegrationSources.php @@ -8,6 +8,7 @@ final class IntegrationSources { public const ALLEGRO = 'allegro'; public const SHOPPRO = 'shoppro'; + public const ERLI = 'erli'; public const APACZKA = 'apaczka'; public const INPOST = 'inpost'; } diff --git a/src/Modules/Cron/CronHandlerFactory.php b/src/Modules/Cron/CronHandlerFactory.php index 7bd7a09..5291abf 100644 --- a/src/Modules/Cron/CronHandlerFactory.php +++ b/src/Modules/Cron/CronHandlerFactory.php @@ -33,6 +33,11 @@ use App\Modules\Settings\ApaczkaIntegrationRepository; use App\Modules\Settings\CompanySettingsRepository; use App\Modules\Settings\EmailMailboxRepository; use App\Modules\Settings\EmailTemplateRepository; +use App\Modules\Settings\ErliApiClient; +use App\Modules\Settings\ErliIntegrationRepository; +use App\Modules\Settings\ErliOrderMapper; +use App\Modules\Settings\ErliOrderSyncStateRepository; +use App\Modules\Settings\ErliOrdersSyncService; use App\Modules\Settings\InpostIntegrationRepository; use App\Modules\Settings\IntegrationSecretCipher; use App\Modules\Settings\ReceiptConfigRepository; @@ -128,6 +133,15 @@ final class CronHandlerFactory $this->db, $automationService ); + $erliOrdersSyncService = new ErliOrdersSyncService( + new ErliIntegrationRepository($this->db, $this->integrationSecret), + new ErliOrderSyncStateRepository($this->db), + new ErliApiClient(), + new OrderImportRepository($this->db), + $ordersRepository, + new ErliOrderMapper(), + $automationService + ); return new CronRunner( $cronRepository, @@ -161,6 +175,9 @@ final class CronHandlerFactory 'shoppro_payment_status_sync' => new ShopproPaymentStatusSyncHandler( $shopproPaymentSyncService ), + 'erli_orders_import' => new ErliOrdersImportHandler( + $erliOrdersSyncService + ), 'shipment_tracking_sync' => new ShipmentTrackingHandler( new ShipmentTrackingRegistry([ new InpostTrackingService( diff --git a/src/Modules/Cron/ErliOrdersImportHandler.php b/src/Modules/Cron/ErliOrdersImportHandler.php new file mode 100644 index 0000000..7f99b23 --- /dev/null +++ b/src/Modules/Cron/ErliOrdersImportHandler.php @@ -0,0 +1,24 @@ + $payload + * @return array