Lint
This commit is contained in:
parent
8125e664b1
commit
6fd6e9ead5
src
45
src/Api.php
45
src/Api.php
|
@ -72,8 +72,9 @@ class Api
|
|||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return app(Paginator::class)->startResult(100,
|
||||
fn ($page, $start) => $this->http()->get($this->url.'/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode(json_encode((object) $payload) ?: '{}').'&page='.$page.'&start='.$start.'&limit=100'),
|
||||
return app(Paginator::class)->startResult(
|
||||
100,
|
||||
fn ($page, $start) => $this->http()->get($this->url . '/ica/rest/nami/search-multi/result-list?searchedValues=' . rawurlencode(json_encode((object) $payload) ?: '{}') . '&page=' . $page . '&start=' . $start . '&limit=100'),
|
||||
function ($response) {
|
||||
if (true !== $response->json()['success']) {
|
||||
$this->exception(NotSuccessfulException::class, 'Search failed', '', $response->json(), []);
|
||||
|
@ -105,7 +106,7 @@ class Api
|
|||
public function pageSearch(array $payload, int $page, int $perPage): LengthAwarePaginator
|
||||
{
|
||||
$start = ($page - 1) * $perPage;
|
||||
$response = $this->http()->get($this->url.'/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode(json_encode((object) $payload) ?: '{}').'&page='.$page.'&start='.$start.'&limit='.$perPage);
|
||||
$response = $this->http()->get($this->url . '/ica/rest/nami/search-multi/result-list?searchedValues=' . rawurlencode(json_encode((object) $payload) ?: '{}') . '&page=' . $page . '&start=' . $start . '&limit=' . $perPage);
|
||||
$items = array_map(fn ($member) => MemberEntry::from($member), $response->json()['data']);
|
||||
|
||||
return new LengthAwarePaginator($items, $response->json('totalEntries'), $perPage, $page, []);
|
||||
|
@ -114,11 +115,11 @@ class Api
|
|||
public function deleteMember(int $id): void
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
$url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/mglschaft-beenden';
|
||||
$url = $this->url . '/ica/rest/nami/mitglied/filtered-for-navigation/mglschaft-beenden';
|
||||
$payload = [
|
||||
'id' => $id,
|
||||
'isConfirmed' => 'true',
|
||||
'beendenZumDatum' => now()->subDays(1)->format('Y-m-d').' 00:00:00',
|
||||
'beendenZumDatum' => now()->subDays(1)->format('Y-m-d') . ' 00:00:00',
|
||||
];
|
||||
$response = $this->http()->asForm()->post($url, $payload);
|
||||
|
||||
|
@ -153,13 +154,13 @@ class Api
|
|||
$existing = $this->rawMember($member->groupId, $member->id);
|
||||
$payload = array_merge($existing, $member->toNami());
|
||||
$payload['kontoverbindung'] = json_encode(data_get($payload, 'kontoverbindung', []));
|
||||
$url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->groupId.'/'.$member->id;
|
||||
$url = $this->url . '/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $member->groupId . '/' . $member->id;
|
||||
$response = $this->http()->put($url, $payload);
|
||||
$this->assertOk($response, $url, 'Update failed');
|
||||
|
||||
return $response->json()['data']['id'];
|
||||
} else {
|
||||
$url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->groupId;
|
||||
$url = $this->url . '/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $member->groupId;
|
||||
$response = $this->http()->post($url, [
|
||||
...$member->toNami(),
|
||||
'ersteTaetigkeitId' => $firstActivity,
|
||||
|
@ -177,10 +178,10 @@ class Api
|
|||
{
|
||||
$this->assertLoggedIn();
|
||||
if ($data->id) {
|
||||
$url = $this->url."/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}/{$data->id}";
|
||||
$url = $this->url . "/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}/{$data->id}";
|
||||
$response = $this->http()->put($url, $data->toNami());
|
||||
} else {
|
||||
$url = $this->url."/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
$url = $this->url . "/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
$response = $this->http()->post($url, $data->toNami());
|
||||
}
|
||||
if (true !== data_get($response->json(), 'success')) {
|
||||
|
@ -204,7 +205,7 @@ class Api
|
|||
|
||||
return $this
|
||||
->fetchCollection(
|
||||
'/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/'.$memberId.'/flist',
|
||||
'/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/' . $memberId . '/flist',
|
||||
'Membership fetch failed'
|
||||
)
|
||||
->map(fn ($membership) => MembershipEntry::from($membership));
|
||||
|
@ -234,7 +235,7 @@ class Api
|
|||
$this->assertLoggedIn();
|
||||
|
||||
return $this->fetchCollection(
|
||||
'/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/'.$activity->id,
|
||||
'/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/' . $activity->id,
|
||||
'Fetch subactivities failed'
|
||||
)->map(fn ($subactivity) => Subactivity::from($subactivity));
|
||||
}
|
||||
|
@ -286,11 +287,11 @@ class Api
|
|||
public function createCourse(int $memberId, array $payload): int
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
$url = $this->url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}";
|
||||
$url = $this->url . "/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}";
|
||||
$payload = [
|
||||
'bausteinId' => $payload['course_id'],
|
||||
'vstgName' => $payload['event_name'],
|
||||
'vstgTag' => Carbon::parse($payload['completed_at'])->format('Y-m-d').'T00:00:00',
|
||||
'vstgTag' => Carbon::parse($payload['completed_at'])->format('Y-m-d') . 'T00:00:00',
|
||||
'veranstalter' => $payload['organizer'],
|
||||
];
|
||||
$response = $this->http()->post($url, $payload);
|
||||
|
@ -308,11 +309,11 @@ class Api
|
|||
public function updateCourse(int $memberId, int $courseId, array $payload): void
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
$url = $this->url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}";
|
||||
$url = $this->url . "/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}";
|
||||
$payload = [
|
||||
'bausteinId' => $payload['course_id'],
|
||||
'vstgName' => $payload['event_name'],
|
||||
'vstgTag' => Carbon::parse($payload['completed_at'])->format('Y-m-d').'T00:00:00',
|
||||
'vstgTag' => Carbon::parse($payload['completed_at'])->format('Y-m-d') . 'T00:00:00',
|
||||
'veranstalter' => $payload['organizer'],
|
||||
];
|
||||
$response = $this->http()->put($url, $payload);
|
||||
|
@ -325,7 +326,7 @@ class Api
|
|||
public function deleteCourse(int $memberId, int $courseId): void
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
$url = $this->url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}";
|
||||
$url = $this->url . "/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}";
|
||||
$response = $this->http()->delete($url);
|
||||
|
||||
if (null !== $response->json() && true !== data_get($response->json(), 'success')) {
|
||||
|
@ -357,7 +358,7 @@ class Api
|
|||
$this->assertLoggedIn();
|
||||
|
||||
return $this->fetchCollection(
|
||||
'/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentGroup ? $parentGroup->id : 'root'),
|
||||
'/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/' . ($parentGroup ? $parentGroup->id : 'root'),
|
||||
'Group fetch failed'
|
||||
)->map(fn ($group) => Group::from([...$group, 'parentId' => $parentGroup ? $parentGroup->id : null]));
|
||||
}
|
||||
|
@ -466,8 +467,8 @@ class Api
|
|||
$this->assertLoggedIn();
|
||||
|
||||
return $this->fetchData(
|
||||
'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId,
|
||||
'Fetch von Mitglied '.$memberId.' in Gruppe '.$groupId.' fehlgeschlagen'
|
||||
'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $groupId . '/' . $memberId,
|
||||
'Fetch von Mitglied ' . $memberId . ' in Gruppe ' . $groupId . ' fehlgeschlagen'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -485,7 +486,7 @@ class Api
|
|||
*/
|
||||
private function fetchCollection(string $url, string $error): Collection
|
||||
{
|
||||
$response = $this->http()->get($this->url.$url);
|
||||
$response = $this->http()->get($this->url . $url);
|
||||
|
||||
$this->assertOk($response, $url, $error);
|
||||
/** @var array<int, mixed> */
|
||||
|
@ -499,7 +500,7 @@ class Api
|
|||
*/
|
||||
private function fetchData(string $url, string $error): array
|
||||
{
|
||||
$response = $this->http()->get($this->url.$url);
|
||||
$response = $this->http()->get($this->url . $url);
|
||||
|
||||
$this->assertOk($response, $url, $error);
|
||||
|
||||
|
@ -511,7 +512,7 @@ class Api
|
|||
$response = $this->http()->withHeaders([
|
||||
'content-type' => 'application/json',
|
||||
'accept' => 'application/json',
|
||||
])->delete($this->url.$url);
|
||||
])->delete($this->url . $url);
|
||||
|
||||
$this->assertOk($response, $url, $error);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue