<?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);

$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,
]);

$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 = new \Modules\Schemas\RoomStayCandidates([$guest1,$guest2]);

$data = [
  "cin" => "2025-09-06",
  "cout" => "2025-09-13",
  "hotel_code" => 198336,
  "rate_plan" => 3236716,
  "room_id" => "",
  "ISOMarket" => "JPN"
];

//$response = $omnibees->GetHotelAvail($data,[$room]);

$ISOMarket = "ISR";
$rooms = [
  [
    "StartDate" => "2025-09-06",
    "EndDate" => "2025-09-13",
    "HotelCode" => 198336,
    "RatePlanID" => 3236716,
    "RoomID" => 1036385,
    "Quantity" => 1,
    "GuestCounts" =>
      [
        $guest1->GuestCountsSchema("Adult",2,[1,2])
      ]
  ]
];
//$response = $omnibees->SendHotelResInitiate($rooms, $ISOMarket,[$guest1, $guest2]);
$response = $omnibees->SendHotelResCommit("RES000474-198336",'6b1cd01e-19d8-ca77-a42e-757305f33b6e');

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