/**
  * @api {post} /country_options/search/:id POST /country_options/search/:id
  * @apiExample Example usage:
  * curl -H "X-COMPARE-REST-API-KEY: 1234567890"
  *      -i "http://apibeta.compargo.com/v1/country_options/search/05a5ec26-372a-11e4-b18a-fe7344fb1ea4/?countryCode=ph&language=en"
  *
  * @apiDescription Read data of a Countries Options
  * @apiName        SearchOne
  * @apiGroup       Country Options
  *
  * @apiHeader      {String} X-COMPARE-REST-API-KEY   Country Options unique access-key.
  *
  * @apiParam       {String} language                 Mandatory Language.
  * @apiParam       {String} countryCode              Mandatory Country Code.
  * @apiParam       {String} id                       Mandatory Countries Options unique ID.
  *
  * @apiSuccess     {String} id                       ID of the Country Options.
  * @apiSuccess     {String} countryId                Country ID of the Country Options.
  * @apiSuccess     {String} name                     Name of the Channels Options.
  * @apiSuccess     {String} value                    Value of the Channels Options.
  * @apiSuccess     {String} label                    Label of the Channels Options.
  * @apiSuccess     {String} editable                 Editable Flag of the Country Options.
  * @apiSuccess     {String} visibility               Visibility Flag of the Country Options.
  * @apiSuccess     {Number} status                   Status Flag of the Country Options.
  * @apiSuccess     {Number} active                   Active Flag of the Country Options.
  * @apiSuccess     {Date}   created                  Creation date of the Country Options.
  * @apiSuccess     {Date}   modified                 Modification date of the Country Options.
  * @apiSuccess     {String} createdBy                ID of the User who created the Country Options.
  * @apiSuccess     {String} modifiedBy               ID of the User who modified the Country Options.
  *
  * @apiSuccessExample Success-Response:
  *     HTTP/1.1 200 OK
  *     {
  *       "id": "1535ebcc-22b8-11e4-bd33-17609cecca2f",
  *       "name": "iso2",
  *       "description": "",
  *       "editable": "1",
  *       "visibility": "1",
  *       "status": "1"
  *     }
  *
  * @apiError CountryOptionNotFound The id of the Country Option was not found.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 404 Not Found
  *     {
  *       "error": "CountryOptionNotFound"
  *     }
  *
  * @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) {
         $countryOptions = new CountryOptionsCollection($this->di);
         $results = $this->respond($countryOptions, $id);
     } else {
         $results = CountryOptionsCollection::find(array(array("id" => $id)));
     }
     if (!$results) {
         throw new HTTPException("Not found", 404, array('dev' => 'Country option does not exist', 'internalCode' => 'P1000', 'more' => ''));
     }
     return $results;
 }
 /**
  * Responds with information about updated inserted company
  *
  * @method post
  * @return json/xml data
  */
 public function put($id)
 {
     $results = array();
     $countryOption = CountryOptions::findFirstById($id);
     if ($countryOption) {
         $countryOptionsCollection = CountryOptionsCollection::findFirst(array(array('id' => $id)));
         if ($countryOptionsCollection != false) {
             $countryOptionCollection->id = $countryOption->id;
             $countryOptionCollection->countryId = $countryOption->countryId;
             $countryOptionCollection->name = $countryOption->name;
             $countryOptionCollection->value = $countryOption->value;
             $countryOptionCollection->label = $countryOption->label;
             $countryOptionCollection->status = $countryOption->status;
             $countryOptionCollection->active = $countryOption->active;
             $countryOptionCollection->editable = $countryOption->editable;
             $countryOptionCollection->visibility = $countryOption->active;
             $countryOptionCollection->created = $countryOption->created;
             $countryOptionCollection->modified = $countryOption->modified;
             $countryOptionCollection->createdBy = $countryOption->createdBy;
             $countryOptionCollection->modifiedBy = $countryOption->modifiedBy;
             $success = $countryOptionsCollection->save();
             if ($success) {
                 if (1 == $countryOption->status) {
                     $country = Country::findFirst(array(array('id' => $countryOption->countryId)));
                     if ($country) {
                         $name = $countryOption->name;
                         $country->{$name} = $countryOption->value;
                         $country->save();
                         $results['id'] = $countryOption->id;
                     }
                 }
             }
         }
     }
     return $results;
 }