Lightning Connect Custom Adapters for Github
Mar 2, 2019 / Shen
Integration with Github
I occasionally found this article Rendering GitHub JSON Data in Salesforce on the salesforce dev blog and found it very interesting. So I couldn't wait to digest it.
To make the story short: This sample uses the Apex Connector Framework to develop a custom adapter for Salesforce Connect.
The result:
How to implement?
There are only four steps need to do:
- A apex class that implements the sync and query methods interface of DataSource.Connection
- A custom adapter class that extends DataSource.Provider.
- Create a new remote site setting.
- Create the external data sourcen.
When the above steps are done, we can select through the soql:
SELECT Name__c, Stars__c FROM GitHub_Repos__x
Here is the implementation class for Provider:
global class GitHubProvider extends DataSource.Provider {
override global List getCapabilities() {
List capabilities = new List();
capabilities.add(DataSource.Capability.ROW_QUERY);
return capabilities;
}
override global List getAuthenticationCapabilities() {
List capabilities = new List();
capabilities.add(DataSource.AuthenticationCapability.ANONYMOUS);
return capabilities;
}
override global DataSource.Connection getConnection(DataSource.ConnectionParams connectionsParams) {
return new GitHubConnection();
}
}
Enjoy! You can find the test code in the developerforce/github-custom-adapter GitHub project.