/**
  * Register devices when app launches
  * @return json
  */
 public function registerDevice()
 {
     $deviceType = Input::get('type');
     $pushToken = trim(Input::get('push_token'));
     $headers = getallheaders();
     if (!empty($headers['Device-Id']) && !empty($deviceType) && !empty($pushToken)) {
         $deviceTypesAvailable = Config::get('constants.deviceTypes');
         if (in_array($deviceType, $deviceTypesAvailable)) {
             $data = $this->objectDeviceService->registerDevice($headers['Device-Id'], $deviceType, $pushToken);
             return ResponseHelper::jsonResponse($data['status'], $data['statusCode'], $data['data'], $data['error']);
         } else {
             return ResponseHelper::jsonResponse(config::get('constants.ERROR'), 200, NULL, Config::get('constants.errorMessages.invalid_device'));
         }
     } else {
         return ResponseHelper::jsonResponse(config::get('constants.ERROR'), 200, NULL, Config::get('constants.errorMessages.parameter_missing'));
     }
 }
예제 #2
0
 /**
  * To create and return json response for all apis
  * @return json
  */
 public function createJsonResponse()
 {
     return ResponseHelper::jsonResponse($this->responseData['status'], $this->responseData['statusCode'], $this->responseData['data'], $this->responseData['error'], $this->responseData['access_token']);
 }