Call shop service to execute code in shop.

@param string $serviceName
@param string $shopId

@example call to update information to database.

@throws \Exception

@return string $sResult
14995
public function callService($serviceName, $shopId = null)
    {
        $testConfig = $this->getTestConfig();
        if (!is_null($shopId) && $testConfig->getShopEdition() == 'EE') {
            $this->setParameter('shp', $shopId);
        } elseif ($testConfig->isSubShop()) {
            $this->setParameter('shp', $testConfig->getShopId());
        }

        if ($testConfig->getRemoteDirectory()) {
            $response = $this->callRemoteService($serviceName);
        } else {
            $this->callLocalService(ChangeExceptionLogRights::class);

            $response = $this->callLocalService($serviceName);
        }

        $this->parameters = array();

        return $response;
    }
552326
public function bindService($controllerName, $methodName, $argumentName, $serviceName)
    {
        $this->bindings[$controllerName][$methodName][$argumentName] = $serviceName;
        return $this;
    }
1199447
public function execute($paymentId)
    {
        $url    = $this->environment->getApiUrl() . '1/sales/' . $paymentId . '/' . $this->type;
        $params = [];

        if ($this->amount != null) {
            $params['amount'] = $this->amount;
        }

        if ($this->serviceTaxAmount != null) {
            $params['serviceTaxAmount'] = $this->serviceTaxAmount;
        }

        $url .= '?' . http_build_query($params);

        return $this->sendRequest('PUT', $url);
    }
770363
protected function callLocalService($serviceName)
    {
        if (!defined('TMP_PATH')) {
            define('TMP_PATH', $this->getTestConfig()->getTempDirectory());
        }

        $config = new ServiceConfig($this->getTestConfig()->getShopPath(), $this->getTestConfig()->getTempDirectory());
        $config->setShopEdition($this->getTestConfig()->getShopEdition());

        $serviceCaller = new ServiceFactory($config);
        $request = new Request($this->getParameters());
        $service = $serviceCaller->createService($serviceName);

        return $service->init($request);
    }
844592
public function switchToShop($shopId)
    {
        $_POST['shp'] = $shopId;
        $_POST['actshop'] = $shopId;
        $keepThese = [\OxidEsales\Eshop\Core\ConfigFile::class];
        $registryKeys = Registry::getKeys();
        foreach ($registryKeys as $key) {
            if (in_array($key, $keepThese)) {
                continue;
            }
            Registry::set($key, null);
        }
        $utilsObject = new \OxidEsales\Eshop\Core\UtilsObject;
        $utilsObject->resetInstanceCache();
        Registry::set(\OxidEsales\Eshop\Core\UtilsObject::class, $utilsObject);
        \OxidEsales\Eshop\Core\Module\ModuleVariablesLocator::resetModuleVariables();
        Registry::getSession()->setVariable('shp', $shopId);
        Registry::set(\OxidEsales\Eshop\Core\Config::class, null);
        Registry::getConfig()->setConfig(null);
        Registry::set(\OxidEsales\Eshop\Core\Config::class, null);
        $moduleVariablesCache = new \OxidEsales\Eshop\Core\FileCache();
        $shopIdCalculator = new \OxidEsales\Eshop\Core\ShopIdCalculator($moduleVariablesCache);
        return  $shopIdCalculator->getShopId();
    }
152714
public function execute($paymentId)
    {
        $url = $this->environment->getApiQueryURL() . '1/sales/' . $paymentId;

        return $this->sendRequest('GET', $url);
    }
899588
public function getVendors(
        DateTime $updatedSince = null,
        $paginate = false,
        $shopIds = array()
    ) {
        $this->restClient->getConfig()->setPath(
            'request.options/headers/Authorization',
            $this->operatorKey
        );
        $command = $this->restClient->getCommand(
            'GetVendors',
            array(
                'updatedSince' => $updatedSince,
                'paginate' => $paginate,
                'shopIds' => $shopIds,
            )
        );
        $result = $this->restClient->execute($command);

        return $result['shops'];
    }
419945
protected function _ExecuteCron()
    {
        $sQuery = "SELECT * FROM `shop_order_basket`
                         WHERE `shop_order_basket`.`processed` != '1'
                      ORDER BY `shop_order_basket`.`lastmodified` DESC";
        $oOrderBasketList = TdbShopOrderBasketList::GetList($sQuery);
        $sStatistics = "#########################################################\r\n";
        while ($oOrderBasket = $oOrderBasketList->Next()) {
            $sStatistics .= $this->GenerateStatisticsFromOrderBasket($oOrderBasket);
            $this->MarkOrderBasketAsProcessed($oOrderBasket);
            ++$this->sTotalBaskets;
        }
        if ($oOrderBasketList->Length() > 0) {
            $sTotalStatistics = $this->GetTotalStatistics().$sStatistics;
            $this->SendBasketStatistics($sTotalStatistics);
        }
    }
