fix: don't normalize hotel and product codes when fetching cms data
This commit is contained in:
1 parent
592cd517ff
commit
8ca105966d
2 files changed
+7
-39
No files matched your search
@@ -11,42 +11,14 @@ class CmsDataService
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a product or hotel code for CMS lookup.
|
||||
*
|
||||
* Returns the first 3 characters of the code, except for codes
|
||||
* starting with 'SER' where characters 4-6 are returned instead.
|
||||
*/
|
||||
public function normalizeCode(?string $code): ?string
|
||||
{
|
||||
if (null === $code || 3 > strlen($code)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (str_starts_with($code, 'SER') && 6 <= strlen($code)) {
|
||||
return substr($code, 3, 3);
|
||||
}
|
||||
|
||||
return substr($code, 0, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches only the hotel images from the CMS.
|
||||
*
|
||||
* The product code is normalized for CMS lookup while the hotel code
|
||||
* is passed as-is for better matching results.
|
||||
*
|
||||
* @return array<string, mixed>|null The images array or null if unavailable
|
||||
*/
|
||||
public function getProductImages(string $productCode, ?string $hotelCode = null): ?array
|
||||
{
|
||||
$normalizedProduct = $this->normalizeCode($productCode);
|
||||
|
||||
if (null === $normalizedProduct) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $this->getProductDetails($normalizedProduct, $hotelCode);
|
||||
$result = $this->getProductDetails($productCode, $hotelCode);
|
||||
|
||||
if (true === isset($result['success']) && false === $result['success']) {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user