/** * Requests the validation of the current installation's domain * * @param string $domain * @param string $shopwareVersion Current Shopware version * @param AccessTokenStruct $token * @return array Result of the validation operation (empty if successful) * @throws \Exception */ public function verifyDomain($domain, $shopwareVersion, AccessTokenStruct $token) { $postData = ['shopwareId' => $token->getShopwareId(), 'domain' => $domain, 'shopwareVersion' => $shopwareVersion]; try { return $this->storeClient->doAuthPostRequest($token, "/domainverifications", $postData); } catch (StoreException $se) { throw $this->translateExceptionMessage($se); } }
/** * @param $resource * @param array $params * @param AccessTokenStruct $token * @return \Shopware\Components\HttpClient\Response * @throws StoreException * @throws \Exception */ private function postRequest($resource, $params = [], AccessTokenStruct $token = null) { $url = $this->apiEndPoint . $resource; $header = []; if ($token) { $header['X-Shopware-Token'] = $token->getToken(); } try { $response = $this->httpClient->post($url, $header, json_encode($params)); } catch (RequestException $e) { $this->handleRequestException($e); } return $response; }
/** * @param AccessTokenStruct $accessToken * @param OrderRequest $context * @throws \Exception * @return bool */ public function orderPlugin(AccessTokenStruct $accessToken, OrderRequest $context) { $data = ['origin' => ['name' => 'Shopware Backend'], 'shopwareId' => $accessToken->getShopwareId(), 'positions' => [['licenseShopDomain' => $context->getLicenceShop(), 'bookingShopDomain' => $context->getBookingShop(), 'orderNumber' => $context->getOrderNumber(), 'isArticle' => true, 'priceModel' => ['type' => $context->getPriceType(), 'price' => $context->getPrice()]]]]; $response = $this->storeClient->doAuthPostRequestRaw($accessToken, '/orders', $data); return $response->getStatusCode() == 204; }