diff --git a/VERSIONS_WIP/27067 b/VERSIONS_WIP/27067 new file mode 100644 index 0000000000000000000000000000000000000000..4266f52e993875e5655677aa4ab02090c27eff40 --- /dev/null +++ b/VERSIONS_WIP/27067 @@ -0,0 +1 @@ + - ticket #27067 : Koha : Webservice de création des suggestions \ No newline at end of file diff --git a/library/Class/WebService/SIGB/AbstractRESTService.php b/library/Class/WebService/SIGB/AbstractRESTService.php index 4ccaad37fc3a0b5183b9d4e0c6ad71bdd98c418c..c315f04f551180e8668c21cc7a0663008c8214b2 100644 --- a/library/Class/WebService/SIGB/AbstractRESTService.php +++ b/library/Class/WebService/SIGB/AbstractRESTService.php @@ -80,15 +80,11 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @return string */ public function httpGet($options) { - $url = $this->buildQueryURL($options); - try { - $response = $this->getWebClient()->open_url($url); - $this->log(); - return $response; - } catch (Exception $e) { - $this->logError($url, $e->getMessage()); - return ''; - } + $closure = function($client, $url) { + return $client->open_url($url); + }; + + return $this->_withClientDo($options, $closure); } @@ -98,9 +94,23 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @return string response body */ public function httpPost($options, $datas) { + $closure = function($client, $url) use ($datas) { + return $client->postData($url, $datas); + }; + + return $this->_withClientDo($options, $closure); + } + + + /** + * @param $options array url query part + * @param $closure + * @return response body + */ + protected function _withClientDo($options, $closure) { $url = $this->buildQueryURL($options); try { - $response = $this->getWebClient()->postData($url, $datas); + $response = $closure($this->getWebClient(), $url); $this->log(); return $response; } catch (Exception $e) {