<?php
require __DIR__ . '/../../vendor/autoload.php';
//date_default_timezone_set ("America/Mazatlan");


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

function dumpAndDie($what){
  echo "<pre>";
  var_dump($what);
  die();
}

$settings = require __DIR__ . '/../../src/settings.php';

$settings = $settings['settings']['logger_omnibees'];
$logger = new Monolog\Logger($settings['name']);
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
$logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], $settings['level']));
 
$omnibees = new \APIS\Omnibees($logger);

//$response = $omnibees->HotelSearch();




$room = new \Modules\Reservation\Room([], "2025-12-05", "2025-12-09");

$guest1 = new \Modules\Schemas\Guest([
  "first_name" => "Ob Adult 1",
  "last_name" => "Doe",
  "email" => "john.doe@example.com",
  "phone" => "123-456-7890",
  "PrimaryIndicator" => true,
  "AgeQualifyingCode" => "Adult",
  "ResGuestRPH" => 1,
]);
$room->addGuest($guest1);


$guest2 = new \Modules\Schemas\Guest([
  "first_name" => "Ob adult 2",
  "last_name" => "Doe",
  "email" => "john.doe@example.com",
  "phone" => "123-456-7890",
  "PrimaryIndicator" => false,
  "AgeQualifyingCode" => "Adult",
  "ResGuestRPH" => 2,
]);

$room->addGuest($guest2);

$room->setISOMarket("CHE");
$room->setResortId(198336);
$room->setRatePlan(3236772);
$room->setRoomId(1036387);
$ISOMarket = "AUS";
$rooms = [
  $room->reservationStartArray()
];

/*
a) DirectBill = 2
b) CreditCard = 5
c) Voucher = 3
d) PrePay = 4
*/

/*
$response = $omnibees->SendHotelResInitiate($rooms, $ISOMarket,[$guest1, $guest2],false,[
  "PaymentType" => 3
]);
*/
$reservationId = "RES000481-198336";
$transactionId = "ab258d87-4923-3b20-938a-22dc87a7b8c8";

$response = $omnibees->SendHotelResCommit($reservationId, $transactionId);
//  ------- termina la reserva original -----

echo json_decode($response) ? json_encode(json_decode($response), JSON_PRETTY_PRINT) : $response;
