private function getResourceDataV3(Source $source, $accept = null)
 {
     $url = $source->getUrl();
     $jwt = $source->getJwt();
     if (!$url) {
         throw new RuntimeException("No source URL to get resource data");
     }
     if (!$jwt) {
         throw new RuntimeException("No source JWT to get resource data");
     }
     if ($jwt) {
         $url .= "?jwt=" . $jwt;
     }
     if ($accept) {
         $url .= '&accept=' . $accept;
     }
     //echo "REQUESTING: $url\n";
     try {
         $res = $this->httpClient->get($url, ['headers' => [], 'verify' => $this->verify]);
         if ($res->getStatusCode() == 200) {
             $res = (string) $res->getBody();
             return $res;
         }
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         ErrorResponseHandler::handle($e->getResponse());
     }
 }
예제 #2
0
 private function parseDossiersXmlToResources($xml)
 {
     $rootNode = @simplexml_load_string($xml);
     if (!$rootNode) {
         echo $xml;
         throw new RuntimeException("Failed to parse response as XML...\n");
     }
     $resources = array();
     foreach ($rootNode->dossier as $dossierNode) {
         if ($dossierNode->client && $dossierNode->client->eocs) {
             $clientNode = $dossierNode->client;
             $providerNode = $dossierNode->provider;
             foreach ($dossierNode->client->eocs->eoc as $eocNode) {
                 $resource = new Resource();
                 $resource->setType('perinatologie/dossier');
                 $resource->addPropertyValue('reference', $eocNode->reference);
                 $resource->addPropertyValue('client_bsn', $clientNode->bsn);
                 $resource->addPropertyValue('client_birthdate', $clientNode->birthdate);
                 $resource->addPropertyValue('client_displayname', $clientNode->displayname);
                 $resource->addPropertyValue('client_zisnr', $clientNode->zisnr);
                 $resource->addPropertyValue('gravida', $eocNode->gravida);
                 $resource->addPropertyValue('para', $eocNode->para);
                 $resource->addPropertyValue('provider_reference', $providerNode->dbname);
                 $resource->addPropertyValue('provider_apiurl', $providerNode->apiurl);
                 $source = new Source();
                 $source->setApi('v1');
                 $resource->setSource($source);
                 $resources[] = $resource;
             }
         }
     }
     return $resources;
 }
예제 #3
0
 private function parseSource($node)
 {
     $source = new Source();
     $source->setUrl((string) $node->url);
     $source->setApi((string) $node->api);
     if ($node->jwt) {
         $source->setJwt((string) $node->jwt);
     }
     return $source;
 }