remov old methods
This commit is contained in:
parent
30f8a301c2
commit
cb97b8f1a9
119
src/Api.php
119
src/Api.php
|
@ -60,11 +60,6 @@ class Api implements NamiData {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function memberModel($member): Model {
|
||||
$eloquentClass = config('nami.models.member');
|
||||
return $eloquentClass::findByNamiId($member['id']) ?: $this->fillFromOverview(new $eloquentClass);
|
||||
}
|
||||
|
||||
public function membersOf($groupId): Collection {
|
||||
return collect($this->http()->get(self::$url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/flist')->json()['data']);
|
||||
}
|
||||
|
@ -228,117 +223,5 @@ class Api implements NamiData {
|
|||
return $member->toArray();
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
public function groupForActivity($activityId) {
|
||||
|
||||
$response = $this->client->get("/ica/rest//nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/{$activityId}", [
|
||||
'cookies' => $this->cookie
|
||||
]);
|
||||
|
||||
return json_decode((string)$response->getBody());
|
||||
}
|
||||
|
||||
public function allMembers() {
|
||||
$response = $this->client->get("/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/{$this->user->getNamiGroupId()}/flist", [
|
||||
'cookies' => $this->cookie
|
||||
]);
|
||||
|
||||
return json_decode((string)$response->getBody());
|
||||
}
|
||||
|
||||
public function getMember($memberId) {
|
||||
$response = $this->client->get('/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$this->user->getNamiGroupId().'/'.$memberId, [
|
||||
'cookies' => $this->cookie,
|
||||
'http_errors' => false
|
||||
]
|
||||
);
|
||||
|
||||
return json_decode((string)$response->getBody());
|
||||
}
|
||||
|
||||
/** @todo testen mit guzzle fake */
|
||||
public function isSuccess($response) {
|
||||
return isset ($response->success) && $response->success === true
|
||||
&& isset ($response->responseType) && $response->responseType == 'OK';
|
||||
}
|
||||
|
||||
public function checkCredentials() {
|
||||
try {
|
||||
$this->login();
|
||||
} catch (LoginException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get($url) {
|
||||
$this->login();
|
||||
|
||||
$response = $this->client->request('GET', $this->baseUrl.$url, [
|
||||
'http_errors' => false,
|
||||
'cookies' => $this->cookie
|
||||
]);
|
||||
|
||||
$json = json_decode((string) $response->getBody());
|
||||
|
||||
return collect($json);
|
||||
}
|
||||
|
||||
public function post($url, $fields) {
|
||||
$this->login();
|
||||
|
||||
$response = $this->client->request('POST', $this->baseUrl.$url, [
|
||||
'http_errors' => false,
|
||||
'cookies' => $this->cookie,
|
||||
'headers' => [
|
||||
'Accept' => '*/*',
|
||||
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
],
|
||||
'form_params' => $fields
|
||||
]);
|
||||
|
||||
$json = json_decode((string) $response->getBody());
|
||||
|
||||
return collect($json);
|
||||
}
|
||||
|
||||
public function put($url, $fields) {
|
||||
$this->login();
|
||||
|
||||
$response = $this->client->request('PUT', $this->baseUrl.$url, [
|
||||
'http_errors' => false,
|
||||
'cookies' => $this->cookie,
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => $fields
|
||||
]);
|
||||
|
||||
$json = json_decode((string) $response->getBody());
|
||||
|
||||
if (is_null($json)) {
|
||||
\Log::critical('Api gibt kein JSON zurück', [
|
||||
'response' => (string) $response->getBody(),
|
||||
'fields' => $fields,
|
||||
'url' => $url
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$json->success || $json->success == false) {
|
||||
\Log::critical('Fehler beim Update', [
|
||||
'response' => (string) $response->getBody(),
|
||||
'fields' => $fields,
|
||||
'url' => $url
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return collect($json);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue