diff --git a/api/application/config/constants.php b/api/application/config/constants.php index def3a2fb..7e89c98b 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -213,16 +213,16 @@ else if(ENVIRONMENT == 'production') defined('OPTIMIZED_IMAGE_BUCKET_NAME') OR define('OPTIMIZED_IMAGE_BUCKET_NAME','optimized-images-live'); defined('IMAGE_OPTIMIZE_LAMBDA_URL') OR define('IMAGE_OPTIMIZE_LAMBDA_URL','https://4u9t03hvfb.execute-api.ap-south-1.amazonaws.com/live'); defined('VIDEO_SHORT_URL') OR define('VIDEO_SHORT_URL','https://l.pdgenie.com/'); - defined('CET_SALESPD_INTEGRATION_URL') OR define('CET_SALESPD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdData'); - defined('CET_SALESPD_INTEGRATION_IMG_URL') OR define('CET_SALESPD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); - defined('CET_SALESPD_INTEGRATION_REINSERTIMG_URL') OR define('CET_SALESPD_INTEGRATION_REINSERTIMG_URL','https://demo.devopsmcfinance.com/cet_salespd/api/ReInsertImageData'); - defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdData'); - defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); + defined('CET_SALESPD_INTEGRATION_URL') OR define('CET_SALESPD_INTEGRATION_URL','https://partner.smcfinance.com/cet_salespd/api/PullSalesPdData'); + defined('CET_SALESPD_INTEGRATION_IMG_URL') OR define('CET_SALESPD_INTEGRATION_IMG_URL','https://partner.smcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); + defined('CET_SALESPD_INTEGRATION_REINSERTIMG_URL') OR define('CET_SALESPD_INTEGRATION_REINSERTIMG_URL','https://partner.smcfinance.com/cet_salespd/api/ReInsertImageData'); + defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://partner.smcfinance.com/cet_creditpd/api/PullCreditPdData'); + defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://partner.smcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token'); defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued'); defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/file/'); defined('GCP_BUCKET_NAME') OR define('GCP_BUCKET_NAME','pd-giene-data'); - defined('CET_CREDITPD_INTEGRATION_REINSERTIMG_URL') OR define('CET_CREDITPD_INTEGRATION_REINSERTIMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/ReInsertImageData'); + defined('CET_CREDITPD_INTEGRATION_REINSERTIMG_URL') OR define('CET_CREDITPD_INTEGRATION_REINSERTIMG_URL','https://partner.smcfinance.com/cet_creditpd/api/ReInsertImageData'); defined('SMC_FINANCE_AUTH_URL') OR define('SMC_FINANCE_AUTH_URL','http://ums.devopsmcfinance.com/umsnode/ums/api/v1/auth/login'); defined('SMC_FINANCE_REFRESH_TOKEN') OR define('SMC_FINANCE_REFRESH_TOKEN','http://ums.devopsmcfinance.com/umsnode/ums/api/v1/auth/access-token'); defined('SMC_FINANCE_UPDATE_URL') OR define('SMC_FINANCE_UPDATE_URL','http://devopsmcfinance.com/salesapi/salesapplication/v1/sales-lead/update-pd'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 4eb4f863..078eeda7 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -427,6 +427,7 @@ $route['transferSalesPDImgToCETApp'] = 'Sales_PD_Controller/transferSalesPDImgTo $route['transferCreditPDToCETApp'] = 'SMC_Credit_PD_Controller/transferCreditPDToCETApp'; $route['transferCreditPDImgToCETApp'] = 'SMC_Credit_PD_Controller/transferCreditPDImgToCETApp'; $route['transferCreditPDReportToCETApp'] = 'SMC_Credit_PD_Controller/transferCreditPDReportToCETApp'; +$route['auditGCPFile'] = 'SMC_Credit_PD_Controller/auditGCPFile'; $route['cetNewSalesPD'] = 'Sales_PD_Controller/cetNewSalesPd'; $route['login'] = 'Common_Masters_Controller/login'; diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index e5d2ca08..7d4e4497 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -2446,8 +2446,8 @@ public function filterSalesPDList_post() { 'credit_pd_type'=>$mater_details[0]['fk_pd_type'], 'pd_type_name'=>$mater_details[0]['pd_type_name'], 'completed_date'=>$mater_details[0]['completed_on'], - 'start_location'=>$mater_details[0]['start_location'], - 'lender_applicant_id'=>$mater_details[0]['lender_applicant_id']); + 'start_location'=>$mater_details[0]['start_location'], + 'lender_applicant_id'=>$mater_details[0]['lender_applicant_id']); $photograph_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'),array('fk_smc_credit_pd_id' => $credit_pd_id,'isactive' => 1),SMC_CREDIT_PD_DOCS); log_message('ERROR', '#### Credit PD ('.$credit_pd_id.') - Total Images'.count($photograph_data)); @@ -2467,6 +2467,7 @@ public function filterSalesPDList_post() { $common_fields['data']['Photograph Details']['photo'][$k]['img_name'] = $value['img_name']; $common_fields['data']['Photograph Details']['photo'][$k]['img'] = $rand_name; $photograph_data[$k]['rand_name'] = $rand_name;$k++; + // $value['doc_id'];$rand_name; } $CET_response = cet_creditpd::repushwithcetphotographapi($common_fields); $CET_api_response[$credit_pd_id] = $CET_response; @@ -2688,6 +2689,49 @@ public function filterSalesPDList_post() { log_message('ERROR', '#### SMC Credit PD '.count(array($allOptimizedFiles)).' S3 optimized Files Deleted For this '.$pdid); $this->aws_s3->deleteMatchingObjects(OPTIMIZED_IMAGE_BUCKET_NAME, $key); } + + function auditGCPFile_get(){ + $this->load->library('Googlecloud'); + + $bk_name1= 'sales-pd'; + $bk_name2= 'sales-pd-demo'; + $prefix = $this->get('prefix'); + //$prefix = 'credit-pd-demo/pd17092/'; + $prefix = 'credit-pd/pd18010/images/stock_image_ELawVP.png'; + $data['prefix'] = $prefix; + + // $data['listAllBuckets'] = $this->googlecloud->listAllBuckets(); + // $data['getAllObjectsInaBucket'] = $this->googlecloud->getAllObjectsInaBucket('sales-pd-demo'); + // $data['getAllObjectsInaBucket'] = $this->googlecloud->getAllObjectsInaBucket(GCP_BUCKET_NAME); + $data['SingleObjectInaBucketAsSignedURI'] = $this->googlecloud->getSingleObjectInaBucketAsSignedURI(GCP_BUCKET_NAME,$prefix); + + + //$data['listObjectsWithPrefix'] = $this->googlecloud->listObjectsWithPrefix(GCP_BUCKET_NAME,$prefix); + + // $destination_path = $this->external_path . "/sales_pd/2200/satellite.png"; + // $object_name = "pd2202/images/satellite.png"; + // $object_name = "pd8508/8508.pdf"; + // $object_name = "pd2202/report/satellite.png"; + // $download_destination_path = $this->external_path . "/sales_pd/GCP_Downloaded/downloadeder4.pdf"; + + // print_r($this->googlecloud->getSingleObjectInaBucketAsSignedURI(,'pd8582/images/*')); + // print_r($this->googlecloud->deleteSingleObjFromBucket('sales-pd-demo','s')); + // print_r($this->googlecloud->deleteSingleObjFromBucket('sales-pd-demo','sales_pd/2200/new3.png')); + // print_r($this->googlecloud->deleteSingleObjFromBucket('sales-pd-demo','sales_pd/images/2200/new3.png')); + // print_r($this->googlecloud->deleteSingleObjFromBucket('sales-pd-demo','sales_pd/images/2201')); + // print_r($this->googlecloud->deleteSingleObjFromBucket('sales-pd-demo','sales_pd/images/2202/satellite.png')); + // print_r($this->googlecloud->deleteSingleObjFromBucket('sales-pd-demo','test.pdf')); + + // print_r($this->googlecloud->download_object('pd-giene-data', $object_name, $download_destination_path)); + // print_r($this->googlecloud->get_object_v4_signed_url('sales-pd-demo', $object_name)); + // print_r($this->googlecloud->createNewBucket('credit-pd')); + // print_r($this->googlecloud->delete_bucket('credit-pd-demo')); + // print_r($this->googlecloud->upload_object('sales-pd-demo', $object_name, $destination_path)); + // print_r($this->googlecloud->create_bucket_object('sales-pd-demo',"sales_pd/images/2200",$destination_path)); + + $this->response($data,REST_Controller::HTTP_OK); + } + } \ No newline at end of file diff --git a/api/application/libraries/Googlecloud.php b/api/application/libraries/Googlecloud.php index 3b52b0a6..e1f8315c 100644 --- a/api/application/libraries/Googlecloud.php +++ b/api/application/libraries/Googlecloud.php @@ -314,6 +314,34 @@ class Googlecloud printf('Copied gs://%s/%s to gs://%s/%s' . PHP_EOL, $bucketName, $objectName, $newBucketName, $newObjectName); } + + /** + * List Cloud Storage bucket objects with specified prefix. + * + * @param string $bucketName The name of your Cloud Storage bucket. + * (e.g. 'my-bucket') + * @param string $directoryPrefix the prefix to use in the list objects API call. + * (e.g. 'myDirectory/') + * Refer : list_objects_with_prefix() in GCP Docs + */ + function listObjectsWithPrefix(string $bucketName, string $directoryPrefix) + { + $objects = array(); + try { + $storage = $this->googleClient; + $bucket = $storage->bucket($bucketName); + $options = ['prefix' => $directoryPrefix]; + foreach ($bucket->objects($options) as $object) { + array_push($objects, 'Object : ' .$object->name()); + } + } catch (Exception $ex) { + return $ex->getMessage() . "\n
"; + print_r($ex->getTraceAsString()); + ""; + } + + return $objects; +} }