/**
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @return JsonResponse
  *
  * @ApiDoc(
  *  description="Check if an ID number is a valid South African ID number",
  *  filters={
  *      {"name"="idNumber", "dataType"="string"},
  *      {"name"="dateOfBirth", "dataType"="string"},
  *      {"name"="gender", "dataType"="string"},
  *      {"name"="origin", "dataType"="string"}
  *  },
  *  statusCodes={
  *      200="Returned when successful",
  *      400="Returned if the inputs are invalid",
  *      500="Returned if an error occurred"
  *  }
  * )
  */
 public function checkIdNumberAction(Request $request)
 {
     $idNumber = $request->get("idNumber");
     $dateOfBirth = $request->get("dateOfBirth");
     $gender = $request->get("gender");
     $origin = $request->get("origin");
     $data = array();
     $utils = new Utils();
     try {
         $saIdNumberValidator = new SaIdNumberValidator($utils, $idNumber);
         $saIdNumberValidator->checkIdNumber($dateOfBirth, $gender, $origin);
         $httpCode = 200;
         $message = "The ID number and the details provided matches";
     } catch (InvalidFormatException $ex) {
         $this->addErrorToLog("An InvalidFormat Exception has occured", $ex);
         $httpCode = 400;
         $message = $ex->getMessage();
     } catch (IdValidationException $ex) {
         $this->addErrorToLog("An IdValidation Exception has occured", $ex);
         $httpCode = 500;
         $message = $ex->getMessage();
     } catch (\Exception $ex) {
         $this->addErrorToLog("An Unknown Exception has occured", $ex);
         $httpCode = 500;
         $message = "An unknown error has occured, please try again later";
     }
     return $this->apiOutput(array("status" => $httpCode, "message" => $message, "data" => $data), $httpCode);
 }
 /**
  * @expectedException \Demo\IdServicesBundle\Lib\Exceptions\IdValidationException
  */
 public function testCanThrowExceptionOnWrongOriginSupplied()
 {
     $dateOfBirth = "150807";
     $gender = "female";
     $origin = "local";
     $saIdNumberValidator = new SaIdNumberValidator($this->utils, "1508070622197");
     $saIdNumberValidator->checkIdNumber($dateOfBirth, $gender, $origin);
 }