Git Product home page Git Product logo

package-salesforce's Introduction

Salesforce Connector

The Salesforce connector allows you to perform CRUD operations for SObjects, query using SOQL, search using SOSL, and describe SObjects and organizational data through the Salesforce REST API. It handles OAuth 2.0 authentication.

Compatibility

Ballerina Version API Version
0.975.0 v37.0

Getting started

  1. Refer to Getting Started guide to download and install Ballerina.

  2. Create a Salesforce account and create a connected app by visiting Salesforce and obtain the following parameters:

  • Base URl (Endpoint)
  • Client Id
  • Client Secret
  • Access Token
  • Refresh Token
  • Refresh URL

IMPORTANT: This access token and refresh token can be used to make API requests on your own account's behalf. Do not share your access token, client secret with anyone.

Visit here for more information on obtaining OAuth2 credentials.

  1. Create a new Ballerina project by executing the following command.

       <PROJECT_ROOT_DIRECTORY>$ ballerina init
       
  2. Working with Salesforce REST connector.

All the actions return JSON or sfdc37:SalesforceConnectorError. If the action is a success, then result (non-empty) JSON will be returned while the sfdc37:SalesforceConnectorError will be null and vice-versa.

You can import the Salesforce package(sfdc37) to your Ballerina program as follows.

    import wso2/sfdc37;
Example
  • Request
   import wso2/sfdc37 as sf;
   import ballerina/io;

//User credentials to access Salesforce API
   string url = "<base_url>";
   string accessToken = "<access_token>";
   string refreshToken = "<refresh_token>";
   string clientId = "<client_id>";
   string clientSecret = "<client_secret>";
   string refreshUrl = "<refreshUrl>";


   public function main (string... args) {
       endpoint Client salesforceClient {
           clientConfig:{
               url:url,
               auth:{
                   scheme:http:OAUTH2,
                   accessToken:accessToken,
                   refreshToken:refreshToken,
                   clientId:clientId,
                   clientSecret:clientSecret,
                   refreshUrl:refreshUrl
               }
           }
       };
   
        //Call the Salesforce connector function getAvailableApiVersions().
       json|sf:SalesforceConnectorError response = salesforceClient -> getAvailableApiVersions();
           match response {
               //if successful, returns JSON result
               json jsonRes => {
                   io:println(jsonRes);
               }
       
               //if unsuccessful, returns an error of type sfdc37:SalesforceConnectorError
               sf:SalesforceConnectorError err => {
                   io:println(err);
               }
           }
   }
  • Response

JSON response or SalesforceConnectorError struct

package-salesforce's People

Contributors

erandiganepola avatar muthulee avatar ldclakmal avatar keerthu avatar dushaniw avatar biruntha avatar maheshika avatar

Watchers

James Cloos avatar Ruwan Yatawara avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.