Created
December 28, 2019 16:40
-
-
Save arun12209/78f625de40426b58809b62b25857a2fc to your computer and use it in GitHub Desktop.
FullContactAccountDetailsContrl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FullContactAccountDetailsContrl { | |
@AuraEnabled | |
public static string getAccountDetails(string rec_id){ | |
String msg = ''; | |
try{ | |
Account acc=[select Website from account where id=:rec_id ]; | |
system.debug('domain : '+ acc.Website); | |
if(acc.Website != null && acc.Website != ''){ | |
string baseURL = 'https://api.fullcontact.com/v2/company/lookup.json?domain'; | |
string apikey = '9e340d31aXXXXXXX'; // Your API Key (Register on https://dashboard.fullcontact.com/register to get API Key) | |
string url = baseURL +'='+ acc.Website + '&apiKey=' + apikey; | |
HttpRequest req = new HttpRequest(); | |
Http http = new Http(); | |
req.setMethod('GET'); | |
req.setEndpoint(url); | |
HttpResponse res = http.send(req); | |
system.debug('response status code: '+res.getStatusCode()); | |
system.debug(''+res.getBody()); | |
string body=res.getBody(); | |
system.debug('Retured Body: '+body); | |
if (res.getStatusCode() == 200) { | |
return res.getBody(); | |
} | |
else{ | |
return null; | |
} | |
} | |
else{ | |
return 'Enter website to see the company profile'; | |
} | |
} | |
catch(Exception e){ | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment