Exemplo n.º 1
0
 /**
  * Responds with information about updated inserted area
  *
  * @method post
  * @return json/xml data
  */
 public function put($id)
 {
     $results = array();
     $area = Areas::findFirstById($id);
     if ($area) {
         $areasCollection = AreasCollection::findFirst(array(array('id' => $id)));
         if ($areasCollection != false) {
             $areasCollection->id = $area->id;
             $areasCollection->name = $area->name;
             $areasCollection->category = $area->category;
             $areasCollection->description = $area->description;
             $areasCollection->language = $area->language;
             $areasCollection->bounds = $area->bounds;
             $areasCollection->parentId = $area->parentId;
             $areasCollection->lft = $area->lft;
             $areasCollection->rght = $area->rght;
             $areasCollection->scope = $area->scope;
             $areasCollection->status = $area->status;
             $areasCollection->active = $area->active;
             $areasCollection->created = $area->created;
             $areasCollection->modified = $area->modified;
             $areasCollection->createdBy = $area->createdBy;
             $areasCollection->modifiedBy = $area->modifiedBy;
             $areasCollection->save();
             $results['id'] = $area->id;
         }
     }
     return $results;
 }
Exemplo n.º 2
0
 /**
  * @api {post} /areas/search/:id POST /areas/search/:id
  * @apiExample Example usage:
  * curl -H "X-COMPARE-REST-API-KEY: 1234567890" 
  *      -i -X POST"http://apibeta.compargo.com/v1/areas/56c4b6c2-1d54-11e4-b32d-eff91066cccf/?countryCode=ph&language=en"
  * @apiDescription Read data of an Area
  * @apiName        SearchOne
  * @apiGroup       Areas
  *
  * @apiHeader      {String} X-COMPARE-REST-API-KEY   Areas unique access-key.
  *
  * @apiParam       {String} language                 Mandatory Language.
  * @apiParam       {String} countryCode              Mandatory Country Code.
  * @apiParam       {String} id                       Mandatory Area unique ID.
  *
  * @apiSuccess     {String} id                       ID of the Area. 
  * @apiSuccess     {String} name                     Name of the Area.
  * @apiSuccess     {String} category                 Category of the Area.
  * @apiSuccess     {String} description              Description of the Area.
  * @apiSuccess     {String} bounds                   Bounds of the Area. 
  * @apiSuccess     {String} parentId                 Parent ID of the Area.
  * @apiSuccess     {String} lft                      Lft of the Area.
  * @apiSuccess     {String} rght                     Rght of the Area.
  * @apiSuccess     {String} scope                    Scope of the Area.
  * @apiSuccess     {Number} editable                 Editable Flag of the Area.
  * @apiSuccess     {Number} visibility               Visibility Flag of the Area.
  * @apiSuccess     {Number} status                   Status Flag of the Area.
  * @apiSuccess     {Number} active                   Active Flag of the Area.
  * @apiSuccess     {Date}   created                  Creation date of the Area.
  * @apiSuccess     {Date}   modified                 Modification date of the Area.
  * @apiSuccess     {String} createdBy                ID of the User who created the Area.
  * @apiSuccess     {String} modifiedBy               ID of the User who modified the Area.
  * 
  * @apiSuccessExample Success-Response:
  *     HTTP/1.1 200 OK
  *     {
  *       "id": "337b6f34-2282-11e4-b700-0b28aad944c8",
  *       "name": "NCR",
  *       "category": "Region",
  *       "description": "National Capital Region (NCR) of the Philippines, is the seat of government and the most populous region and metropolitan area of the country which is composed of the City of Manila and the cities of Caloocan, Las Pi–as, Makati, Malabon, Mandaluyong, Marikina, Muntinlupa, Navotas, Para–aque, Pasay, Pasig, Quezon City, San Juan, Taguig, and Valenzuela, as well as the Municipality of Pateros.",
  *       "language": "en",
  *       "bounds": "",
  *       "parentId": "",
  *       "lft": "",
  *       "rght": "",
  *       "scope": "",
  *       "status": "1",
  *       "active": "1",
  *       "created": "2014-08-13 02:38:53",
  *       "modified": "2014-08-13 02:42:55",
  *       "createdBy": "a8838d12-1dcc-11e4-b32d-eff91066cccf",
  *       "modifiedBy": "a8838d12-1dcc-11e4-b32d-eff91066cccf"
  *     }
  *
  * @apiError AreaNotFound The id of the Area was not found.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 404 Not Found
  *     {
  *       "error": "AreaNotFound"
  *     }
  *
  * @apiError InvalidAccessToken The access token is invalid.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 401 Unauthorized
  *     {
  *       "error": "InvalidAccessToken"
  *     }
  *
  * @apiError MissingAuthenticationCredentials The authentication credentials are missing.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 401 Unauthorized
  *     {
  *       "error": "MissingAuthenticationCredentials"
  *     }
  */
 public function searchOne($id)
 {
     $results = array();
     $request = $this->di->get('requestBody');
     $parameters = $request->get();
     if (count($parameters) > 1) {
         $area = new AreasCollection($this->di);
         $results = $this->respond($id, $area);
     } else {
         $results = AreasCollection::findFirstById($id);
     }
     if (!$results) {
         throw new HTTPException("Not found", 404, array('dev' => 'Area does not exist', 'internalCode' => 'P1000', 'more' => ''));
     }
     return $results;
 }