DigiLocker Coapplicant Related Changes : ps

This commit is contained in:
VE10-Sanjeev 2022-07-13 23:05:52 +05:30
parent 3d0e422c66
commit 29252cc95d
3 changed files with 43 additions and 12 deletions

View File

@ -2190,9 +2190,9 @@ class Flyhi_Controller extends REST_Controller {
$this->load->helper('digital_locker');
// $code = "66e28b748d5f73186206a03f27f6aee73191a087";
$code = $this->get('code');
$state = $this->get('state');
log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code);
$response_data = digital_locker::getAccessToken($code);
$co_applicant = $this->get('state');
log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant : ".$co_applicant);
$response_data = digital_locker::getAccessToken($code,$co_applicant);
if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){
$response_data['status'] = REST_Controller::HTTP_NOT_FOUND;
@ -2200,6 +2200,7 @@ class Flyhi_Controller extends REST_Controller {
}else{
$view_data['list'] = json_decode($response_data['records'], true);
$view_data['token']= $response_data['token'];
$view_data['pd_id']=$response_data['pd_id'];
log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data));
log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data));
$this->load->view("digital_locker",$view_data);
@ -2214,16 +2215,35 @@ class Flyhi_Controller extends REST_Controller {
log_message('ERROR','### 5 User Choosen Files'.json_encode($this->post()));
$form_data = $this->post();
$token = $form_data['token'];
$pd_id = $form_data['pd_id'];
log_message('ERROR','### 5th User Choosen Files token key'.$form_data['token']);
unset($form_data['token']);
$reindexed_array = array_values($form_data);
if(count($reindexed_array)>0){
for($i=0;$i<count($reindexed_array);$i++){
$reponse = digital_locker::downloadFiles($reindexed_array[$i],$token);
$folder_to_check = XLPATH.'/tmp';
$bytes = file_put_contents($folder_to_check, json_decode($reponse, true));
$config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]);
$this->load->library('upload', $config);
// $folder_to_check = XLPATH.'/tmp';
// $bytes = file_put_contents($folder_to_check, json_decode($reponse, true));
// $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]);
// $this->load->library('upload', $config);
$fields = array('pd_id','fk_lender_id');
$where_condition_array = array('pd_id' => $pd_id);
$dtls = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
$pd_id = (count($dtls)>0) ? $dtls[0]['pd_id'] : null;
$fk_lender_id = (count($dtls)>0) ? $dtls[0]['fk_lender_id'] : null;
$tempdocname = "IDPROOF - ".$i+1;
$bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id;
$key = 'pd'.$pd_id.'/'.$tempdocname ;
$sourcefile = json_decode($reponse, true);
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>"DigiLocker Files (".$tempdocname.")",'pd_document_name'=>$tempdocname);
$this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS);
}
log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse));
}}
$data['dataStatus'] = true;

View File

@ -6,9 +6,9 @@ class DIGITAL_LOCKER
static $TOKEN_AS_GLOBAl = null;
static public $myVAR = null;
public static function getAccessToken($code)
public static function getAccessToken($code,$applicant)
{
log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code);
log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code." & applicant :".$applicant);
$CI =&get_instance();
$headers = array('Content-Type: multipart/form-data');
// $headers = array('Content-Type: application/json');
@ -28,11 +28,21 @@ class DIGITAL_LOCKER
return array('dataStatus'=>false,'msg'=>$response->error_description);
}else{
log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token);
return self::getFileIssuedList($response->access_token);
$CI->db->SELECT("fk_pd_id");
$CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS");
$CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant);
$CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1);
$dtls = $CI->db->GET()->result_array();
$pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null;
$CI->db->where('pd_co_applicant_id =',$applicant);
$CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response));
return self::getFileIssuedList($response->access_token,$pd_id);
}
}
public static function getFileIssuedList($access_token)
public static function getFileIssuedList($access_token,$pd_id)
{
log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token);
$CI =&get_instance();
@ -44,7 +54,7 @@ class DIGITAL_LOCKER
$result=curl_exec($ch);
log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result));
curl_close( $ch );
return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token);
return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id);
}
public static function downloadFiles($uri,$access_token)

View File

@ -103,6 +103,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
echo '<td class = "tdcenteralign" colspan="4">'.$list['items'][$i]['issuer'].'</td></tr>';
}
echo '<input type="hidden" id="token" name="token" value='.$token.'>';
echo '<input type="hidden" id="pd_id" name="pd_id" value='.$pd_id.'>';
echo '</tbody></table>
<br>