-
Notifications
You must be signed in to change notification settings - Fork 1
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 #392 from cultuurnet/feature/WID-513
WID-513 - Use UiTPAS promotions from new UiTPAS API
- Loading branch information
Showing
10 changed files
with
219 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace CultuurNet\ProjectAanvraag\UitpasAPI; | ||
|
||
use CultuurNet\ProjectAanvraag\APIServiceProviderBase; | ||
use CultuurNet\ProjectAanvraag\Uitpas\UitpasClient; | ||
use GuzzleHttp\Client; | ||
use Pimple\Container; | ||
|
||
class UitpasAPIServiceProvider extends APIServiceProviderBase | ||
{ | ||
|
||
public function register(Container $pimple) | ||
{ | ||
$pimple['uitpas_api'] = function (Container $pimple) { | ||
return new UitpasClient(new Client($this->getConfig($pimple, false))); | ||
}; | ||
|
||
$pimple['uitpas_api_test'] = function (Container $pimple) { | ||
return new UitpasClient(new Client($this->getConfig($pimple, true))); | ||
}; | ||
} | ||
|
||
private function getConfig(Container $pimple, bool $test): array | ||
{ | ||
return [ | ||
'base_uri' => $test ? $pimple['uitpas_api_test.base_url'] : $pimple['uitpas_api.base_url'], | ||
'headers' => [ | ||
'Content-type' => 'application/json; charset=utf-8', | ||
'Accept' => 'application/ld+json', | ||
'x-client-id' => $test ? $pimple['uitpas_api_test.x_client_id'] : $pimple['uitpas_api.x_client_id'], | ||
], | ||
'handler' => $this->getHandlerStack('uitpas_api', $pimple), | ||
]; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace CultuurNet\ProjectAanvraag\Uitpas; | ||
|
||
use GuzzleHttp\ClientInterface; | ||
|
||
/** | ||
* Default client to perform searches on the uitpas api. | ||
*/ | ||
class UitpasClient implements UitpasClientInterface | ||
{ | ||
|
||
/** | ||
* @var ClientInterface | ||
*/ | ||
protected $client; | ||
|
||
/** | ||
* UitpasClient constructor. | ||
* @param ClientInterface $client | ||
*/ | ||
public function __construct(ClientInterface $client) | ||
{ | ||
$this->client = $client; | ||
} | ||
|
||
public function setClient(ClientInterface $client) | ||
{ | ||
$this->client = $client; | ||
} | ||
|
||
public function getClient() | ||
{ | ||
return $this->client; | ||
} | ||
|
||
public function searchRewards(String $organizerId, Int $limit) | ||
{ | ||
$options = [ | ||
'query' => [ | ||
'organizerId' => $organizerId, | ||
'status' => 'ACTIVE', | ||
'type' => 'POINTS', | ||
'sort[creationDate]' => 'desc', | ||
'limit' => $limit, | ||
], | ||
]; | ||
|
||
$result = $this->client->request('GET', 'rewards', $options); | ||
|
||
return json_decode($result->getBody(true), true); | ||
} | ||
} |
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 | ||
|
||
namespace CultuurNet\ProjectAanvraag\Uitpas; | ||
|
||
use GuzzleHttp\ClientInterface; | ||
|
||
/** | ||
* Provides an interface for search clients on the uitpas api | ||
*/ | ||
interface UitpasClientInterface | ||
{ | ||
/** | ||
* Perform a search on uitpas rewards. | ||
* | ||
* @param String $organizerdId | ||
* @param Int $limit | ||
* @return Array | ||
*/ | ||
public function searchRewards(String $organizerId, Int $limit); | ||
} |
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
4 changes: 2 additions & 2 deletions
4
views/widgets/search-results-widget/uitpas-promotions.html.twig
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
Large diffs are not rendered by default.
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