diff --git a/src/Configuration/Extractor.php b/src/Configuration/Extractor.php index 014d9dc..40573d2 100644 --- a/src/Configuration/Extractor.php +++ b/src/Configuration/Extractor.php @@ -190,7 +190,7 @@ final class Extractor implements Config\Definition\ConfigurationInterface 'get', 'listPaymentsPerPage', 'allPayments', - 'listShipmentPerPage', + 'listShipmentsPerPage', 'allShipments' ], 'orderItem' => [ @@ -320,6 +320,128 @@ final class Extractor implements Config\Definition\ConfigurationInterface private static array $endpointsShop = [ // Core Endpoints + 'address' => [ + 'listPerPage', + 'all', + 'get', + ], + 'adjustment' => [ + 'listPerPage', + 'all', + 'get', + ], + 'catalogPromotion' => [ + 'get', + ], + 'channel' => [ + 'get', + ], + 'country' => [ + 'listPerPage', + 'all', + 'get', + ], + 'currency' => [ + 'listPerPage', + 'all', + 'get', + ], + 'customer' => [ + 'get', + ], + 'locale' => [ + 'listPerPage', + 'all', + 'get', + ], + 'order' => [ + 'listPerPage', + 'all', + 'get', + 'listPaymentMethodsPerPage', + 'allPaymentMethods', + 'listShipmentMethodsPerPage', + 'allShipmentMethods', + 'listAdjustmentsPerPage', + 'allAdjustments', + 'listItemsPerPage', + 'allItems', + ], + 'orderItem' => [ + 'listPerPage', + 'all', + 'get', + 'listAdjustmentsPerPage', + 'allAdjustments', + ], + 'orderItemUnit' => [ + 'get', + ], + 'payment' => [ + 'listPerPage', + 'all', + 'get', + ], + 'paymentMethod' => [ + 'listPerPage', + 'all', + 'get', + ], + 'product' => [ + 'listPerPage', + 'all', + 'get', + 'getBySlug', + ], + 'productImage' => [ + 'get', + ], + 'productOption' => [ + 'get', + ], + 'productOptionValue' => [ + 'get', + ], + 'productReview' => [ + 'listPerPage', + 'all', + 'get', + ], + 'productTaxon' => [ + 'get', + ], + 'productTranslation' => [ + 'get', + ], + 'productVariant' => [ + 'listPerPage', + 'all', + 'get', + ], + 'productVariantTranslation' => [ + 'get', + ], + 'shipment' => [ + 'listPerPage', + 'all', + 'get', + ], + 'shippingMethod' => [ + 'listPerPage', + 'all', + 'get', + ], + 'shippingMethodTranslation' => [ + 'get', + ], + 'taxon' => [ + 'listPerPage', + 'all', + 'get', + ], + 'taxonTranslation' => [ + 'get', + ], ]; private static array $doubleEndpointsLegacy = [ @@ -339,6 +461,8 @@ final class Extractor implements Config\Definition\ConfigurationInterface private static array $doubleEndpointsShop = [ // Double resources Endpoints + 'adjustment', + 'order', ]; public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder @@ -380,20 +504,13 @@ public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Bui ) { throw new \InvalidArgumentException(sprintf('The value should be one of [%s], got %s.', implode(', ', $endpoints[$item['type']]), json_encode($item['method'], \JSON_THROW_ON_ERROR))); } + if (\in_array($item['type'], $doubleEndpoints) && !\array_key_exists('code', $item)) { + throw new \InvalidArgumentException(sprintf('The %s type should have a "code" field set.', $item['type'])); + } return $item; }) ->end() - ->validate() - ->ifArray() - ->then(function (array $item) { - if (\in_array($item['type'], self::$doubleEndpoints) && !\array_key_exists('code', $item)) { - throw new \InvalidArgumentException(sprintf('The %s type should have a "code" field set.', $item['type'])); - } - - return $item; - }) - ->end() ->children() ->scalarNode('api_type') ->isRequired() @@ -401,15 +518,6 @@ public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Bui ->end() ->scalarNode('type') ->isRequired() - ->validate() - ->ifNotInArray(array_merge(array_keys(self::$endpoints), self::$doubleEndpoints)) - ->thenInvalid( - sprintf( - 'the value should be one of [%s], got %%s', - implode(', ', array_merge(array_keys(self::$endpoints), self::$doubleEndpoints)) - ) - ) - ->end() ->end() ->scalarNode('method')->end() ->scalarNode('code') diff --git a/src/Configuration/Loader.php b/src/Configuration/Loader.php index 2a4c710..bc14f4a 100644 --- a/src/Configuration/Loader.php +++ b/src/Configuration/Loader.php @@ -220,7 +220,39 @@ final class Loader implements Config\Definition\ConfigurationInterface private static array $endpointsShop = [ // Core Endpoints - + 'address' => [ + 'create', + 'delete', + 'upsert', + ], + 'customer' => [ + 'create', + 'upsert', + 'changePassword', + ], + 'order' => [ + 'create', + 'upsert', + 'choosePayment', + 'chooseShipment', + 'complete', + ], + 'orderItem' => [ + 'create', + 'delete', + 'changeQuantity', + ], + 'productReview' => [ + 'create', + ], + 'resetPasswordRequest' => [ + 'create', + 'verify', + ], + 'verifyCustomerAccount' => [ + 'create', + 'verify', + ], ]; public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder