/** * Responds with information about updated vertical * * @method put * @return json/xml data */ public function put($id) { $results = array(); $vertical = Verticals::findFirstById($id); if ($vertical != false) { $verticalsCollection = VerticalsCollection::findFirst(array(array('id' => $id))); if ($verticalsCollection != false) { $verticalsCollection->id = $vertical->id; $verticalsCollection->name = $vertical->name; $verticalsCollection->description = $vertical->description; $verticalsCollection->status = $vertical->status; $verticalsCollection->active = $vertical->active; $verticalsCollection->created = $vertical->created; $verticalsCollection->modified = $vertical->modified; $verticalsCollection->createdBy = $vertical->createdBy; $verticalsCollection->modifiedBy = $vertical->modifiedBy; $verticalsCollection->save(); $results['id'] = $vertical->id; } } return $results; }
/** * @api {post} /verticals/search/:id POST /verticals/search/:id * @apiExample Example usage: * curl -H "X-COMPARE-REST-API-KEY: 1234567890" * -i -X POST"http://apibeta.compargo.com/v1/verticals/56c4b6c2-1d54-11e4-b32d-eff91066cccf/?countryCode=ph&language=en" * @apiDescription Read data of a Vertical * @apiName searchOne * @apiGroup Verticals * * @apiHeader {String} X-COMPARE-REST-API-KEY Verticals unique access-key. * * @apiParam {String} language Mandatory Language. * @apiParam {String} countryCode Mandatory Country Code. * @apiParam {String} id Mandatory Vertical unique ID. * * @apiSuccess {String} id ID of the Vertical. * @apiSuccess {String} name Name of the Vertical. * @apiSuccess {String} description Lastname of the Vertical. * @apiSuccess {Number} status Status of the Vertical. * @apiSuccess {Number} active Flag of the Vertical. * @apiSuccess {Date} created Creation date of the Vertical. * @apiSuccess {Date} modified Modification date of the Vertical. * @apiSuccess {String} createdBy ID of the User who created the Vertical. * @apiSuccess {String} modifiedBy ID of the User who modified the Vertical. * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * { * "id": "07f44e24-1d43-11e4-b32d-eff91066cccf", * "name": "Money", * "description": "Money", * "status": "1", * "active": "1", * "created": "2014-08-06 10:24:06", * "modified": "2014-08-07 03:06:37", * "createdBy": "a8838d12-1dcc-11e4-b32d-eff91066cccf", * "modifiedBy": "a8838d12-1dcc-11e4-b32d-eff91066cccf" * } * * @apiError VerticalNotFound The id of the Vertical was not found. * * @apiErrorExample Error-Response: * HTTP/1.1 404 Not Found * { * "error": "VerticalNotFound" * } * * @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('request'); $parameters = $request->getPost(); if (count($parameters) > 1) { $vertical = new VerticalsCollection($this->di); $results = $this->respond($vertical, $id); } else { $results = VerticalsCollection::find(array(array("id" => $id))); } if (!$results) { throw new HTTPException("Not found", 404, array('dev' => 'Vertical does not exist', 'internalCode' => 'P1000', 'more' => '')); } return $results; }