Add Allegro shipment service and related components
- Implement AllegroShipmentService for managing shipment creation and status checks. - Create ShipmentController to handle shipment preparation and label downloading. - Introduce ShipmentPackageRepository for database interactions related to shipment packages. - Add methods for retrieving delivery services, creating shipments, checking creation status, and downloading labels. - Implement address validation and token management for Allegro API integration.
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Modules\Auth\AuthMiddleware;
|
||||
use App\Modules\Cron\CronRepository;
|
||||
use App\Modules\Orders\OrdersController;
|
||||
use App\Modules\Orders\OrderImportRepository;
|
||||
use App\Modules\Orders\OrdersRepository;
|
||||
use App\Modules\Settings\AllegroApiClient;
|
||||
use App\Modules\Settings\AllegroIntegrationController;
|
||||
use App\Modules\Settings\AllegroIntegrationRepository;
|
||||
@@ -16,8 +17,18 @@ use App\Modules\Settings\AllegroOAuthClient;
|
||||
use App\Modules\Settings\AllegroOrderImportService;
|
||||
use App\Modules\Settings\AllegroStatusDiscoveryService;
|
||||
use App\Modules\Settings\AllegroStatusMappingRepository;
|
||||
use App\Modules\Settings\ApaczkaIntegrationController;
|
||||
use App\Modules\Settings\ApaczkaIntegrationRepository;
|
||||
use App\Modules\Settings\InpostIntegrationController;
|
||||
use App\Modules\Settings\InpostIntegrationRepository;
|
||||
use App\Modules\Settings\AllegroDeliveryMethodMappingRepository;
|
||||
use App\Modules\Settings\CompanySettingsController;
|
||||
use App\Modules\Settings\CompanySettingsRepository;
|
||||
use App\Modules\Settings\CronSettingsController;
|
||||
use App\Modules\Settings\SettingsController;
|
||||
use App\Modules\Shipments\AllegroShipmentService;
|
||||
use App\Modules\Shipments\ShipmentController;
|
||||
use App\Modules\Shipments\ShipmentPackageRepository;
|
||||
use App\Modules\Users\UsersController;
|
||||
|
||||
return static function (Application $app): void {
|
||||
@@ -35,6 +46,7 @@ return static function (Application $app): void {
|
||||
(string) $app->config('app.integrations.secret', '')
|
||||
);
|
||||
$allegroStatusMappingRepository = new AllegroStatusMappingRepository($app->db());
|
||||
$allegroDeliveryMappingRepository = new AllegroDeliveryMethodMappingRepository($app->db());
|
||||
$allegroOAuthClient = new AllegroOAuthClient();
|
||||
$cronRepository = new CronRepository($app->db());
|
||||
$allegroIntegrationController = new AllegroIntegrationController(
|
||||
@@ -51,7 +63,8 @@ return static function (Application $app): void {
|
||||
$allegroOAuthClient,
|
||||
new AllegroApiClient(),
|
||||
new OrderImportRepository($app->db()),
|
||||
$allegroStatusMappingRepository
|
||||
$allegroStatusMappingRepository,
|
||||
new OrdersRepository($app->db())
|
||||
),
|
||||
new AllegroStatusDiscoveryService(
|
||||
$allegroIntegrationRepository,
|
||||
@@ -59,7 +72,29 @@ return static function (Application $app): void {
|
||||
new AllegroApiClient(),
|
||||
$allegroStatusMappingRepository
|
||||
),
|
||||
(string) $app->config('app.url', '')
|
||||
(string) $app->config('app.url', ''),
|
||||
$allegroDeliveryMappingRepository,
|
||||
new AllegroApiClient()
|
||||
);
|
||||
$apaczkaIntegrationRepository = new ApaczkaIntegrationRepository(
|
||||
$app->db(),
|
||||
(string) $app->config('app.integrations.secret', '')
|
||||
);
|
||||
$apaczkaIntegrationController = new ApaczkaIntegrationController(
|
||||
$template,
|
||||
$translator,
|
||||
$auth,
|
||||
$apaczkaIntegrationRepository
|
||||
);
|
||||
$inpostIntegrationRepository = new InpostIntegrationRepository(
|
||||
$app->db(),
|
||||
(string) $app->config('app.integrations.secret', '')
|
||||
);
|
||||
$inpostIntegrationController = new InpostIntegrationController(
|
||||
$template,
|
||||
$translator,
|
||||
$auth,
|
||||
$inpostIntegrationRepository
|
||||
);
|
||||
$cronSettingsController = new CronSettingsController(
|
||||
$template,
|
||||
@@ -69,6 +104,34 @@ return static function (Application $app): void {
|
||||
(bool) $app->config('app.cron.run_on_web_default', false),
|
||||
(int) $app->config('app.cron.web_limit_default', 5)
|
||||
);
|
||||
$companySettingsRepository = new CompanySettingsRepository($app->db());
|
||||
$companySettingsController = new CompanySettingsController(
|
||||
$template,
|
||||
$translator,
|
||||
$auth,
|
||||
$companySettingsRepository
|
||||
);
|
||||
$allegroApiClient = new AllegroApiClient();
|
||||
$shipmentPackageRepository = new ShipmentPackageRepository($app->db());
|
||||
$shipmentService = new AllegroShipmentService(
|
||||
$allegroIntegrationRepository,
|
||||
$allegroOAuthClient,
|
||||
$allegroApiClient,
|
||||
$shipmentPackageRepository,
|
||||
$companySettingsRepository,
|
||||
new OrdersRepository($app->db())
|
||||
);
|
||||
$shipmentController = new ShipmentController(
|
||||
$template,
|
||||
$translator,
|
||||
$auth,
|
||||
$app->orders(),
|
||||
$companySettingsRepository,
|
||||
$shipmentService,
|
||||
$shipmentPackageRepository,
|
||||
$app->basePath('storage'),
|
||||
new AllegroDeliveryMethodMappingRepository($app->db())
|
||||
);
|
||||
$authMiddleware = new AuthMiddleware($auth);
|
||||
|
||||
$router->get('/health', static fn (Request $request): Response => Response::json([
|
||||
@@ -91,6 +154,7 @@ return static function (Application $app): void {
|
||||
$router->get('/orders', static fn (Request $request): Response => Response::redirect('/orders/list'), [$authMiddleware]);
|
||||
$router->get('/orders/list', [$ordersController, 'index'], [$authMiddleware]);
|
||||
$router->get('/orders/{id}', [$ordersController, 'show'], [$authMiddleware]);
|
||||
$router->post('/orders/{id}/status', [$ordersController, 'updateStatus'], [$authMiddleware]);
|
||||
$router->post('/users', [$usersController, 'store'], [$authMiddleware]);
|
||||
$router->get('/settings/users', [$usersController, 'index'], [$authMiddleware]);
|
||||
$router->post('/settings/users', [$usersController, 'store'], [$authMiddleware]);
|
||||
@@ -117,5 +181,16 @@ return static function (Application $app): void {
|
||||
$router->post('/settings/integrations/allegro/statuses/save-bulk', [$allegroIntegrationController, 'saveStatusMappingsBulk'], [$authMiddleware]);
|
||||
$router->post('/settings/integrations/allegro/statuses/delete', [$allegroIntegrationController, 'deleteStatusMapping'], [$authMiddleware]);
|
||||
$router->post('/settings/integrations/allegro/statuses/sync', [$allegroIntegrationController, 'syncStatusesFromAllegro'], [$authMiddleware]);
|
||||
$router->post('/settings/integrations/allegro/delivery/save', [$allegroIntegrationController, 'saveDeliveryMappings'], [$authMiddleware]);
|
||||
$router->get('/settings/integrations/allegro/oauth/callback', [$allegroIntegrationController, 'oauthCallback']);
|
||||
$router->get('/settings/integrations/apaczka', [$apaczkaIntegrationController, 'index'], [$authMiddleware]);
|
||||
$router->post('/settings/integrations/apaczka/save', [$apaczkaIntegrationController, 'save'], [$authMiddleware]);
|
||||
$router->get('/settings/integrations/inpost', [$inpostIntegrationController, 'index'], [$authMiddleware]);
|
||||
$router->post('/settings/integrations/inpost/save', [$inpostIntegrationController, 'save'], [$authMiddleware]);
|
||||
$router->get('/settings/company', [$companySettingsController, 'index'], [$authMiddleware]);
|
||||
$router->post('/settings/company/save', [$companySettingsController, 'save'], [$authMiddleware]);
|
||||
$router->get('/orders/{id}/shipment/prepare', [$shipmentController, 'prepare'], [$authMiddleware]);
|
||||
$router->post('/orders/{id}/shipment/create', [$shipmentController, 'create'], [$authMiddleware]);
|
||||
$router->get('/orders/{id}/shipment/{packageId}/status', [$shipmentController, 'checkStatus'], [$authMiddleware]);
|
||||
$router->post('/orders/{id}/shipment/{packageId}/label', [$shipmentController, 'label'], [$authMiddleware]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user