Skip to content
Snippets Groups Projects
Commit 2355ee98 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #27067 : refacto + version file

parent ae87698f
3 merge requests!1132Hotline#29412 images des articles dans le resultat de recherche,!1016Dev#27067 koha restful suggestion service,!1004Dev#27067 koha restful suggestion service
- ticket #27067 : Koha : Webservice de création des suggestions
\ No newline at end of file
......@@ -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) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment