Example #1
0
 public function getRecord($docId, $options)
 {
     $institution = $options->get('institution', config('app.primo.institution'));
     $scope = $options->get('scope', config('app.primo.default_scope'));
     $queryObj = new Query($institution);
     $queryObj->local($scope);
     $queryObj->onCampus(true);
     $url = str_replace('json=true&', '', $this->primo->url('full', $queryObj));
     $url = str_replace('&indx=1&bulkSize=10', '', $url);
     $url .= '&docId=' . $docId . '&getDelivery=true';
     $client = new HttpClient();
     $request = $client->get($url);
     $body = $request->send()->getBody();
     if ($options->get('raw') == 'true') {
         return $body;
     }
     $root = new QuiteSimpleXMLElement(strval($body));
     $root->registerXPathNamespace('s', 'http://www.exlibrisgroup.com/xsd/jaguar/search');
     $root->registerXPathNamespace('p', 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib');
     $deeplinkProvider = $this->primo->createDeepLink();
     $error = $root->first('/s:SEGMENTS/s:JAGROOT/s:RESULT/s:ERROR');
     if ($error) {
         throw new PrimoException($error->attr('MESSAGE'), 0, null, $url);
     }
     $doc = $root->first('//s:DOC');
     if (!$doc) {
         throw new PrimoException('Invalid response from Primo', 0, null, $url);
     }
     $out = PrimoRecord::make($doc, $deeplinkProvider, true, $this->getRecordOptions($options))->toArray('full');
     return ['source' => $url, 'error' => null, 'result' => $out];
 }