Commit 3a7c1b26 by Jansa Jose

J : flight and hotel apis in seperate page

parent e6cb1bd6
......@@ -614,186 +614,5 @@ class Webservice extends CI_Controller {
$this->errorResponse($res['code'],$res['message']);
}
}
/*********************************** START Hotel API ****************************************/
public function get_hotel_city_list(){
$data = $_GET;
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->get_hotel_city_list($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function hotel_search(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->hotel_search($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function get_specific_hotel_content(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->get_specific_hotel_content($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function get_room_rates(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->get_room_rates($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function get_rate_rules(){
$data = (array) json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->get_rate_rules($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function hotel_book(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->hotel_book($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function trawex_cancel_booking(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->trawex_cancel_booking($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
/*********************************** END Hotel API ****************************************/
/********************************** START Flight API ***************************************/
public function flight_authenticate(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->flight_authenticate($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_availability_search(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->flight_availability_search($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_fare_rules(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->flight_fare_rules($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_revalidate(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->flight_revalidate($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_book(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $thia->Webservice_model->flight_book($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_ticket_order(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->flight_ticket_order($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_trip_details(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->flight_trip_details($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function cancel_flights(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->cancel_flights($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function airportSearch(){
$data = $_GET;
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_model->airportSearch($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
/******************************* END Flight API******************************************/
}
?>
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit(0);
}
//test changes
class WebserviceFlight extends CI_Controller {
var $auth_token;
public function __construct() {
parent::__construct();
date_default_timezone_set("Asia/Riyadh");
$this->load->model('Webservice_flight_model');
$this->load->model('Validation_flight_model');
$method = $this->router->fetch_method();
$data = (array) json_decode(file_get_contents('php://input'));
if (isset(apache_request_headers()['Auth']) || isset(apache_request_headers()['auth'])) {
$this->auth_token = (isset(apache_request_headers()['Auth']))?apache_request_headers()['Auth']:apache_request_headers()['auth'];
$data['auth_token'] = $this->auth_token;
}
$res = $this->Validation_flight_model->validation_check($method, $data);
if($res['state'] == 1) {
$this->errorResponse($res['response']['code'], $res['response']['message']);
die;
}
}
public function response($data) {
$result = array(
'status' => 'success',
'data' =>$data
);
print json_encode($result);
}
public function successResponse($data='') {
$result = array(
'status' => 'success',
);
print json_encode($result);
}
public function errorResponse($errorCode, $errorDesc) {
$result = array(
'status' => 'error',
'error'=> $errorCode,
'message'=> $errorDesc
);
print json_encode($result);
}
public function flight_authenticate(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->flight_authenticate($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_availability_search(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->flight_availability_search($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_fare_rules(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->flight_fare_rules($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_revalidate(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->flight_revalidate($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_book(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $thia->Webservice_flight_model->flight_book($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_ticket_order(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->flight_ticket_order($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function flight_trip_details(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->flight_trip_details($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function cancel_flights(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->cancel_flights($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function airportSearch(){
$data = $_GET;
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_flight_model->airportSearch($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
}
?>
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit(0);
}
//test changes
class WebserviceHotel extends CI_Controller {
var $auth_token;
public function __construct() {
parent::__construct();
date_default_timezone_set("Asia/Riyadh");
$this->load->model('Webservice_hotel_model');
$this->load->model('Validation_hotel_model');
$method = $this->router->fetch_method();
$data = (array) json_decode(file_get_contents('php://input'));
if (isset(apache_request_headers()['Auth']) || isset(apache_request_headers()['auth'])) {
$this->auth_token = (isset(apache_request_headers()['Auth']))?apache_request_headers()['Auth']:apache_request_headers()['auth'];
$data['auth_token'] = $this->auth_token;
}
$res = $this->Validation_hotel_model->validation_check($method, $data);
if($res['state'] == 1) {
$this->errorResponse($res['response']['code'], $res['response']['message']);
die;
}
}
public function response($data) {
$result = array(
'status' => 'success',
'data' =>$data
);
print json_encode($result);
}
public function successResponse($data='') {
$result = array(
'status' => 'success',
);
print json_encode($result);
}
public function errorResponse($errorCode, $errorDesc) {
$result = array(
'status' => 'error',
'error'=> $errorCode,
'message'=> $errorDesc
);
print json_encode($result);
}
public function get_hotel_city_list(){
$data = $_GET;
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_hotel_model->get_hotel_city_list($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function hotel_search(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_hotel_model->hotel_search($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function get_specific_hotel_content(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_hotel_model->get_specific_hotel_content($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function get_room_rates(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_hotel_model->get_room_rates($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function get_rate_rules(){
$data = (array) json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_hotel_model->get_rate_rules($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function hotel_book(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_hotel_model->hotel_book($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function trawex_cancel_booking(){
$data = (array)json_decode(file_get_contents('php://input'));
$data['auth_token'] = $this->auth_token;
$res = $this->Webservice_hotel_model->trawex_cancel_booking($data);
if($res['status'] == 1){
$this->response($res['data']);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
}
?>
......@@ -1078,12 +1078,6 @@ class Validation_app_model extends CI_Model {
'message' => 'Frequent Flyr Number Field is null or empty'
)
),
'adultmealplan' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Adult Meal Plan Field is null or empty'
)
),
'child_dob' => array(
'required' => array(
'code' => 'ER02',
......@@ -1132,12 +1126,6 @@ class Validation_app_model extends CI_Model {
'message' => 'Child Frequent Flyr Number is null or empty'
)
),
'childMealplan' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Child Meal Plan is null or empty'
)
),
'infant_dob' => array(
'required' => array(
'code' => 'ER02',
......@@ -1168,24 +1156,12 @@ class Validation_app_model extends CI_Model {
'message' => 'Infant Title is null or empty'
)
),
'infantMealplan' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Infant Meal Plan is null or empty'
)
),
'FareSourceCode' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Fare Source Code is null or empty'
)
),
'PostCode' => array(
'required' => array(
'code' => 'ER02',
'message' => 'PostCode is null or empty'
)
),
),
'flight_ticket_order'=>array(
'auth_token' => array(
......
<?php
class Validation_hotel_model extends CI_Model {
public $validation_array = array(
'get_hotel_city_list'=>array(),
'hotel_search'=>array(
'auth_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'User id is null or empty'
)
)
),
'get_specific_hotel_content'=>array(
'auth_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'User id is null or empty'
)
),
'hotelId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Hotel Id is null or empty'
)
),
'productId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Product Id is null or empty'
)
),
'sessionId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Session Id is null or empty'
)
),
'trackingId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Tracking Id is null or empty'
)
)
),
'get_room_rates'=>array(
'auth_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'User id is null or empty'
)
),
'TraceId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Trace Id is null or empty'
)
),
'propertyid' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Property Id is null or empty'
)
),
'trackingId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Tracking Id is null or empty'
)
),
'sessionId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Session Id is null or empty'
)
),
'productId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Product Id is null or empty'
)
),
'TokenId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Token Id is null or empty'
)
),
'resultindex' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Result Index Field is null or empty'
)
),
'hotelcode' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Hotel Code is null or empty'
)
),
),
'get_rate_rules'=>array(
'auth_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'User Id is null or empty'
)
),
'TokenId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Token Id is null or empty'
)
),
'TraceId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Trace Id is null or empty'
)
),
'allocationDetails' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Allocation Details is null or empty'
)
),
'booking_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Booking Token is null or empty'
)
),
'hotel_name' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Hotel Name is null or empty'
)
),
'hotelcode' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Hotel Code is null or empty'
)
),
'infosource' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Infosource Field is null or empty'
)
),
'meal_code' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Meal Code Field is null or empty'
)
),
'productId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Product Id is null or empty'
)
),
'propertyid' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Property Id is null or empty'
)
),
'rate_basis_id' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Rate Basis Id is null or empty'
)
),
'resultindex' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Result Index field is null or empty'
)
),
'room_code' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Room Code is null or empty'
)
),
'roomType_runno' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Room Type Runno Field is null or empty'
)
),
'sessionId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Session Id is null or empty'
)
),
'trackingId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Tracking Id is null or empty'
)
),
'boardCode' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Board Code Field is null or empty'
)
),
),
'hotel_book'=>array(
'auth_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'User Id is null or empty'
)
),
'TokenId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Token Id is null or empty'
)
),
'TraceId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Trace Id is null or empty'
)
),
'changedOccupancy' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Changed Occupancy Field is null or empty'
)
),
'extrabeds' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Extrabeds Field is null or empty'
)
),
'guests_details' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Guest Details field is null or empty'
)
),
'hotelcode' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Hotel Code is null or empty'
)
),
'refcode' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Refcode Field is null or empty'
)
),
'prebookingtoken' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Pre Booking Token is null or empty'
)
),
'productId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Product Id is null or empty'
)
),
'propertyid' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Property Id is null or empty'
)
),
'resultindex' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Result Index field is null or empty'
)
),
'sessionId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Session Id is null or empty'
)
),
'trackingId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Tracking Id is null or empty'
)
),
),
'trawex_cancel_booking'=>array(
'auth_token' => array(
'required' => array(
'code' => 'ER02',
'message' => 'User Id is null or empty'
)
),
'trackingId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Tracking Id is null or empty'
)
),
'productId' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Product Id is null or empty'
)
),
'supplierConfirmationNum' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Supplier Confirmation Number is null or empty'
)
),
'reference' => array(
'required' => array(
'code' => 'ER02',
'message' => 'Reference Id is null or empty'
)
),
),
);
public function validation_check($method_name, $parms) {
$state = 0;
$rules = $this->validation_array[$method_name];
$error_key = '';
foreach ($rules as $key => $value) {
foreach ($value as $keys => $values) {
switch ($keys) {
case 'required':
if(!isset($parms[$key]) || $parms[$key]=='' || $parms[$key]== null){
$state = 1;
$error_key = $values;
}
break;
case 'email':
if (isset($parms[$key]) && !filter_var($parms[$key], FILTER_VALIDATE_EMAIL)) {
$state = 1;
$error_key = $values;
}
break;
case 'phone':
if(isset($parms[$key])){
$phone = preg_replace('/[^0-9]/', '', $parms[$key]);
/*if (strlen($phone) !== 10) {
$state = 1;
$error_key = $values;
} */
}
break;
default:
# code...
break;
}
if($state==1){
break;
}
}
if($state==1){
break;
}
}
return array('state'=>$state,'response'=>$error_key);
}
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment