/** * @api {get} /country/search/:id GET /country/search/:id * @apiExample Example usage: * curl -H "X-COMPARE-REST-API-KEY: 1234567890" * -i "http://apibeta.compargo.com/v1/country/search/4de2ec7a-22b5-11e4-bd33-17609cecca2f/?countryCode=ph&language=en" * * @apiDescription Read data of a Country * @apiName SearchOne * @apiGroup Country * * @apiHeader {String} X-COMPARE-REST-API-KEY Country unique access-key. * * @apiParam {String} language Mandatory Language. * @apiParam {String} countryCode Mandatory Country Code. * @apiParam {String} id Mandatory Country unique ID. * * @apiSuccess {String} id ID of the Country. * @apiSuccess {String} name Name of the Country. * @apiSuccess {String} alias Alias of the Country. * @apiSuccess {String} description Description of the Country. * @apiSuccess {Number} status Status of the Country. * @apiSuccess {Number} active Flag of the Country. * @apiSuccess {Date} created Creation date of the Country. * @apiSuccess {Date} modified Modification date of the Country. * @apiSuccess {String} createdBy ID of the User who created the Country. * @apiSuccess {String} modifiedBy ID of the User who modified the Country. * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * { * "id": "4de2ec7a-22b5-11e4-bd33-17609cecca2f", * "name": "Philippines", * "description": "", * "status": "1", * "active": "1", * "created": "2014-08-13 08:44:42", * "modified": "0000-00-00 00:00:00", * "createdBy": "a8838d12-1dcc-11e4-b32d-eff91066cccf", * "modifiedBy": "a8838d12-1dcc-11e4-b32d-eff91066cccf" * } * * @apiError CountryNotFound The id of the Country was not found. * * @apiErrorExample Error-Response: * HTTP/1.1 404 Not Found * { * "error": "CountryNotFound" * } * * @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" * } * * @apiError RouteNotFound That route was not found on the server. * * @apiErrorExample Error-Response: * HTTP/1.1 404 * { * "error": "RouteNotFound" * } * */ public function searchOne($id) { $results = array(); $request = $this->di->get('requestBody'); $parameters = $request->get(); if (count($parameters) > 1) { $country = new CountryCollection($this->di); $results = $this->respond($country, $id); } else { $results = CountryCollection::find(array(array("id" => $id))); } if (!$results) { throw new HTTPException("Not found", 404, array('dev' => 'Country does not exist', 'internalCode' => 'P1000', 'more' => '')); } return $results; }