70 lines
2.4 KiB
PHP
70 lines
2.4 KiB
PHP
<?php
|
|
namespace admin\factory;
|
|
|
|
/**
|
|
* Fasada kompatybilnosci wstecznej.
|
|
* Deleguje do Domain\Integrations\IntegrationsRepository.
|
|
* Uzywane przez: cron.php, shop\Order, admin\Controllers\ShopStatusesController, admin\controls\ShopTransport, admin\controls\ShopProduct, admin\Controllers\ShopPaymentMethodController.
|
|
*/
|
|
class Integrations {
|
|
|
|
private static function repo(): \Domain\Integrations\IntegrationsRepository
|
|
{
|
|
global $mdb;
|
|
return new \Domain\Integrations\IntegrationsRepository( $mdb );
|
|
}
|
|
|
|
// ── Apilo settings ──────────────────────────────────────────
|
|
|
|
static public function apilo_settings( $name = '' )
|
|
{
|
|
$repo = self::repo();
|
|
return $name ? $repo->getSetting( 'apilo', $name ) : $repo->getSettings( 'apilo' );
|
|
}
|
|
|
|
static public function apilo_settings_save( $field_id, $value )
|
|
{
|
|
return self::repo()->saveSetting( 'apilo', $field_id, $value );
|
|
}
|
|
|
|
static public function apilo_get_access_token()
|
|
{
|
|
return self::repo()->apiloGetAccessToken();
|
|
}
|
|
|
|
static public function apilo_keepalive( int $refresh_lead_seconds = 300 )
|
|
{
|
|
return self::repo()->apiloKeepalive( $refresh_lead_seconds );
|
|
}
|
|
|
|
static public function apilo_authorization( $client_id, $client_secret, $authorization_code )
|
|
{
|
|
return self::repo()->apiloAuthorize( $client_id, $client_secret, $authorization_code );
|
|
}
|
|
|
|
// ── Apilo product linking ─────────────────────────────────────
|
|
|
|
static public function apilo_product_select_save( int $product_id, $apilo_product_id, $apilo_product_name )
|
|
{
|
|
return self::repo()->linkProduct( $product_id, $apilo_product_id, $apilo_product_name );
|
|
}
|
|
|
|
static public function apilo_product_select_delete( int $product_id )
|
|
{
|
|
return self::repo()->unlinkProduct( $product_id );
|
|
}
|
|
|
|
// ── ShopPRO settings ──────────────────────────────────────────
|
|
|
|
static public function shoppro_settings( $name = '' )
|
|
{
|
|
$repo = self::repo();
|
|
return $name ? $repo->getSetting( 'shoppro', $name ) : $repo->getSettings( 'shoppro' );
|
|
}
|
|
|
|
static public function shoppro_settings_save( $field_id, $value )
|
|
{
|
|
return self::repo()->saveSetting( 'shoppro', $field_id, $value );
|
|
}
|
|
}
|