/**
  * get Single data of UpperHouse geo location by mongo id
  * @param  string $id
  * @return Hexcores\Api\Facades\Response
  */
 public function getById($id)
 {
     $geo = $this->model->find($id);
     if (!$geo) {
         return response_missing();
     }
     return response_ok($this->transform($geo, new GeoTransformer()));
 }
 /**
  * Get Faq By Question
  * @param  Illuminate\Http\Request $request
  * @return Hexcores\Api\Facades\Response
  */
 public function getFaqByQuestion(Request $request)
 {
     $question = $request->input('q');
     if (!$question) {
         return response_missing('U need Question Parameters');
     }
     $faq = $this->model->like('question', $question)->paginate();
     return response_ok($this->transform($faq, new FaqTransformer(), true));
 }
 /**
  * Authenticate the given request token is valid or not.
  *
  * @param  string $token
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function authenticate($token)
 {
     $token = Token::where('token', '=', $token)->first();
     if (is_null($token) || $token->disable) {
         $msg = is_null($token) ? 'Invalid token' : 'Application is disable';
         return response_unauthorized($msg);
     }
     return response_ok($token);
 }
Exemple #4
0
 /**
  * API to retrieve 
  * return type- 
  * created on - 09Th Sept 2015;
  * updated on - 
  * update 	  -
  * created by - Akshay Patil;
  */
 function get_forum()
 {
     $sb_hotel_guest_booking_id = $this->input->post('sb_hotel_guest_booking_id');
     if ($sb_hotel_guest_booking_id == '') {
         response_fail("Please Insert All data correctly");
     } else {
         $data = $this->Forum_model->get_forum($sb_hotel_guest_booking_id);
         $result = array('result' => $data);
         response_ok($result);
     }
 }
 /**
  * this API is to get hotel menu
  * return type- 
  * created on - 16th Oct 2015;
  * updated on - 
  * update 	  -
  * created by - Akshay Patil;
  */
 function gethotelmenu()
 {
     header('Access-Control-Allow-Origin: *');
     $sb_hotel_id = $this->input->post('sb_hotel_id');
     if ($sb_hotel_id == '') {
         response_fail("Please Insert All data correctly");
     } else {
         $result = $this->Hotelmenu_model->gethotelmenu($sb_hotel_id);
         response_ok($result);
     }
 }
Exemple #6
0
 public function insert_feedback()
 {
     // print_r($this->input->post());
     $rate_stay = $this->input->post('rate_stay');
     $improve_feedback = $this->input->post('improve_feedback');
     $service_feedback = $this->input->post('service_feedback');
     $special_info = $this->input->post('special_info');
     $sb_hotel_id = $this->input->post('sb_hotel_id');
     $guest_booking_id = $this->input->post('sb_hotel_guest_booking_id');
     if ($sb_hotel_id == '' || $guest_booking_id == '') {
         response_fail("Hotel id or Guest Booking ID is missing");
     } else {
         $insert_arr = array("rate_stay" => $rate_stay, "improve_feedback" => $improve_feedback, "service_feedback" => $service_feedback, "special_info" => $special_info, "sb_hotel_id" => $sb_hotel_id, "guest_booking_id" => $guest_booking_id);
         // print_r($insert_arr); die();
         $result = $this->Feedback_model->insert_feedbck($insert_arr);
         if ($result == 0) {
             response_fail("Some error occoured.. Please try again");
         } else {
             response_ok();
         }
     }
 }
 /**
  * Generate the token for given api key.
  *
  * @param  string $key
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function generate($key)
 {
     $app = Application::where('key', '=', $key)->first();
     if (is_null($app) || $app->disable) {
         $msg = is_null($app) ? 'Invalid app key' : 'Application is disable';
         return response_unauthorized($msg);
     }
     $tokenValue = $this->getUUID5Token($app);
     if ($tokenValue) {
         $token = new Token();
         $token->app_id = $app->id;
         // Application ID
         $token->app_key = $app->key;
         // Application Key
         $token->user_id = $app->user_id;
         // Application owner id
         $token->token = $tokenValue;
         // Token for unique user.
         if ($token->save()) {
             return response_ok($token);
         }
     }
     return response_error('Error occured to generate token. Please try again');
 }
 private function getAnalyticData($url, $query = [])
 {
     $client = new Client(['base_uri' => $this->base_url]);
     try {
         $response = $client->get($url, ['headers' => ['X-API-KEY' => $this->api_key, 'X-API-SECRET' => $this->api_secret], 'query' => $query]);
     } catch (\Exception $e) {
         return response_error("Internal Server Error.");
     }
     switch ($response->getStatusCode()) {
         case 500:
             return response_error("Internal Server Error.");
             break;
         case 401:
             response_unauthorized();
             break;
         case 404:
             return response_missing();
             break;
         case 200:
             return response_ok(json_decode($response->getBody()->getContents()));
             break;
     }
     return response_error("Internal Server Error.");
 }
 /**
  * Generate User Token
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  **/
 public function generateToken(Request $request)
 {
     if ($request->has('api_key')) {
         $apiKey = $request->input('api_key');
         $authUrl = config('app.auth');
         $client = new Client(['base_url' => $authUrl['base_url']]);
         $headers = ['X-API-KEY' => env('AUTH_APP_KEY'), 'X-API-SECRET' => env('AUTH_APP_SECRET')];
         try {
             $tokenResponse = $client->get($authUrl['token_uri'] . '/' . $apiKey, ['headers' => $headers]);
         } catch (ClientException $e) {
             $tokenResponse = $e->getResponse();
         }
         switch ($tokenResponse->getStatusCode()) {
             case 200:
                 $responseData = $tokenResponse->json();
                 return response_ok(['_meta' => ['status' => 'ok', 'count' => 1, 'api_version' => 1], 'data' => ['token' => $responseData['token']]]);
                 break;
             case 500:
                 return response_error("Something wrong with token generate process");
                 break;
             default:
                 return response()->json($tokenResponse->json(), $tokenResponse->getStatusCode());
                 break;
         }
     }
     return response_missing("You must pass your 'api_key' to generate user token.");
 }
