This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
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.
III-2331: Event & Organizer controller changes based on new UiTPAS AP…
…I (WIP)
- Loading branch information
1 parent
641943d
commit c2bd420
Showing
14 changed files
with
433 additions
and
249 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
<?php | ||
|
||
namespace CultuurNet\UDB3\UiTPASService\Controller; | ||
|
||
use CultuurNet\UDB3\UiTPASService\Controller\Response\CardSystemsJsonResponse; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class EventCardSystemsController | ||
{ | ||
/** | ||
* @var \CultureFeed_Uitpas | ||
*/ | ||
private $uitpas; | ||
|
||
/** | ||
* @param \CultureFeed_Uitpas $uitpas | ||
*/ | ||
public function __construct(\CultureFeed_Uitpas $uitpas) | ||
{ | ||
$this->uitpas = $uitpas; | ||
} | ||
|
||
/** | ||
* @param string $eventId | ||
* @return CardSystemsJsonResponse | ||
*/ | ||
public function get($eventId) | ||
{ | ||
$cardSystems = $this->uitpas->getCardSystemsForEvent($eventId); | ||
return new CardSystemsJsonResponse($cardSystems->objects); | ||
} | ||
|
||
/** | ||
* @param string $eventId | ||
* @param string $cardSystemId | ||
* @param string|null $distributionKeyId | ||
* @return Response | ||
*/ | ||
public function add($eventId, $cardSystemId, $distributionKeyId = null) | ||
{ | ||
$this->uitpas->addCardSystemToEvent($eventId, $cardSystemId, $distributionKeyId); | ||
return new Response('OK', 200); | ||
} | ||
|
||
/** | ||
* @param string $eventId | ||
* @param string $cardSystemId | ||
* @return Response | ||
*/ | ||
public function delete($eventId, $cardSystemId) | ||
{ | ||
$this->uitpas->deleteCardSystemFromEvent($eventId, $cardSystemId); | ||
return new Response('OK', 200); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
<?php | ||
|
||
namespace CultuurNet\UDB3\UiTPASService\Controller; | ||
|
||
use CultuurNet\UDB3\UiTPASService\Controller\Response\CardSystemsJsonResponse; | ||
|
||
class OrganizerCardSystemsController | ||
{ | ||
/** | ||
* @var \CultureFeed_Uitpas | ||
*/ | ||
private $uitpas; | ||
|
||
/** | ||
* @param \CultureFeed_Uitpas $uitpas | ||
*/ | ||
public function __construct(\CultureFeed_Uitpas $uitpas) | ||
{ | ||
$this->uitpas = $uitpas; | ||
} | ||
|
||
/** | ||
* @param string $organizerId | ||
* @return CardSystemsJsonResponse | ||
*/ | ||
public function get($organizerId) | ||
{ | ||
$cardSystems = $this->uitpas->getCardSystemsForOrganizer($organizerId); | ||
return new CardSystemsJsonResponse($cardSystems->objects); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,55 @@ | ||
<?php | ||
|
||
namespace CultuurNet\UDB3\UiTPASService\Controller\Response; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class CardSystemsJsonResponse extends Response | ||
{ | ||
/** | ||
* @param \CultureFeed_Uitpas_CardSystem[] $cardSystems | ||
* @param int $status | ||
* @param array $headers | ||
*/ | ||
public function __construct(array $cardSystems, $status = 200, array $headers = array()) | ||
{ | ||
$data = []; | ||
foreach ($cardSystems as $cardSystem) { | ||
$data[$cardSystem->id] = $this->convertCardSystemToArray($cardSystem); | ||
} | ||
|
||
$content = json_encode($data); | ||
|
||
parent::__construct($content, $status, $headers); | ||
} | ||
|
||
/** | ||
* @param \CultureFeed_Uitpas_CardSystem $cardSystem | ||
* @return array | ||
*/ | ||
private function convertCardSystemToArray(\CultureFeed_Uitpas_CardSystem $cardSystem) | ||
{ | ||
$distributionKeys = []; | ||
foreach ($cardSystem->distributionKeys as $distributionKey) { | ||
$distributionKeys[$distributionKey->id] = $this->convertDistributionKeyToArray($distributionKey); | ||
} | ||
|
||
return [ | ||
'id' => $cardSystem->id, | ||
'name' => $cardSystem->name, | ||
'distributionKeys' => $distributionKeys, | ||
]; | ||
} | ||
|
||
/** | ||
* @param \CultureFeed_Uitpas_DistributionKey $distributionKey | ||
* @return array | ||
*/ | ||
private function convertDistributionKeyToArray(\CultureFeed_Uitpas_DistributionKey $distributionKey) | ||
{ | ||
return [ | ||
'id' => $distributionKey->id, | ||
'name' => $distributionKey->name, | ||
]; | ||
} | ||
} |
Oops, something went wrong.