<?php
//////////////////////////////////////
header("Access-Control-Allow-Origin: *");
include_once('OAuth.php');
//////////// SAAS ENV ////////////////////////////////////////////////////
require_once("class.restframework.php");
require_once("class.saas.php");
include_once('class.booking.php');
////////////////////////////////////////////////////////////////////////
$restapi = new RestFrameWork();
// alow get ######## 
$restapi->allow("get");
// only allow get method
$saas = new SaaS($restapi);
$auth = $saas->_initAuth();
////////////////////////////////////////////////////////////////////////
$booking = new Booking($auth, $restapi);
///////////////////////////////////////////////////////////////////////
if ($restapi->purge("room_id")) {
    $room_id = $_GET["room_id"];
    $response = $booking->getAllRoomRates($room_id);
    echo $restapi->Response($response);
} else if ($restapi->purge("room_rate_id")) {
    $room_rate_id = $restapi->purge("room_rate_id");
    $response = $booking->getRoomRateById($room_rate_id);
    echo $restapi->Response($response);
} else {
    echo $restapi->Response(array("message" => "Incomplete request", "success" => false), 400);
}
