Пример #1
0
 /**
  * @param array $options
  * @return mixed
  * @throws \Exception
  */
 protected function processRequest(array $options = [])
 {
     if ($options['request_url']) {
         $options['request_url'] = $this->requestUrl . $options['request_url'];
     }
     $options = array_merge($options, ['api_key' => $this->options['api_key'], 'ssl' => $this->options['ssl']]);
     $RequestProcessor = new RequestProcessor($options);
     return $RequestProcessor->process();
 }
Пример #2
0
 /**
  * @param $apiKey
  * @param $ssl
  * @return mixed
  */
 public function processLink($apiKey, $ssl = true)
 {
     $RequestProcessor = new RequestProcessor(['request_url' => $this->getHref(), 'headers' => ['Accept: ' . $this->getMediaType()], 'request' => null, 'api_key' => $apiKey, 'ssl' => $ssl]);
     $response = $RequestProcessor->process();
     switch ($this->getRel()) {
         case 'label':
             return self::processApplicationPdfResponse($response);
             break;
         case 'manifest':
             $responseXML = new \SimpleXMLElement($response);
             switch ($responseXML->getName()) {
                 case 'manifest':
                     $ManifestType = new ManifestType();
                     $ManifestType->setPoNumber((string) $responseXML->{'po-number'});
                     if ($responseXML->{'links'}->link) {
                         foreach ($responseXML->{'links'}->link as $link) {
                             $LinkType = new LinkType();
                             $LinkType->setHref((string) $link['href']);
                             $LinkType->setRel((string) $link['rel']);
                             $LinkType->setMediaType((string) $link['media-type']);
                             if (isset($link['index'])) {
                                 $LinkType->setIndex((string) $link['index']);
                             }
                             $ManifestType->addLink($LinkType);
                         }
                     }
                     return $ManifestType;
                     break;
                 case 'messages':
                     return WebService::getMessagesType($responseXML);
                     break;
                 default:
                     return false;
                     break;
             }
             break;
         case 'artifact':
             return self::processApplicationPdfResponse($response);
             break;
         default:
             return false;
             break;
     }
 }