|
@@ -121,7 +121,7 @@ class Webservice
|
|
|
if (method_exists($token, 'getAccessToken')) {
|
|
|
$headers[] = 'Authorization: Bearer ' . $token->getAccessToken();
|
|
|
}
|
|
|
- } elseif (!empty($credentials) && isset($credentials['username']) && isset($credentials['password'])) {
|
|
|
+ } elseif (!empty($credentials) && isset($credentials['username']) && isset($credentials['password'])) {
|
|
|
$headers[] = 'Authorization: Basic ' . base64_encode($credentials['username'] . ":" . $credentials['password']);
|
|
|
} else {
|
|
|
return '';
|
|
@@ -155,8 +155,8 @@ class Webservice
|
|
|
$url = $this->buildUrl($url, $filters, $order_by, $limit, $offset);
|
|
|
$data = json_decode($this->makeGetRequest($url), true);
|
|
|
} catch (\Exception $ex) {
|
|
|
- // TODO : Loguear esta exception o lanzarla.
|
|
|
- }
|
|
|
+ // TODO : Loguear esta exception o lanzarla.
|
|
|
+ }
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
@@ -176,7 +176,8 @@ class Webservice
|
|
|
try {
|
|
|
$url = $this->buildUrl($url, $filters, $order_by, $limit, $offset);
|
|
|
$data = json_decode($this->makeRequest($url), true);
|
|
|
- } catch (\Exception $ex) {}
|
|
|
+ } catch (\Exception $ex) {
|
|
|
+ }
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
@@ -268,10 +269,11 @@ class Webservice
|
|
|
return array("error" => "Webservice({$webservice}) not found.");
|
|
|
}
|
|
|
|
|
|
- public function buildUrlForId($ws,$id = null, $extra= null){
|
|
|
+ public function buildUrlForId($ws, $id = null, $extra = null)
|
|
|
+ {
|
|
|
$url = $this->serviceContainer->getParameter($ws);
|
|
|
- if(!is_null($id)){
|
|
|
- $url = str_replace(".json", "/{$id}", $url);
|
|
|
+ if (!is_null($id)) {
|
|
|
+ $url = str_replace(".json", "/{$id}", $url);
|
|
|
}
|
|
|
return $url . $extra;
|
|
|
|
|
@@ -301,4 +303,19 @@ class Webservice
|
|
|
return $this->httpClient;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param string $webservice
|
|
|
+ * @param int $id
|
|
|
+ *
|
|
|
+ * @return string Funcion que retorna todos los datos del objeto.
|
|
|
+ */
|
|
|
+ public function getByIdData($webservice, $id)
|
|
|
+ {
|
|
|
+ $result = $this->getArray($webservice, array(
|
|
|
+ 'id' => $id
|
|
|
+ ));
|
|
|
+
|
|
|
+ return isset($result[0]) ? $result[0] : $id;
|
|
|
+ }
|
|
|
+
|
|
|
}
|