Files
myep/src/BpnConnect/RoomsClient.php
T

34 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\BpnConnect;
class RoomsClient extends AbstractApiClient
{
private const string CONTINGENT_POOLS_PATH = '/api/v1/rooms/contingent-pools';
/**
* Which room type's contingent each room type of a hotel draws on.
*
* The office sells one room at several occupancies by pointing the extra room types at the
* first one's contingent (`PartnerZimmer.IDPartnerZimmer_FS_KontiAus`). A room type with its
* own contingent maps to itself.
*
* @param int $hotelId the hotel's BusPro address id (the export's `<hotel idbuspro>`)
*
* @return array<int, int> room type id => room type id owning its contingent
*/
public function getContingentPools(int $hotelId): array
{
$payload = $this->request(self::CONTINGENT_POOLS_PATH, ['hotelId' => $hotelId]);
$pools = [];
foreach ($payload['data'] ?? [] as $item) {
$pools[(int) $item['room_type_id']] = (int) $item['pool_room_type_id'];
}
return $pools;
}
}