-
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 branch 'master' into III-6395-ignore-rejected-ownership-requests
- Loading branch information
Showing
18 changed files
with
237 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Feature: Test the metadata in the history API | ||
|
||
Background: | ||
Given I am using the UDB3 base URL | ||
And I am authorized with an Auth0 client access token for "test_client" | ||
And I create a minimal place and save the "url" as "placeUrl" | ||
And I wait for the place with url "%{placeUrl}" to be indexed | ||
And I create a minimal permanent event and save the "url" as "eventUrl" | ||
And I wait for the event with url "%{eventUrl}" to be indexed | ||
|
||
Scenario: test metaData place | ||
Given I am using an UiTID v1 API key of consumer "uitdatabank" | ||
And I am authorized as JWT provider v1 user "centraal_beheerder" | ||
And I send and accept "application/json" | ||
And I send a GET request to "%{placeUrl}/history" | ||
And the JSON response at "0/author" should be "pjeOqgEYI0Y4gmr8DWMpUrpTMXrvjgpc@clients" | ||
And the JSON response at "0/auth0ClientId" should be "pjeOqgEYI0Y4gmr8DWMpUrpTMXrvjgpc" | ||
And the JSON response at "0/auth0ClientName" should be "UiTdatabank Acceptance Tests" | ||
And the JSON response at "0/api" should be "JSON-LD API" | ||
|
||
Scenario: test metaData event | ||
Given I am using an UiTID v1 API key of consumer "uitdatabank" | ||
And I am authorized as JWT provider v1 user "centraal_beheerder" | ||
And I send and accept "application/json" | ||
And I send a GET request to "%{eventUrl}/history" | ||
And the JSON response at "0/author" should be "pjeOqgEYI0Y4gmr8DWMpUrpTMXrvjgpc@clients" | ||
And the JSON response at "0/auth0ClientId" should be "pjeOqgEYI0Y4gmr8DWMpUrpTMXrvjgpc" | ||
And the JSON response at "0/auth0ClientName" should be "UiTdatabank Acceptance Tests" | ||
And the JSON response at "0/api" should be "JSON-LD API" |
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
33 changes: 33 additions & 0 deletions
33
src/Model/Serializer/ValueObject/Price/TariffDenormalizer.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CultuurNet\UDB3\Model\Serializer\ValueObject\Price; | ||
|
||
use CultuurNet\UDB3\Model\ValueObject\Price\Tariff; | ||
use CultuurNet\UDB3\Model\ValueObject\Price\TranslatedTariffName; | ||
use CultuurNet\UDB3\MoneyFactory; | ||
use Money\Currency; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
|
||
final class TariffDenormalizer implements DenormalizerInterface | ||
{ | ||
public function denormalize($data, $class, $format = null, array $context = []): Tariff | ||
{ | ||
/** @var TranslatedTariffName $tariffName */ | ||
$tariffName = (new TranslatedTariffNameDenormalizer())->denormalize( | ||
$data['name'], | ||
TranslatedTariffName::class | ||
); | ||
|
||
return new Tariff( | ||
$tariffName, | ||
MoneyFactory::createFromCents($data['price'], new Currency($data['currency'])) | ||
); | ||
} | ||
|
||
public function supportsDenormalization($data, $type, $format = null): bool | ||
{ | ||
return $type === Tariff::class; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Model/Serializer/ValueObject/Price/TariffNormalizer.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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CultuurNet\UDB3\Model\Serializer\ValueObject\Price; | ||
|
||
use CultuurNet\UDB3\Model\ValueObject\Price\Tariff; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
final class TariffNormalizer implements NormalizerInterface | ||
{ | ||
/** | ||
* @param Tariff $tariff | ||
*/ | ||
public function normalize($tariff, $format = null, array $context = []): array | ||
{ | ||
return [ | ||
'name' => (new TranslatedTariffNameNormalizer())->normalize($tariff->getName()), | ||
'price' => $tariff->getPrice()->getAmount(), | ||
'currency' => $tariff->getPrice()->getCurrency()->getName(), | ||
]; | ||
} | ||
|
||
public function supportsNormalization($data, $format = null): bool | ||
{ | ||
return $data === Tariff::class; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Model/Serializer/ValueObject/Price/TranslatedTariffNameNormalizer.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CultuurNet\UDB3\Model\Serializer\ValueObject\Price; | ||
|
||
use CultuurNet\UDB3\Model\Serializer\ValueObject\Translation\TranslatedValueObjectNormalizer; | ||
use CultuurNet\UDB3\Model\ValueObject\Price\TranslatedTariffName; | ||
|
||
final class TranslatedTariffNameNormalizer extends TranslatedValueObjectNormalizer | ||
{ | ||
public function supportsNormalization($data, $format = null): bool | ||
{ | ||
return $data === TranslatedTariffName::class; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Model/Serializer/ValueObject/Translation/TranslatedValueObjectNormalizer.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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CultuurNet\UDB3\Model\Serializer\ValueObject\Translation; | ||
|
||
use CultuurNet\UDB3\Model\ValueObject\Translation\Language; | ||
use CultuurNet\UDB3\Model\ValueObject\Translation\TranslatedValueObject; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
abstract class TranslatedValueObjectNormalizer implements NormalizerInterface | ||
{ | ||
/** | ||
* @param TranslatedValueObject $object | ||
*/ | ||
public function normalize($object, $format = null, array $context = []): array | ||
{ | ||
$data = []; | ||
|
||
/** @var Language $language */ | ||
foreach ($object->getLanguages() as $language) { | ||
$data[$language->toString()] = $object->getTranslation($language)->toString(); | ||
} | ||
|
||
return $data; | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.