/**
  * @api {post} /country_options POST /country_options
  * @apiExample Example usage:
  * curl -i -X POST "http://apibeta.compargo.com/v1/country_options/?countryCode=ph&language=en"
  *      -H "X-COMPARE-REST-API-KEY: 1234567890"
  *      -d "countryId=4de2ec7a-22b5-11e4-bd33-17609cecca2f&
  *          name=iso3&
  *          value=PHL&
  *          status=1&
  *          editable=1&
  *          visibility=1"
  * 
  * @apiDescription  Create a new Country Options
  * @apiName         Post
  * @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} countryId                Mandatory Country ID of Country Options.
  * @apiParam        {String} name                     Mandatory Name of the Country Options.
  * @apiParam        {String} value                    Mandatory Value of the Country Options.
  * @apiParam        {String} [label]                  Optional Label of the Country Options.
  * @apiParam        {String} [editable=0]             Optional Editable Flag of the Country Options.
  * @apiParam        {String} [visibility=0]           Optional Visibility Value of the Country Options.
  * @apiParam        {String} [status=0]               Optional Status of the Country Options.
  * @apiParam        {String} [createdBy]              Optional ID of the User who created the Country Options.
  * @apiParam        {String} [modifiedBy]             Optional ID of the User who modified the Country Options.
  *	
  * @apiSuccess      {String} id                       The new Country-ID.
  *
  * @apiSuccessExample Success-Response:
  *     HTTP/1.1 200 OK
  *     {
  *       "id": "594942d8-3815-11e4-b18a-fe7344fb1ea4"
  *     }
  *     
  * @apiError BadInputParameter The request cannot be fulfilled due to bad syntax.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 400
  *     {
  *       "error": "BadInputParameter"
  *     }
  *     
  * @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 post()
 {
     $results = array();
     $request = $this->di->get('request');
     $data = $request->getPost();
     if (!empty($data)) {
         $countryOptions = new CountryOptions();
         $data['id'] = $countryOptions->id;
         $data['countryId'] = isset($data['countryId']) ? $data['countryId'] : '';
         $data['name'] = isset($data['name']) ? $data['name'] : '';
         $data['value'] = isset($data['value']) ? $data['value'] : '';
         $data['label'] = isset($data['label']) ? $data['label'] : '';
         $data['status'] = isset($data['status']) ? $data['status'] : 0;
         if (isset($data['status'])) {
             $data['active'] = $data['status'] != CountryOptions::ACTIVE ? 0 : 1;
             $data['editable'] = $data['status'] != CountryOptions::ACTIVE ? 0 : $data['editable'];
             $data['visibility'] = $data['status'] != CountryOptions::ACTIVE ? 0 : $data['visibility'];
         }
         $data['createdBy'] = isset($data['createdBy']) ? $data['createdBy'] : '';
         $data['modifiedBy'] = isset($data['modifiedBy']) ? $data['modifiedBy'] : '';
         if ($countryOptions->save($data)) {
             $results['id'] = $countryOptions->id;
         } else {
             throw new HTTPException("Request unable to be followed due to semantic errors", 422, array('dev' => $countryOptions->getMessages(), 'internalCode' => 'P1000', 'more' => ''));
         }
     } else {
         throw new HTTPException("The request cannot be fulfilled due to bad syntax.", 400, array('dev' => 'A required field is missing.', 'internalCode' => 'P1000', 'more' => ''));
     }
     return $results;
 }