<?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("activity_id")) {
    $activity_id = $_GET["activity_id"];
    $response = $booking->getActivityById($activity_id);
    if ($response["success"]) {
        echo $restapi->Response($response);
    } else {
        echo $restapi->Response($response, 400);
    }
} else {
    $response = $booking->getAllActivities();
    echo $restapi->Response($response);
}