Exemple #10
0
 /**
  * This function will change password
  * return type- 
  * created on - 22th July 2015;
  * updated on - 
  * created by - Akshay Patil;
  */
 public function change_password()
 {
     $sb_hotel_user_id = $this->input->post('sb_hotel_user_id');
     $sb_hotel_userpasswd = $this->input->post('old_password');
     $newpassword = $this->input->post('new_password');
     if ($sb_hotel_user_id == '' || $sb_hotel_userpasswd == '' || $newpassword == '') {
         response_fail("Input may be empty");
     } else {
         $arr = array();
         $arr['sb_hotel_user_id'] = $sb_hotel_user_id;
         $password = $this->User_model->check_user($arr);
         if (count($password) <= 0) {
             response_fail("Email is wrong");
         } else {
             if (verifyPasswordHash($sb_hotel_userpasswd, $password[0]['sb_hotel_userpasswd']) == TRUE) {
                 $arr1['sb_hotel_userpasswd'] = createHashAndSalt($newpassword);
                 $user_info1 = $this->User_model->update_user($arr1, $arr);
                 response_ok();
             } else {
                 response_fail("Something is wrong");
             }
         }
     }
 }
Exemple #11
0
 public function hotel_customer()
 {
     // print_r($_POST); die();
     $sb_guest_firstName = $this->input->post('sb_guest_firstName');
     $sb_guest_lastName = $this->input->post('sb_guest_lastName');
     $sb_guest_email = $this->input->post('sb_guest_email');
     $sb_hotel_id = $this->input->post('sb_hotel_id');
     if ($sb_hotel_id == '' || $sb_guest_email == '') {
         response_fail("Please insert all the fields");
     }
     $cdt_token = $this->input->post('cdt_token');
     $cdt_deviceType = $this->input->post('cdt_deviceType');
     $cdt_macid = $this->input->post('cdt_macid');
     $check_reservation = $this->User_model->check_reservation($sb_guest_email, $sb_hotel_id);
     if (count($check_reservation) > 0) {
         $sb_guest_reservation_code = $check_reservation[0]['sb_guest_reservation_code'];
         $this->login($sb_guest_reservation_code, $cdt_token, $cdt_deviceType, $cdt_macid);
     } else {
         $date = date_create();
         $sb_guest_reservation_code = $sb_hotel_id . date_timestamp_get($date) . rand();
         $insert_arr = array("sb_guest_firstName" => $sb_guest_firstName, "sb_guest_lastName" => $sb_guest_lastName, "sb_guest_email" => $sb_guest_email, "sb_hotel_id" => $sb_hotel_id, "sb_guest_reservation_code" => $sb_guest_reservation_code);
         $sb_hotel_guest_booking_id = $this->User_model->register_visitor($insert_arr);
         if ($sb_hotel_guest_booking_id != 0) {
             $data = $this->login($sb_guest_reservation_code, $cdt_token, $cdt_deviceType, $cdt_macid);
             response_ok($data);
         } else {
             response_fail("ErrorCode#2,Something Went Wrong");
         }
     }
 }
 /**
  * Get candidate list
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function candidateList()
 {
     $data = $this->transform($this->query(), new CandidateTransformer(), true);
     return response_ok($data);
 }
Exemple #13
0
 /**
  * This API allow staff to reject item order
  * return type- 
  * created on - 20th AUG 2015;
  * updated on - 
  * created by - Akshay Patil;
  */
 public function reject_order_item()
 {
     $order_placed_id = $this->input->post('order_placed_id');
     if ($order_placed_id == '') {
         response_fail("Please Insert All data correctly");
     } else {
         $res = $this->Tasks_model->check_order_item($order_placed_id);
         if ($res === 1) {
             response_fail("This item is already rejected");
         } elseif ($res === 0) {
             $val = $this->Tasks_model->reject_order_item($order_placed_id);
             response_ok();
         } else {
             response_fail("Please try after some time");
         }
     }
 }
 /**
  * This function will provide latest price and status of paid services
  * return type- 
  * created on - 24st aug 2015;
  * updated on - 
  * created by - Akshay Patil;
  * updated by - 
  */
 public function get_paid_service_status()
 {
     $sub_child_services_id = trim($this->input->post('sub_child_services_id'));
     $paid_service = $this->User_order_model->get_paid_service_status($sub_child_services_id);
     $result = array('result' => $paid_service);
     response_ok($result);
 }
