/** * @param AccessTokenStruct $token * @param OrderRequest $context * @return BasketStruct */ public function getCheckout(AccessTokenStruct $token, OrderRequest $context) { $data = ['origin' => ['name' => 'Shopware Backend'], 'shopwareId' => $token->getShopwareId(), 'positions' => [['licenseShopDomain' => $context->getLicenceShop(), 'bookingShopDomain' => $context->getBookingShop(), 'orderNumber' => $context->getOrderNumber(), 'isArticle' => true, 'priceModel' => ['price' => $context->getPrice(), 'type' => $context->getPriceType()]]]]; $response = $this->storeClient->doAuthPostRequest($token, '/basket', $data); $basket = $this->hydrator->hydrateBasket($response); $basket->setLicenceDomain($context->getLicenceShop()); return $basket; }
/** * @param $plugins * @return \Shopware\Bundle\PluginInstallerBundle\Struct\PluginStruct[] */ private function iteratePlugins($plugins) { foreach ($plugins as &$row) { $row['iconPath'] = $this->getIconOfPlugin($row['source'], $row['namespace'], $row['name']); } return $this->hydrator->hydrateLocalPlugins($plugins); }
/** * Gets a list of locales supported by the SBP * * @return LocaleStruct[] array of locale details * @throws \Exception */ public function getLocales() { try { $responseBody = $this->storeClient->doGetRequest("/locales"); } catch (StoreException $se) { throw $this->translateExceptionMessage($se); } return $this->hydrator->hydrateLocales($responseBody); }
/** * Returns all categories, grouped by the parent id * @param string $locale * @param string $fallbackLocale * @return array */ private function getCategories($locale, $fallbackLocale) { $data = $this->getCategoryDataForLocale($locale); if (empty($data)) { $data = $this->getCategoryDataForLocale($fallbackLocale); } $result = []; foreach ($data as $key => $grouped) { $result[$key] = []; foreach ($grouped as $categoryData) { $result[$key][] = $this->hydrator->hydrateCategory($categoryData); } } return $result; }
/** * @param PluginStruct[] $plugins * @return PluginStruct[] */ private function getAdditionallyLocalData($plugins) { $context = new PluginsByTechnicalNameRequest(null, null, array_keys($plugins)); $local = $this->localPluginService->getPlugins($context); $merged = []; foreach ($plugins as &$plugin) { $key = strtolower($plugin->getTechnicalName()); if (!array_key_exists($key, $local)) { $merged[$key] = $plugin; continue; } $localPlugin = $local[$key]; $this->hydrator->assignLocalPluginStruct($plugin, $localPlugin); $merged[$key] = $plugin; } return $merged; }
/** * @return CategoryStruct[] * @throws \Exception */ public function getCategories() { $data = $this->storeClient->doGetRequest('/pluginStore/categories'); return $this->hydrator->hydrateCategories($data); }
/** * @param string $shopwareId * @param string $password * @return AccessTokenStruct * @throws \Exception */ public function getAccessToken($shopwareId, $password) { $response = $this->doPostRequest('/accesstokens', ['shopwareId' => $shopwareId, 'password' => $password]); return $this->structHydrator->hydrateAccessToken($response, $shopwareId); }