• madhuri chowdary
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
public without sharing class DP_cls_FileAggregatorService {
    /**
     * Prepare data to Send to File Aggregator API
     * Http Callout to File Aggregator system
     *
     * @param setOfUpdatedGovReq (Set of Gov. Req.)
     */
    private static final Logger log = LoggerFactory.getLogger(LoggerFactory.LoggerType.LOGSTASH,LoggerFactory.TeamName.CP,DP_cls_CCPACaseValidation.class);
    @future(callout = true)
    public static void sendRequestToFileAggregatorFuture(Id idOfUpdatedGovReq) {
        integer responsecode = sendRequestToFileAggregator(idOfUpdatedGovReq);
    }
    public static Integer sendRequestToFileAggregator(Id idOfUpdatedGovReq) {
        Integer calloutresponse;
        //Prepare list of identified Gov. Req. to send in request
        DP_Governance_Request__c updatedGovReq = new DP_Governance_Request__c();
        if(idOfUpdatedGovReq != null) {
            updatedGovReq = DP_cls_CCPAModelClass.searchGovReq(idOfUpdatedGovReq);
        }

        //Generate access token
        DP_cls_FileAggregatorHelper tokenHelper = new DP_cls_FileAggregatorHelper();
       // GT_cls_AccessTokenROPCService tokenService = new GT_cls_AccessTokenROPCService(tokenHelper.getAdfsUrl(), tokenHelper.getResource(),
       //         tokenHelper.getClientId(), tokenHelper.getClientSecret(), tokenHelper.getUserName(), tokenHelper.getUserPassword());
          GT_cls_AccessTokenROPCService tokenService = new GT_cls_AccessTokenROPCService(tokenHelper.getAzureUrl(), tokenHelper.getContentTypeHeader(), tokenHelper.getCPPClientId(),
                tokenHelper.getCPPClientSecret(), tokenHelper.getGrantType(), tokenHelper.getScope());        

        GT_cls_Token tokenDPP = tokenService.getToken();
        String finalToken = tokenDPP.getAccessToken();
        
        //Callout to File Aggregator system with POST method
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Type', tokenHelper.getContentType());
        req.setHeader('Authorization', 'Bearer ' +finalToken);
        if(!Test.isRunningTest()){
            req.setHeader('x-api-key', tokenHelper.getApiKey());
        }
        req.setMethod(tokenHelper.getMethod());
        req.setEndpoint(tokenHelper.getEndpoint());
        req.setTimeout(60000);

        //create json
        JSONGenerator gen = JSON.createGenerator(true);
        gen.writeStartObject();
        if(updatedGovReq.Country__c == DP_cls_AppLiterals.CCPA_COUNTRY_LITERAL){
            gen.writeStringField('s3Url', tokenHelper.getURL() + String.valueOf(updatedGovReq.Id) + '/' + updatedGovReq.ECom_GLB_EUCI__c);
        }else if((updatedGovReq.Regulatory_ID__c == DP_cls_AppLiterals.GDPR_LITERAL) && (updatedGovReq.Request_Type__c == DP_cls_AppLiterals.DP_GR_REQUEST_TYPE_DATA_PORTABILITY )) {
            gen.writeStringField('s3Url', tokenHelper.getgdprUrl() + tokenHelper.getgdprPortabilityUrl() + String.valueOf(updatedGovReq.Id) + '/' + updatedGovReq.ECom_GLB_EUCI__c);
        }else if(updatedGovReq.Regulatory_ID__c == DP_cls_AppLiterals.GDPR_LITERAL){
            gen.writeStringField('s3Url', tokenHelper.getgdprUrl() + String.valueOf(updatedGovReq.Id) + '/' + updatedGovReq.ECom_GLB_EUCI__c);
        }else if(updatedGovReq.Regulatory_ID__c == DP_cls_AppLiterals.LGPD_LITERAL){
            gen.writeStringField('s3Url', tokenHelper.getlgpdUrl() + String.valueOf(updatedGovReq.Id) + '/' + updatedGovReq.ECom_GLB_EUCI__c);
        }
        gen.writeEndObject();
        String jsonString = gen.getAsString();
        req.setBody(jsonString);
        Http http = new Http();
        HttpResponse response;
        
        try{
            //Callout
            if(!Test.isRunningTest()) {
                response = http.send(req);
            }else{
                response = new HttpResponse();
                response.setStatusCode(200);
            }
            calloutresponse = response.getStatusCode() ;
            if(calloutresponse == GT_cls_CTI_AppLiterals.E_COM_STATUS_200
                    || calloutresponse == GT_cls_CTI_AppLiterals.E_COM_STATUS_201){
                //Update governance request record
                updatedGovReq.RequestSent__c = true;
                updatedGovReq.status__c = DP_cls_AppLiterals.DP_GR_STATUS_COMPLETED;
                try{
                    update updatedGovReq;
                }catch(Exception ex){
                    Ecom_cls_Utility.insertErrorLog(ex);
                }
                return calloutresponse;
            }else {
                Ecom_cls_Utility.createErrorLog(response.getStatusCode() +'_'+response.getBody());
                return null;
            }
        }catch(Exception ex){
            Ecom_cls_Utility.createErrorLog(response.getStatusCode() +'_'+response.getBody());
            return null;
        }
    }
}
Hello All!
I will send an  email_type  case_not_closed_after_60 days if CaseActiveDays  > 59 . For my testing purpose I am trying to convert caseActiveDays to  time  for  1  Hour .

 Date todayDate = Date.today();
        Date caseCreatedDate = caseObj.CreatedDate.Date();
        Integer caseActiveDays = caseCreatedDate.daysBetween(currentDate);

Can someone help me how to convert the above date so that I can use  CaseActiveTime > 1 hour .
 
Hi all, 

I want to write a method in which email needs to send to case contacts for those cases which are escalated . And this method is called from a trigger. 

Can someone please help me in this . 

Thanks in advance. 
 
Hi all, 

I want to write a method in which email needs to send to case contacts for those cases which are escalated . And this method is called from a trigger. 

Can someone please help me in this . 

Thanks in advance.