feat: unfiltered product export for the website's catalogue import
This commit is contained in:
1 parent
272c811f4f
commit
1d42565a84
11 files changed
+970
-33
No files matched your search
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\Model\TravelExportQuery;
|
||||
use App\Model\Export;
|
||||
use App\Model\ExportQuery;
|
||||
use App\Service\ProductExportBuilder;
|
||||
use App\Service\TravelExportBuilder;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
@@ -29,6 +31,7 @@ class ExportController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TravelExportBuilder $travelExportBuilder,
|
||||
private readonly ProductExportBuilder $productExportBuilder,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -41,13 +44,31 @@ class ExportController extends AbstractController
|
||||
#[Route(path: '/travels', name: 'api_exports_travels', methods: ['GET'])]
|
||||
public function travels(
|
||||
#[MapQueryString(validationFailedStatusCode: Response::HTTP_BAD_REQUEST)]
|
||||
TravelExportQuery $query = new TravelExportQuery(),
|
||||
ExportQuery $query = new ExportQuery(),
|
||||
): JsonResponse {
|
||||
// Deliberately not wrapped in a catch that answers 200 with an error body, the way
|
||||
// TravelController::hotelAvailability() does: the consumer's retry logic keys on
|
||||
// status codes, so a failure here has to surface as a 5xx.
|
||||
$export = $this->travelExportBuilder->build();
|
||||
return $this->paginate($this->travelExportBuilder->build(), $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Every travel date x hotel pair with its whole record, unfiltered, paginated.
|
||||
*
|
||||
* The website's product import. Same grain, envelope and failure behaviour as travels();
|
||||
* the rows carry rooms, prices, services and selection groups instead of the
|
||||
* disposition subset, and nothing is dropped for the consumer.
|
||||
*/
|
||||
#[Route(path: '/products', name: 'api_exports_products', methods: ['GET'])]
|
||||
public function products(
|
||||
#[MapQueryString(validationFailedStatusCode: Response::HTTP_BAD_REQUEST)]
|
||||
ExportQuery $query = new ExportQuery(),
|
||||
): JsonResponse {
|
||||
return $this->paginate($this->productExportBuilder->build(), $query);
|
||||
}
|
||||
|
||||
private function paginate(Export $export, ExportQuery $query): JsonResponse
|
||||
{
|
||||
$total = count($export->rows);
|
||||
|
||||
return $this->json([
|
||||
|
||||
Reference in new issue
Block a user