/** * @api {post} /products_options/search/:id POST /products_options/search/:id * @apiExample Example usage: * curl -H "X-COMPARE-REST-API-KEY: 1234567890" * -i -X POST "http://apibeta.compargo.com/v1/products_options/e8227346-3a61-11e4-b18a-fe7344fb1ea4/?countryCode=ph&language=en" * * @apiDescription Read data of a Products Options * @apiName SearchOne * @apiGroup Products Options * * @apiHeader {String} X-COMPARE-REST-API-KEY Products Options unique access-key. * * @apiParam {String} language Mandatory Language. * @apiParam {String} countryCode Mandatory Country Code. * @apiParam {String} id Mandatory Products Options unique ID. * * @apiSuccess {String} id ID of the Products Option. * @apiSuccess {String} productId Product ID of the Products Option. * @apiSuccess {String} areaID Area ID of the Products Option. * @apiSuccess {String} name Name of the Products Option. * @apiSuccess {String} value Value of the Products Option. * @apiSuccess {String} label Label of the Products Option. * @apiSuccess {String} editable Editable Flag of the Products Option. * @apiSuccess {String} visibility Visibility Flag of the Products Option. * @apiSuccess {Number} status Status Flag of the Products Option. * @apiSuccess {Number} active Active Flag of the Products Option. * @apiSuccess {Date} created Creation date of the Products Option. * @apiSuccess {Date} modified Modification date of the Products Option. * @apiSuccess {String} createdBy ID of the User who created the Products Option. * @apiSuccess {String} modifiedBy ID of the User who modified the Products Option. * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * { * "id": "e8227346-3a61-11e4-b18a-fe7344fb1ea4", * "productId": "72c28c74-3a45-11e4-b18a-fe7344fb1ea4", * "areaId": "0b412a0e-397a-11e4-b18a-fe7344fb1ea4", * "name": "featured", * "value": "0", * "label": null, * "editable": null, * "visibility": null, * "status": "1", * "created": "2014-07-11 09:13:27", * "modified": "2014-07-11 09:52:08", * "createdBy": "a8838d12-1dcc-11e4-b32d-eff91066cccf", * "modifiedBy": "c6bcb740-1dcc-11e4-b32d-eff91066cccf" * } * * @apiError ProductsOptionNotFound The id of the Products Option was not found. * * @apiErrorExample Error-Response: * HTTP/1.1 404 Not Found * { * "error": "ProductsOptionNotFound" * } * * @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) { $productsOptions = new ProductsOptionsCollection($this->di); $results = $this->respond($productsOptions, $id); } else { $results = ProductsOptionsCollection::findFirstById($id); } if (!$results) { throw new HTTPException("Not found", 404, array('dev' => 'Products option does not exist', 'internalCode' => 'P1000', 'more' => '')); } return $results; }