Example #1
0
 /**
  * Sets the response body to ProductName/Major.MinorVersion (Edition). E.g.: Magento/0.42 (Community). Omits patch
  * version from response
  *
  * @return void
  */
 public function execute()
 {
     $versionParts = explode('.', $this->productMetadata->getVersion());
     if (!isset($versionParts[0]) || !isset($versionParts[1])) {
         return;
         // Major and minor version are not set - return empty response
     }
     $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
     $this->getResponse()->setBody($this->productMetadata->getName() . '/' . $majorMinorVersion . ' (' . $this->productMetadata->getEdition() . ')');
 }
Example #2
0
    /**
     * Retrieve feed data as XML element
     *
     * @return \SimpleXMLElement
     */
    public function getFeedData()
    {
        $curl = $this->curlFactory->create();
        $curl->setConfig(
            [
                'timeout'   => 2,
                'useragent' => $this->productMetadata->getName()
                    . '/' . $this->productMetadata->getVersion()
                    . ' (' . $this->productMetadata->getEdition() . ')',
                'referer'   => $this->urlBuilder->getUrl('*/*/*')
            ]
        );
        $curl->write(\Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
        $data = $curl->read();
        if ($data === false) {
            return false;
        }
        $data = preg_split('/^\r?$/m', $data, 2);
        $data = trim($data[1]);
        $curl->close();

        try {
            $xml = new \SimpleXMLElement($data);
        } catch (\Exception $e) {
            return false;
        }

        return $xml;
    }
Example #3
0
 /**
  * Get the 'Info' section data
  *
  * @return string[]
  */
 protected function getGeneralInfo()
 {
     $versionParts = explode('.', $this->productMetadata->getVersion());
     if (!isset($versionParts[0]) || !isset($versionParts[1])) {
         return [];
         // Major and minor version are not set - return empty response
     }
     $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
     return ['version' => $majorMinorVersion, 'title' => $this->productMetadata->getName() . ' ' . $this->productMetadata->getEdition()];
 }
 public function getExpectedCommonData()
 {
     $versionParts = explode('.', $this->productMetadata->getVersion());
     if (!isset($versionParts[0]) || !isset($versionParts[1])) {
         return [];
         // Major and minor version are not set - return empty response
     }
     $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
     $url = str_replace('://', '', strstr($this->baseUrl, '://'));
     $host = strpos($url, '/') ? strstr($url, '/', true) : $url;
     $basePath = strstr(rtrim($url, '/'), '/');
     $basePath = $basePath ? trim($basePath, '/') . '/' : '';
     $basePath = '/' . $basePath . 'rest/' . $this->storeCode;
     return ['swagger' => '2.0', 'info' => ['version' => $majorMinorVersion, 'title' => $this->productMetadata->getName() . ' ' . $this->productMetadata->getEdition()], 'host' => $host, 'basePath' => $basePath];
 }
 /**
  * Generate AvaTax Client Name from a combination of Magento version number and AvaTax module version number
  * Format: Magento 2.x Community - AvaTax 1.0.0
  * Limited to 50 characters to comply with API requirements
  *
  * @return string
  */
 protected function getClientName()
 {
     return substr($this->magentoProductMetadata->getName(), 0, 7) . ' ' . substr($this->magentoProductMetadata->getVersion(), 0, 14) . ' ' . substr($this->magentoProductMetadata->getEdition(), 0, 10) . ' - ' . 'AvaTax ' . substr(AvaTaxAppInterface::APP_VERSION, 0, 7);
     // "AvaTax " & 1.x.x - 14 chars
 }
Example #6
0
 protected function addVersionInfo()
 {
     $this->infos['Name'] = $this->productMetadata->getName();
     $this->infos['Version'] = $this->productMetadata->getVersion();
     $this->infos['Edition'] = $this->productMetadata->getEdition();
 }
Example #7
0
 /**
  * Sets the response body with ProductName/Version (Edition). E.g.: Magento/0.42.0-beta3 (Community)
  *
  * @return void
  */
 public function execute()
 {
     $this->getResponse()->setBody($this->productMetadata->getName() . '/' . $this->productMetadata->getVersion() . ' (' . $this->productMetadata->getEdition() . ')');
 }