/** * Retorna usuario a partir de su nombre de usuario (obtenido de la credencial) */ private function getUserByUsername() { $response = $this->dbUtils->getUser($this->requiredParametersReceived['credential'], true, false, true); if ($response != null) { return $response; } else { return ResponseUtils::getNonExistentResource(); } }
private function getLastMovements($userId, $count) { $response = $this->dbUtils->getLastMovements($userId, $count); if (count($response) > 0) { return $response; } else { return ResponseUtils::getNonExistentResource(); } }
private function returnSpecificPromo($idCampaign, $idPromo) { $utils = new PromoUtils($this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter')); $promo = $utils->getPromoFromCampaign($idCampaign, $idPromo); if ($promo != null) { return $promo->getFullData(); } else { return ResponseUtils::getNonExistentResource(); } }
/** * Retorna todas las campañas globales. * Directamente las obtiene de CampaingTable, no necesito de un ResponseManager (no se necesita parsear la peticion, obtener par opcionales,etc) * @return \Zend\View\Model\JsonModel */ public function getList() { $utils = $this->getServiceLocator()->get('CampaignUtils'); $campaignList = $utils->getAllCampaigns(); $result = array(); foreach ($campaignList as $campaign) { array_push($result, $campaign->getFullData()); } $callback = $this->getRequest()->getQuery(ResponseUtils::CALLBACK_PARAMETER); return ResponseUtils::getJson($result, $callback); }
public function getList() { // Retornar lista de tipos de movimientos que soporta el sistema $config = $this->getServiceLocator()->get('Config'); $movements = $config['movementsTypes']; $result = array(); foreach ($movements as $movement) { array_push($result, $movement->getFullData()); } $callback = $this->getRequest()->getQuery(ResponseUtils::CALLBACK_PARAMETER); return ResponseUtils::getJson($result, $callback); }
protected function getCampaign($onlyVersion) { $object = $this->dbUtils->getCampaign($this->requiredParametersReceived['id']); if ($object != null) { if ($onlyVersion) { return $object->getFullData(); } else { return $object->getVersionOnly(); } } else { return ResponseUtils::getNonExistentResource(); } }
/** * Retorn Json con todas las publicidades globales * @return \Zend\View\Model\JsonModel */ public function getList() { $utils = $this->getServiceLocator()->get('PromoUtils'); $promoList = $utils->getAllPromos(); $response = array(); if (count($promoList) > 0) { $result = array(); foreach ($promoList as $promo) { array_push($result, $promo->getFullData()); } $response = $result; } else { $response = ResponseUtils::getNonExistentResource(); } $callback = $this->getRequest()->getQuery(ResponseUtils::CALLBACK_PARAMETER); return ResponseUtils::getJson($response, $callback); }
/** * Retorn Json con el mapeo de montos a creditos (Datos extraidos de t_cotizacioncreditos a nivel global) * @return \Zend\View\Model\JsonModel */ public function getList() { $utils = $this->getServiceLocator()->get('MontoCreditsMapperUtils'); $mapEntries = $utils->getAllEntries(); $response = array(); if (count($mapEntries) > 0) { $result = array(); foreach ($mapEntries as $entry) { array_push($result, $entry->getFullData()); } $response = $result; } else { $response = ResponseUtils::getNonExistentResource(); } $callback = $this->getRequest()->getQuery(ResponseUtils::CALLBACK_PARAMETER); return ResponseUtils::getJson($response, $callback); }
public function indexAction() { $request = $this->getRequest(); switch ($request->getMethod()) { case 'GET': $loginParser = new GetLoginParser($request); $callback = $this->getRequest()->getQuery(ResponseUtils::CALLBACK_PARAMETER); break; case 'POST': $loginParser = new PostLoginParser($request); $callback = $this->getRequest()->getPost(ResponseUtils::CALLBACK_PARAMETER); break; } $parseRequest = $loginParser->getParseRequest(); if ($parseRequest[LoginParser::REQUEST_CODE]) { // parse OK $authResult = UserUtils::authenticateUser($loginParser->getUser(), $loginParser->getPass(), $this->getServiceLocator()->get('AuthService')); switch ($code = $authResult->getCode()) { case 1: $result = $this->returnSuccess(); break; case 0: $result = $this->returnError($code, LoginController::ERROR); break; case -1: $result = $this->returnError($code, LoginController::USERNAME_ERROR); break; case -2: $result = $this->returnError($code, Login); break; case -3: $result = $this->returnError($code, LoginController::PASSWORD_ERROR); break; } } else { $result = $this->returnRequestError($parseRequest); } return ResponseUtils::getJson($result, $callback); }
/** * Método que genera la respuesta a la petición basado en los parámetros que obtuvo. * Si faltan parámetros requeridos retornar error: * array ( * code => 0, * message => BAD REQUEST, * missing_parameter => {param_faltante} * ) * Si están todos los parámetros: * Primero actualizar los parámetros opcionales recibidos y luego retornar respuesta final: * La generación de la respuesta se sebe calcular en el método abstracto generateResponse(). * * Retorna la respuesta (response) */ public function obtainResponse() { $status = $this->checkRequiredParameters(); if (is_int($status)) { // no hay faltante de parámetros $this->updateOptionalParameters(); return ResponseUtils::getJson($this->generateResponse(), $this->checkOption(ResponseUtils::CALLBACK_PARAMETER)); } else { return $status; // retorno array que contiene error (Missing Parameter). } }