Skip to content

Commit

Permalink
WID-513 - Use same parameters on uitpas search rewards as on uitpas.be
Browse files Browse the repository at this point in the history
  • Loading branch information
brampauwelyn committed Feb 27, 2024
1 parent 807c811 commit 979e1e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/Uitpas/UitpasClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ public function getClient()
return $this->client;
}

public function searchRewards(String $organizerId)
public function searchRewards(String $organizerId, Int $limit)
{
$options = [
'query' => ['organizerId' => $organizerId],
'query' => [
'organizerId' => $organizerId,
'status' => 'ACTIVE',
'type' => 'POINTS',
'sort[creationDate]' => 'desc',
'limit' => $limit
],
];

$result = $this->client->request('GET', 'rewards', $options);
Expand Down
3 changes: 2 additions & 1 deletion src/Uitpas/UitpasClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function getClient();
* Perform a search on uitpas rewards.
*
* @param String $organizerdId
* @param Int $limit
* @return Array
*/
public function searchRewards(String $organizerId);
public function searchRewards(String $organizerId, Int $limit);
}
9 changes: 2 additions & 7 deletions src/Widget/Twig/TwigPreprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,25 +353,20 @@ public function preprocessEventDetail(Event $event, string $langcode, array $set
}

$variables['uitpas_promotions'] = '';
// Load Uitpas promotions via culturefeed.
if ($variables['uitpas'] && !empty($settings['uitpas_benefits']) && $event->getOrganizer()) {
$promotionsQuery = new \CultureFeed_Uitpas_Passholder_Query_SearchPromotionPointsOptions();
$promotionsQuery->max = 4;
$promotionsQuery->balieConsumerKey = $event->getOrganizer()->getCdbid();
$promotionsQuery->unexpired = true;
$organizerName = $this->translateOrganizerName($event, $langcode);

$organizerId = $event->getOrganizer()->getCdbid();

try {
$uitpasPromotions = $this->uitpasClient->searchRewards($organizerId);
$uitpasPromotions = $this->uitpasClient->searchRewards($organizerId, 4);
$variables['uitpas_promotions'] = $this->twig->render(
'widgets/search-results-widget/uitpas-promotions.html.twig',
[
'promotions' => $this->preprocessUitpasPromotions($uitpasPromotions['member']),
'organizerName' => $organizerName,
'organizerUrlName' => $this->formatOrganizerUrlName($organizerName),
'organizerId' => $promotionsQuery->balieConsumerKey,
'organizerId' => $organizerId,
]
);
} catch (\Exception $e) {
Expand Down

0 comments on commit 979e1e7

Please sign in to comment.