Add namiException when fetching of member returns error
This commit is contained in:
parent
88076d2e1d
commit
a317215554
21
src/Api.php
21
src/Api.php
|
@ -112,15 +112,24 @@ class Api {
|
||||||
|
|
||||||
Logger::http($url, $response, 'Show member '.$memberId, ['memberId' => $memberId]);
|
Logger::http($url, $response, 'Show member '.$memberId, ['memberId' => $memberId]);
|
||||||
|
|
||||||
if ($response->json()['success'] === true) {
|
if($response->json()['success'] === false && Str::startsWith($response['message'], 'Access denied')) {
|
||||||
return $response->json()['data'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Str::startsWith($response['message'], 'Access denied')) {
|
|
||||||
return $this->singleMemberFallback($groupId, $memberId);
|
return $this->singleMemberFallback($groupId, $memberId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response->json()['data'];
|
if($response->json()['success'] === false && Str::startsWith($response['message'], 'Sicherheitsverletzung: Zugriff')) {
|
||||||
|
return $this->singleMemberFallback($groupId, $memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->json()['success'] === true) {
|
||||||
|
return $response->json()['data'];
|
||||||
|
} else {
|
||||||
|
$e = new NamiException('Fetch von Mitglied fehlgeschlagen');
|
||||||
|
$e->setData([
|
||||||
|
'response' => $response->body(),
|
||||||
|
'url' => $url
|
||||||
|
]);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasGroup($groupId): bool {
|
public function hasGroup($groupId): bool {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zoomyboy\LaravelNami;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class NamiException extends \Exception {
|
||||||
|
|
||||||
|
private $data;
|
||||||
|
|
||||||
|
public function setData($data) {
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getData() {
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue