Add update course
This commit is contained in:
parent
1238309006
commit
8614f81eca
20
src/Api.php
20
src/Api.php
|
@ -244,6 +244,26 @@ class Api {
|
|||
return $response['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param int $courseId
|
||||
* @param array<string, mixed> $payload
|
||||
* @return void
|
||||
*/
|
||||
public function updateCourse(int $memberId, int $courseId, array $payload): void
|
||||
{
|
||||
$response = $this->http()->put(self::$url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}", [
|
||||
'bausteinId' => $payload['course_id'],
|
||||
'vstgName' => $payload['event_name'],
|
||||
'vstgTag' => Carbon::parse($payload['completed_at'])->format('Y-m-d').'T00:00:00',
|
||||
'veranstalter' => $payload['organizer'],
|
||||
]);
|
||||
|
||||
if (data_get($response->json(), 'success') !== true) {
|
||||
$this->exception('Course creation failed', $payload, $response->json());
|
||||
}
|
||||
}
|
||||
|
||||
public function member($groupId, $memberId) {
|
||||
$url = self::$url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
|
||||
$response = $this->http()->get($url);
|
||||
|
|
|
@ -10,7 +10,20 @@ class CourseFake extends Fake {
|
|||
public function createsSuccessful(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}") {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}" && $request->method() === 'POST') {
|
||||
return Http::response([
|
||||
'data' => $courseId,
|
||||
'responseType' => 'OK',
|
||||
'success' => true,
|
||||
], 200);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function updatesSuccessful(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && $request->method() === 'PUT') {
|
||||
return Http::response([
|
||||
'data' => $courseId,
|
||||
'responseType' => 'OK',
|
||||
|
@ -45,4 +58,21 @@ class CourseFake extends Fake {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param int $courseId
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function assertUpdated(int $memberId, int $courseId, array $payload): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId, $courseId, $payload) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/${courseId}"
|
||||
&& $request->method() === 'PUT'
|
||||
&& data_get($request, 'bausteinId') === $payload['bausteinId']
|
||||
&& data_get($request, 'veranstalter') === $payload['veranstalter']
|
||||
&& data_get($request, 'vstgName') === $payload['vstgName']
|
||||
&& data_get($request, 'vstgTag') === $payload['vstgTag'];
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue