-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1214 from cultuurnet/PPF-460-uitpas-activation
PPF-460-UiTPAS activation
- Loading branch information
Showing
18 changed files
with
347 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/Domain/Integrations/Controllers/OrganizerController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Domain\Integrations\Controllers; | ||
|
||
use App\Domain\Integrations\FormRequests\GetOrganizersRequest; | ||
use App\Http\Controllers\Controller; | ||
use App\Search\Sapi3\SearchService; | ||
use CultuurNet\SearchV3\ValueObjects\Organizer; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
final class OrganizerController extends Controller | ||
{ | ||
public function __construct(private readonly SearchService $searchService) | ||
{ | ||
} | ||
|
||
public function index(GetOrganizersRequest $request): JsonResponse | ||
{ | ||
try { | ||
$organizerName = $request->input('name'); | ||
|
||
$data = $this->searchService->searchUiTPASOrganizer($organizerName)->getMember()?->getItems() ?? []; | ||
|
||
return new JsonResponse( | ||
array_map(function (Organizer $organizer) { | ||
return [ | ||
'id' => $organizer->getCdbid(), | ||
'name' => $organizer->getName()?->getValues(), | ||
]; | ||
}, $data) | ||
); | ||
|
||
} catch (\Exception $e) { | ||
return new JsonResponse( | ||
['exception' => $e->getMessage()] | ||
); | ||
; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/Domain/Integrations/FormRequests/GetOrganizersRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Domain\Integrations\FormRequests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
final class GetOrganizersRequest extends FormRequest | ||
{ | ||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'name' => ['required', 'string'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Domain\Integrations\Mappers; | ||
|
||
use App\Domain\Integrations\FormRequests\RequestActivationRequest; | ||
use App\Domain\Integrations\Organizer; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
final class OrganizerMapper | ||
{ | ||
/** | ||
* @return Organizer[] | ||
*/ | ||
public static function map(RequestActivationRequest $request, string $id): array | ||
{ | ||
/** | ||
* @var Organizer[] $organizers | ||
*/ | ||
$organizers = []; | ||
|
||
foreach ($request->input('organizers') ?? [] as $organizer) { | ||
$organizers[] = new Organizer( | ||
Uuid::uuid4(), | ||
Uuid::fromString($id), | ||
Uuid::fromString($organizer['id']) | ||
); | ||
} | ||
|
||
return $organizers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.