Method to get the files under one folder
public string emailFile(){ if(wrapPdfLinksList!=null && wrapPdfLinksList.size()>0 ){ list<string> selectedFiles = new list<string>(); for(wrapPdfLinks w :wrapPdfLinksList){ if(w.check) selectedFiles.add(w.pdfLink); } for(string thefolder :selectedFiles){ // Create a new http object to send the request object string accessibility = 'anyone'; boolean send_email = false; string path =thefolder; boolean notify = false; string recipients; //End of creating the variables /*//to get quote num temp1 = thefolder.split('/'); if(temp1.size()>5){ system.debug('***** temp1-- '+temp1); if(temp1[4] != null) quoteNo = temp1[4]; } //End to get Quote Number*/ //to get the receipent of the Quote list<Quotes__c> receipientList = new list<Quotes__c>([SELECT Email__c from Quotes__c WHERE Name =: quoteNo Limit 1]); system.debug('UUUUUUUUUU'+receipientList); if(receipientList != null){ for(Quotes__c a :receipientList){ recipients = a.Email__c; system.debug('DDDDDDDDDD'+recipients); } } //end to get the receipent of the Quote HttpRequest req = new HttpRequest(); req.setEndpoint('https://constructionspecialties.egnyte.com/pubapi/v1/links'); req.setMethod('POST'); list<eToken__c> sToken = new list<eToken__c>([Select Token__c From eToken__c where name =: UserInfo.getUserEmail()]); system.debug('***sToken**'+sToken); req.setHeader('Authorization', 'Bearer '+sToken[0].Token__c); req.setHeader('Content-Type','application/json'); string reqBody = '{"accessibility":"'+accessibility+'","send_email":"'+send_email+'","type":"file","path":"'+path+'","notify":"'+notify+'","link_to_current":"true","recipients":["'+recipients+'"]}'; req.setBody(reqBody); Http http = new Http(); HTTPResponse res = http.send(req); system.debug('reqBody'+reqBody); System.debug(res); system.debug('***** response---'+res.getStatusCode()); system.debug('***** to string---'+res.getbody()); //fileURL = res.getbody(); string theResponse = res.getbody(); string afterUrl = theResponse.subStringAfter('"url":"'); system.debug('***** afterUrl---'+afterUrl); string theUrl = afterUrl.subStringBefore('","recipients":'); system.debug('***** theUrl---'+theUrl); fileURL = theUrl; } } String url = '/_ui/core/email/author/EmailAuthor?p7=The%20files%20'+fileURL; pageReference pr = new PageReference(url); pr.setRedirect(true); return url; }
No comments:
Post a Comment