refactor: wydzielenie ApiloRepository z IntegrationsRepository
IntegrationsRepository zredukowany z ~875 do ~340 linii. Nowa klasa ApiloRepository przejmuje 19 metod apilo*. Konsumenci (IntegrationsController, OrderAdminService, cron.php) zaktualizowani przez DI. Suite: 818 testów, 2275 asercji. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
11
cron.php
11
cron.php
@@ -131,6 +131,7 @@ function getImageUrlById($id) {
|
||||
|
||||
$settings = ( new \Domain\Settings\SettingsRepository( $mdb ) )->allSettings();
|
||||
$integrationsRepository = new \Domain\Integrations\IntegrationsRepository( $mdb );
|
||||
$apiloRepository = new \Domain\Integrations\ApiloRepository( $mdb );
|
||||
$orderRepo = new \Domain\Order\OrderRepository( $mdb );
|
||||
$cronRepo = new \Domain\CronJob\CronJobRepository( $mdb );
|
||||
$orderAdminService = new \Domain\Order\OrderAdminService( $orderRepo, null, null, null, $cronRepo );
|
||||
@@ -188,7 +189,7 @@ $processor->registerHandler( \Domain\CronJob\CronJobType::APILO_TOKEN_KEEPALIVE,
|
||||
$apilo_settings = $integrationsRepository->getSettings('apilo');
|
||||
if ( !(int)($apilo_settings['enabled'] ?? 0) ) return true; // skip if disabled
|
||||
|
||||
$integrationsRepository->apiloKeepalive( 300 );
|
||||
$apiloRepository->apiloKeepalive( 300 );
|
||||
echo '<p>Apilo token keepalive</p>';
|
||||
return true;
|
||||
});
|
||||
@@ -276,7 +277,7 @@ $processor->registerHandler( \Domain\CronJob\CronJobType::APILO_SEND_ORDER, func
|
||||
continue;
|
||||
}
|
||||
|
||||
$access_token = $integrationsRepository->apiloGetAccessToken();
|
||||
$access_token = $apiloRepository->apiloGetAccessToken();
|
||||
$order_date = new DateTime( $order['date_order'] );
|
||||
$paczkomatData = parsePaczkomatAddress( $order['inpost_paczkomat'] );
|
||||
$orlenPointData = parseOrlenAddress( $order['orlen_point'] );
|
||||
@@ -557,7 +558,7 @@ $processor->registerHandler( \Domain\CronJob\CronJobType::APILO_PRODUCT_SYNC, fu
|
||||
$result = $stmt ? $stmt->fetch( \PDO::FETCH_ASSOC ) : null;
|
||||
if ( !$result ) return true;
|
||||
|
||||
$access_token = $integrationsRepository->apiloGetAccessToken();
|
||||
$access_token = $apiloRepository->apiloGetAccessToken();
|
||||
$url = 'https://projectpro.apilo.com/rest/api/warehouse/product/' . $result['apilo_product_id'] . '/';
|
||||
$curl = curl_init( $url );
|
||||
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||
@@ -586,7 +587,7 @@ $processor->registerHandler( \Domain\CronJob\CronJobType::APILO_PRICELIST_SYNC,
|
||||
$apilo_settings = $integrationsRepository->getSettings('apilo');
|
||||
if ( !$apilo_settings['enabled'] || !$apilo_settings['access-token'] ) return true;
|
||||
|
||||
$access_token = $integrationsRepository->apiloGetAccessToken();
|
||||
$access_token = $apiloRepository->apiloGetAccessToken();
|
||||
$url = 'https://projectpro.apilo.com/rest/api/warehouse/price-calculated/?price=' . $apilo_settings['pricelist_id'];
|
||||
|
||||
$curl = curl_init( $url );
|
||||
@@ -639,7 +640,7 @@ $processor->registerHandler( \Domain\CronJob\CronJobType::APILO_STATUS_POLL, fun
|
||||
{
|
||||
if ( $order['apilo_order_id'] )
|
||||
{
|
||||
$access_token = $integrationsRepository->apiloGetAccessToken();
|
||||
$access_token = $apiloRepository->apiloGetAccessToken();
|
||||
$url = 'https://projectpro.apilo.com/rest/api/orders/' . $order['apilo_order_id'] . '/';
|
||||
|
||||
$ch = curl_init( $url );
|
||||
|
||||
Reference in New Issue
Block a user