154506
public function queryShopWifi($shop_id = null, $pageindex = null, $pagesize = null)
    {
        $data = [];
        is_null($pagesize) || $data['pagesize'] = $pagesize;
        is_null($pageindex) || $data['pageindex'] = $pageindex;
        is_null($shop_id) || $data['shop_id'] = $shop_id;
        $url = 'https://api.weixin.qq.com/bizwifi/device/list?access_token=ACCESS_TOKEN';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
112640
public function extract(string $shopTransactionId)
    {
        $pieces = explode(self::SEPARTOR, $shopTransactionId);

        return (int) $pieces[0];
    }
847883
protected function failIfContainerNotFound(ServiceException $exception, $action, $containerName)
    {
        $errorCode = $this->getErrorCodeFromServiceException($exception);

        if ($errorCode === self::ERROR_CONTAINER_NOT_FOUND) {
            throw new \RuntimeException(sprintf(
                'Failed to %s: container "%s" not found.',
                $action,
                $containerName
            ), $exception->getCode());
        }
    }
454801
public function callService($serviceName, $action, array $parameters = array(), array $files = array())
    {
        $httpClient = $this->getHTTPClient();

        $url = $this->getServiceUrl($serviceName, $action);
        $request = new Request('POST', $url, $this->getRequestHeaders($url, $parameters), $this->getRequestBody($parameters, $files));

        try {
            $response = $httpClient->send($request);
        } catch (GuzzleRequestException $exception) {
            $response = $exception->getResponse();
        }

        $this->validateAPIResponseCode($request, $response);

        return $response;
    }
335620
public function getService($serviceName)
    {
        $serviceName = ltrim($serviceName, '@');
        if (!isset($this->registeredServices[$serviceName])) {
            throw new ServiceManagerException(ServiceManagerException::SERVICE_DEFINITION_NOT_FOUND, [$serviceName]);
        }

        // Instantiate new service or get existing service instance
        if (!isset($this->instantiatedServices[$serviceName])) {
            $service = $this->instantiateService($serviceName);
        } else {
            $service = $this->instantiatedServices[$serviceName];
        }

        return $service;
    }
1228175
public function updateOne($moduleName, $entityID, array $params)
    {
        if (!is_assoc_array($params)) {
            throw new WSException(
                "You have to specify at least one search parameter (prop => value) 
                in order to be able to update the entity(ies)"
            );
        }

        // Fail if no ID was supplied
        if (empty($entityID)) {
            throw new WSException("The list of contraints must contain a valid ID");
        }

        // Preprend so-called moduleid if needed
        $entityID = $this->wsClient->modules->getTypedID($moduleName, $entityID);

        // Check if the entity exists + retrieve its data so it can be used below
        $entityData = $this->findOneByID($moduleName, $entityID);
        if ($entityData === false && !is_array($entityData)) {
            throw new WSException("Such entity doesn't exist, so it cannot be updated");
        }

        // The new data overrides the existing one needed to provide
        // mandatory field values to WS 'update' operation
        $params = array_merge(
            $entityData,
            $params
        );

        $requestData = [
            'elementType' => $moduleName,
            'element'     => json_encode($params)
        ];

        return $this->wsClient->invokeOperation('update', $requestData);
    }
76347
protected function setActiveShop($shopId)
    {
        if ($shopId && $this->getServiceConfig()->getShopEdition() == 'EE') {
            \OxidEsales\Eshop\Core\Registry::getConfig()->setShopId($shopId);
        }
    }
957579
protected function _getOrderServiceItem( $baseid )
	{
		$orderServiceManager = MShop_Factory::createManager( $this->_getContext(), 'order/base/service' );

		$search = $orderServiceManager->createSearch();
		$expr = array(
			$search->compare( '==', 'order.base.service.baseid', $baseid ),
			$search->compare( '==', 'order.base.service.type', 'payment' )
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

		$results = $orderServiceManager->searchItems( $search );

		if ( ( $serviceItem = reset( $results ) ) === false )
		{
			$msg = sprintf( 'Service payment provider for order base ID "%1$s" not found', $baseid );
			throw new MShop_Service_Exception( $msg );
		}

		return $serviceItem;
	}
99356
public function getNextOxsort($shopId)
    {
        $query = "SELECT MAX(`oxsort`)+10 FROM `oxdiscount` WHERE `oxshopid` = ?";
        $nextSort = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->getOne($query, [$shopId]);

        return (int) $nextSort;
    }