/** * */ public function actionTicket() { $params = ApiParams::getPostJsonParams(); $model = Validation::checkUserAuthorization($params); if ($model->errors) { Utils::echoErrorResponse($model->getFirstErrors()); } else { } }
public function actionViewAlert() { $params = ApiParams::getPostJsonParams(); $message = Validation::checkParamsAndGetMessage($params, ApiParams::$ACK_ALERT_PARAMS); if ($message->errors) { Utils::echoErrorResponse($message->getFirstErrors()); } else { //TODO ...... } }
public function actionGetRecipientsList() { $params = ApiParams::getPostJsonParams(); $model = Validation::checkUserAuthorization($params); if ($model->errors) { Utils::echoErrorResponse($model->getFirstErrors()); } else { $recipiens = Recipients::find()->asArray()->all(); $groups = Groups::find()->select('code')->asArray()->all(); $groups_members = $this->getGroupsMembers($groups); Utils::echoSuccessResponse($groups_members); } }
public static function setNewRecipientInfo($model, $info_type, $params) { try { $user_info = new RecipientMobileInfo(); $user_info->recipient_mobile_index = $model->index; $user_info->info_type = $info_type; $user_info->occured_at = Utils::getCurrentTime(); if (ApiParams::checkLocationParams($params)) { $user_info->pos_lat = $params[ApiParams::POS_LNG]; $user_info->pos_lng = $params[ApiParams::POS_LAT]; } elseif (ApiParams::checkIfThereAreNote($params)) { $user_info->note = $params[ApiParams::NOTE]; } return $user_info->save(); } catch (\Exception $e) { return $e; } }
public function actionChangeProfileInfo() { $params = ApiParams::getPostJsonParams(); $model = Validation::checkParams($params, ApiParams::$CHANGE_PROFILE_PARAMS); if ($model->errors) { Utils::echoErrorResponse($model->getFirstErrors()); } else { $model = RecipientMobileLogin::findOne([RecipientMobileLogin::INDEX => $model->recipient_mobile_index]); $setting = RecipientMobileSetting::findOne([RecipientMobileSetting::RECIPIENT_MOBILE_INDEX => $model->index]); $recipient = Recipients::find()->where(['code' => $model->recipient_code])->one(); $recipient->name = $params[ApiParams::USER_NAME]; $model->recipient_code = $params[ApiParams::USER_CODE]; $model->mobile_password = $params[ApiParams::USER_PASSWORD]; $setting->unlock_code = $params[ApiParams::UNLOCK_CODE]; $setting->location_support = $params[ApiParams::IS_LOCATION]; if (!$setting->save() || !$model->save() || !$recipient->save()) { Utils::echoErrorResponse("something went wrong with the server, please try again later"); } else { $response = $this->userJson($model, $setting); Utils::echoSuccessResponse($response); } } }
public static function checkParamsAndGetMessage($params, $require_params) { $model = ApiParams::checkRequiredParams($params, $require_params); if ($model->errors) { return $model; } else { $model = self::thisUserIsLogin($params[ApiParams::DEVICE_ID], $params[ApiParams::AUTH_KEY]); if ($model->errors) { return $model; } else { $message = Validation::checkMessage($params['cmsgOID']); return $message; } } }