Exemple #15
0
 function insert_chat()
 {
     $type = $this->input->post('type');
     if ($type != 'request' and $type != 'order') {
         response_fail("ErrorCode#1, Somthing went wrong, Please Logout and login again");
     }
     if ($type == 'request' || $type == 'order') {
         $sb_hotel_requst_ser_id = $this->input->post('sb_hotel_requst_ser_id');
         if ($sb_hotel_requst_ser_id == '') {
             response_fail("ErrorCode#2, Somthing went wrong, Please Logout and login again");
         }
         $data = $this->Chat_model->get_request($sb_hotel_requst_ser_id);
         if ($data > 0) {
             $sb_sender_type = $this->input->post('sb_sender_type');
             $sb_chat_message = trim($this->input->post('sb_chat_message'));
             if ($sb_sender_type == '' || $sb_chat_message == '') {
                 response_fail("ErrorCode#4, Somthing went wrong, Please Logout and login again");
             } else {
                 $insert_arr = array('sb_hotel_requst_ser_id' => $sb_hotel_requst_ser_id, 'sb_sender_type' => $sb_sender_type, 'sb_chat_message' => $sb_chat_message);
                 $result = $this->Chat_model->insert_chat($insert_arr);
                 // print_r($result); die()
                 if ($result) {
                     $id = $this->Chat_model->get_ids($sb_hotel_requst_ser_id, $sb_sender_type);
                     if ($id) {
                         $token = $this->Chat_model->get_token($id, $sb_sender_type);
                         //print_r($token); die();
                         if (count($token) > 0) {
                             $user_name = $this->Chat_model->get_name($id, $sb_sender_type);
                             //print_r($user_name); die();
                             $title = "New Message";
                             // from : ".$user_name ;
                             $message = array("type" => 'Message', "message" => $sb_chat_message, "title" => $title, "id" => $sb_hotel_requst_ser_id);
                             $android_token = array();
                             $ios_token = array();
                             for ($i = 0; $i < count($token); $i++) {
                                 if ($token[$i]['sdt_deviceType'] == 'android' and $token[$i]['sdt_token'] != NULL and $token[$i]['sdt_token'] != null) {
                                     array_push($android_token, $token[$i]['sdt_token']);
                                 } else {
                                     if ($token[$i]['sdt_token'] != "" and $token[$i]['sdt_token'] != NULL and $token[$i]['sdt_token'] != null) {
                                         array_push($ios_token, $token[$i]['sdt_token']);
                                     }
                                 }
                             }
                             if ($sb_sender_type == 1) {
                                 $userType = "staff";
                             } else {
                                 $userType = "customer";
                             }
                             if (count($ios_token) > 0) {
                                 $ipushdata = array('deviceToken' => $ios_token, 'user' => $userType, 'message' => $message);
                                 $this->load->library('api/Iospush');
                                 $val = $this->iospush->iospush_notification($ipushdata);
                             }
                             // array for android
                             if (count($android_token) > 0) {
                                 $pushdata = array('message' => $message, 'deviceTokens' => $android_token, 'user' => $userType);
                                 $this->load->library('api/Android_push');
                                 $val1 = $this->android_push->push_notification($pushdata);
                             }
                         }
                         response_ok();
                     } else {
                         response_fail("No such user exists");
                     }
                 } else {
                     response_fail("Notification not inserted.. Please try again");
                 }
             }
         } else {
             response_fail("ErrorCode#3, Somthing went wrong, Please Logout and login again");
         }
     }
 }