Example #1
0
 /**
  * Fetch a resource
  *
  * @api {get} API_DOMAIN/ginosi-tally/user/:user_id/pin/:pin User Pins
  * @apiVersion 1.0.0
  * @apiName  UserPins
  * @apiGroup User
  * @apiDescription This method check user pin code and return status.
  *
  * @apiHeader {String} Content-Type application/json
  * @apiHeader {String} Authorization Bearer ACCESS_TOKEN
  *
  * @apiSuccess {Boolean}  status               Response status
  * @apiSuccess {String}   message              Response message
  *
  * @apiSuccessExample {json} Sample Response:
  *     HTTP/1.1 200 OK
  *     {
  *         "status":  true,
  *         "message": "Success"
  *     }
  *
  * @param  int $pin
  * @return ApiProblem|array
  */
 public function fetch($pin)
 {
     try {
         $requestHandler = $this->serviceLocator->get('Service\\RequestHandler');
         $request = $this->serviceLocator->get('request');
         $userId = $this->serviceLocator->get('router')->match($request)->getParam("user_id");
         $pin = $this->serviceLocator->get('router')->match($request)->getParam("pin");
         $userManagerDao = new \DDD\Dao\User\UserManager($this->serviceLocator, 'ArrayObject');
         $user = $userManagerDao->getUserByIdAndPin($userId, $pin);
         if (!$user) {
             return new ApiProblem(404, 'Pin code is incorrect');
         }
         return ['status' => true, 'message' => 'Success'];
     } catch (\Exception $e) {
         return $requestHandler->handleException($e);
     }
 }
Example #2
0
 /**
  * @api {get} API_DOMAIN/users User List
  * @apiVersion 1.0.0
  * @apiName GetUser
  * @apiGroup User
  *
  * @apiDescription This method returns the list of all users
  *
  * @apiHeader {String} Content-Type application/json
  * @apiHeader {String} Authorization Bearer ACCESS_TOKEN
  *
  * @apiSuccess {Int} id The unique identification of the user
  * @apiSuccess {String} firstname  The first name of the user
  * @apiSuccess {String} lastname  The last name of the user
  *
  * @apiSuccessExample {json} Sample Response:
  *     HTTP/1.1 200 OK
  *     [
  *         {
  *             "id": "12",
  *             "firstname": "App",
  *             "lastname": "User",
  *         }
  *     ]
  *
  * @param array $params
  * @return \Zend\Db\ResultSet\ResultSet
  */
 public function fetchAll($params = array())
 {
     try {
         $auth = $this->serviceLocator->get('library_backoffice_auth');
         $requestHandler = $this->serviceLocator->get('Service\\RequestHandler');
         $userManagerDao = new \DDD\Dao\User\UserManager($this->serviceLocator, 'ArrayObject');
         $countryId = $auth->getIdentity()->countryId;
         $usersInfo = $userManagerDao->getUserByCountry($countryId);
         return $usersInfo;
     } catch (\Exception $e) {
         return $requestHandler->handleException($e);
     }
 }
Example #3
0
 /**
  * @api {get} API_DOMAIN/ginosi-link/users User List
  * @apiVersion 1.0.0
  * @apiName GetUser
  * @apiGroup User
  *
  * @apiDescription This method returns the list of all users
  *
  * @apiHeader {String} Content-Type application/json
  * @apiHeader {String} Authorization Bearer ACCESS_TOKEN
  *
  * @apiSuccess {Int}    id         The unique identification of the user
  * @apiSuccess {String} firstname  The first name of the user
  * @apiSuccess {String} lastname   The last name of the user
  * @apiSuccess {String} avatar     The profile picture of the user
  *
  * @apiSuccessExample {json} Sample Response:
  *     HTTP/1.1 200 OK
  *     [
  *         {
  *             "id": "12",
  *             "firstname": "App",
  *             "lastname": "User",
  *             "avatar": "https://images.ginosi.com/profile/12/1439802421_0_150.png"
  *         }
  *     ]
  *
  * @param array $params
  * @return \Zend\Db\ResultSet\ResultSet
  */
 public function fetchAll($params = array())
 {
     try {
         $auth = $this->serviceLocator->get('library_backoffice_auth');
         $requestHandler = $this->serviceLocator->get('Service\\RequestHandler');
         $userManagerDao = new \DDD\Dao\User\UserManager($this->serviceLocator, 'ArrayObject');
         $countryId = $auth->getIdentity()->countryId;
         $usersInfo = $userManagerDao->getUserByCountry($countryId, ['id', 'firstname', 'lastname', 'avatar']);
         $usersInfoArray = [];
         foreach ($usersInfo as $userInfo) {
             $userInfo['avatar'] = 'https:' . Helper::getUserAvatar($userInfo, 'big');
             $usersInfoArray[] = $userInfo;
         }
         return $usersInfoArray;
     } catch (\Exception $e) {
         return $requestHandler->handleException($e);
     }
 }