<commit_before><commit_msg>Create DoaController.php<commit_after><?php


namespace App\Http\Controllers;

use App\Nidas;
use App\RSSB;
use App\RRA;


use Illuminate\Http\Request;
use Illuminate\Http\Response;



class CreditScoreController extends Controller
{

   public function create_nida(Request $request){

       $nida = new Nidas();
       $nida->names=$request->name;	
       $nida->dob=$request->dob;		
       $nida->location=$request->location;	
       $nida->personal_id=$request->personal_id;

       $handle_id = $this->create_nida_handle($request->name,$request->dob,$request->location,$request->personal_id);

       $nida->handle_id = $handle_id;

       $nida->save();

       return $nida;
    }


    public function create_nida_handle($names,$dob,$location,$personal_id){
       
    	$method ='POST';
        $headers = array();
        $headers[] = 'Content-Type: application/json';
        $headers[] = 'Authorization: LBE7YRZPUCOCLQOXBMPJUWKS0EMUZ8MJ';
         

        $handleid= "25.001/CREDITSCORE/".$personal_id;

        $url ="https://172.16.31.10:8880/".$handleid;

     	$data = '
        			{
	                    "authkey": "<KEY>",
	                    "handleid": "25.001\/CREDITSCORE\/'.$personal_id.'",
	                    "values": 
	                    [
	                    	{
			                    "type": "CITIZEN_INDENTIFIER",
			                    "value":"'.$personal_id.'",
			                    "adminRead": true,
			                    "adminWrite": true,
			                    "publicRead": true,
			                    "publicWrite": false,
			                    "index": "1001"                
		                    }, 
		                    {
			                   "type":"NAMES",
			                   "value":"'.$names.'",
			                   "adminRead": true,
			                   "adminWrite": true,
			                   "publicRead": true,
			                    "publicWrite": false,
			                    "index": "1002"      
		                    },
		                    {
			                   "type":"LOCATION",
			                   "value":"'.$location.'",
			                   "adminRead": true,
			                   "adminWrite": true,
			                   "publicRead": true,
			                    "publicWrite": false,
			                    "index": "1003"      
		                    },
		                    {
			                   "type":"DATE_OF_BIRTH",
			                   "value":"'.$dob.'",
			                   "adminRead": true,
			                   "adminWrite": true,
			                   "publicRead": true,
			                    "publicWrite": false,
			                    "index": "1004"      
		                    }
						]
              		}
              	';
               
             
      //phpinfo();

        
       $curl = curl_init();
        curl_setopt_array($curl, array(
	        	CURLOPT_RETURNTRANSFER => true,
                CURLOPT_SSL_VERIFYHOST => false,
                CURLOPT_SSL_VERIFYPEER =>false,
	       		CURLOPT_URL => $url,
	        	CURLOPT_CUSTOMREQUEST => $method,
	        	CURLOPT_HTTPHEADER => $headers,
				CURLOPT_POSTFIELDS => ($data)
	    ));
       
        $output = curl_exec($curl);

        return $handleid;
        
        /* $err = curl_error($curl);
       
       curl_close($curl);    
	    if ($err) {
	    	echo "cURL Error #:" . $err;
	    } else {
           	echo "1";
           }
        */
    }

    public function get_nida_data(){
      
         $nida=new Nidas;
         $nida = $nida->get();
         
         if($nida){

            
             return response()->json($nida,200);

         }else{
         	
             return response()->json(['success'=>0, 'failure'=>1,'message'=>'Nida data not found'],400);
         }

    }


    public function create_rssb(Request $request){

    	  $rssb = new RSSB;

	      $rssb->employee_id=$request->employee_id;	

	      $rssb->employee_salary=$request->employee_salary;	
	      
	      $rssb_handle_id = $this->create_rssb_handle($rssb->employee_id,$rssb->salary,$request->handle_id);
	      
	      $rssb->handle_id = $rssb_handle_id;

	      

          $rssb->save();

          return $rssb_handle_id;

     }

     public function create_rssb_handle($id, $salary,$handle_id){

     	$handle_id = Nidas::where("handle_id",$handle_id)->get();

         if($handle_id){


         	$method ='POST';
        $headers = array();
        $headers[] = 'Content-Type: application/json';
        $headers[] = 'Authorization: LBE7YRZPUCOCLQOXBMPJUWKS0EMUZ8MJ';

        $handleid= "25.001/RSSB/".$id;

              
        $url ='https://172.16.31.10:8880/25.001/RSSB/'.$handleid;
     	$data = '
        			{
	                    "authkey": "<KEY>",
	                    "handleid": "'.$handleid.'",
	                    "values": 
	                    [
	                    	{
			                    "type": "EMPLOYEE_id",
			                    "value":"'.$id.'",
			                    "adminRead": true,
			                    "adminWrite": true,
			                    "publicRead": true,
			                    "publicWrite": false,
			                    "index": "1001"                
		                    }, 
		                    {
			                   "type":"SALARY",
			                   "value":"'.$salary.'",
			                   "adminRead": true,
			                   "adminWrite": true,
			                   "publicRead": true,
			                    "publicWrite": false,
			                    "index": "1002"      
		                    }
						]
              		}
              	';
               
     
       
       $curl = curl_init();
        curl_setopt_array($curl, array(
	        	CURLOPT_RETURNTRANSFER => true,
                CURLOPT_SSL_VERIFYHOST => false,
                CURLOPT_SSL_VERIFYPEER =>false,
	       		CURLOPT_URL => $url,
	        	CURLOPT_CUSTOMREQUEST => $method,
	        	CURLOPT_HTTPHEADER => $headers,
				CURLOPT_POSTFIELDS => ($data)
	    ));
       
        $output = curl_exec($curl);

        $err = curl_error($curl);
       
       curl_close($curl);    
	    if ($err) {
	    	echo "cURL Error #:" . $err;
	    } else {
           	return $handleid;
           }    
     }
  }

}

{'fraction_non_alphanumeric': 0.13213547463825728, 'fraction_numerical': 0.013515662267451106, 'mean_word_length': 1.1431005110732537, 'pattern_counts': {'":': 48, '<': 6, '<?xml version=': 0, '>': 51, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2809674', 'n_tokens_mistral': 2117, 'n_tokens_neox': 1755, 'n_words': 260}