/**
  * @return JsonResponse
  *
  * @ApiDoc(
  *  description="Generate a valid South African ID number",
  *  filters={
  *      {"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 generateIdNumberAction($dateOfBirth, $gender, $origin)
 {
     $data = array();
     $utils = new Utils();
     try {
         $saIdNumberGenerator = new SaIdNumberGenerator($utils, $dateOfBirth);
         $idNumber = $saIdNumberGenerator->generateIdNumber($gender, $origin);
         $httpCode = 200;
         $message = "The ID number has been generated successfully";
         $data = array("idNumber" => $idNumber);
     } catch (InvalidFormatException $ex) {
         $this->addErrorToLog("An InvalidFormat Exception has occured", $ex);
         $httpCode = 400;
         $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\InvalidFormatException
  */
 public function testCanThrowExceptionOnInvalidOrigin()
 {
     $dataOfBirth = "150201";
     $gender = "male";
     $origin = "Invalid origin";
     $saIdNumberGenerator = new SaIdNumberGenerator($this->utils, $dataOfBirth);
     $results = $saIdNumberGenerator->generateIdNumber($gender, $origin);
 }