Git Product home page Git Product logo

go-salesforce-sdk's Introduction

Tests

Go Salesforce SDK

go-salesforce-sdk is an unofficial SDK for the Salesforce REST API.

Checkout our release notes for information about the latest bug fixes, updates, and features added to the sdk.

Jump To:

Installation

This SDK comes in two parts: a CLI for generating types and running small commands, and a series of Go packages intended to be used as a library in your applications.

# install the package using go modules
go get github.com/beeekind/go-salesforce-sdk
# install the CLI
go install $GOPATH/src/github.com/beeekind/go-salesforce-sdk/cmd/go-salesforce-sdk

Examples

This SDK consists of a high level and a low level API. The high level API can be found in the root package while all other packages should be considered low level.

We recommend you actually use the low level API as it is much more configurable and still simple to use.

Use these examples, all *_test.go files, the root package, and the godoc, as documentation for using this SDK.

  1. Authenticate via the Password or JWT flows by setting environmental variables:
# For the JWT flow (recommended):
# https://mannharleen.github.io/2020-03-03-salesforce-jwt/

export SALESFORCE_SDK_CLIENT_ID=...
export SALESFORCE_SDK_USERNAME=...
export SALESFORCE_SDK_PEM_PATH=...

#For the Password Flow:

export SALESFORCE_SDK_CLIENT_ID=...
export SALESFORCE_SDK_CLIENT_SECRET=...
export SALESFORCE_SDK_USERNAME=...
export SALESFORCE_SDK_PASSWORD=...
export SALESFORCE_SDK_SECURITY_TOKEN=...
  1. Generate the types you intend to use
go-salesforce-sdk generate Lead ./ leads 0
  1. Use the SDK
import (
    sdk "github.com/beeekind/go-salesforce-sdk"
    "github.com/beeekind/go-salesforce-sdk/requests"
    "github.com/beeekind/go-salesforce-sdk/soql"
    "github.com/beeekind/go-salesforce-sdk/types"
    "github.com/your/project/leads"
)

type LeadsResponse struct {
    types.QueryResponse
    Records []*leads.Lead `json:"records"`
}

func main(){
    var response LeadsResponse
    _, err := requests. 
        Sender(sdk.DefaultClient).
        URL("query").
        SQLizer(soql.
            Select("Id", "Name", "CreatedDate"). 
            From("Lead"). 
            Limit(100)).
        JSON(&response)

    for _, lead := range response.Records {
        // ...
    }
}

Features


  • Generate type definitions

    • Standard Objects
    • Tooling Objects
  • Authentication Mechanisms

    • JWT flow (recommended)
    • Password flow
  • Concurrent Processing

    • Pre-compute paginated resources for retrieving all paginated records quickly
  • HTTP Client Wrapper

    • HttpTransport customization
    • Ratelimiting
    • GZIP compression
  • Querybuilder (based on squirrel)

    • Select
    • Where
      • Equality | Inequality
      • Subqueries
      • Like | NotLike
      • GT | LT | GTE | LTE
      • Conjugations (And | Or)
    • Group By
    • Order By(s)
    • Limit
    • Offset
    • Prefixes
    • Suffixes
  • Request Builder

    • URL composition
    • Method
    • URL parameters
    • Headers
    • SOQL embeding
    • Build as http.Response
    • Unmarshal into struct
    • application/x-www-form-urlencoded submissions
  • Custom Types

    • Nullable (bool | string | int | float)
    • Date / Datetime
    • Address
    • AlmostBool
  • Metadata Response Types

    • /describe
    • /describe/{objectName}
    • Limits
    • Query
    • Tooling/query
  • Bulk API v2

    • Ingest
    • Query
  • Composite

    • Create
    • Read
    • Update
    • Delete
  • Tree

    • ParseNode(typeDefinition)
    • Recursive object nesting
  • Execute Anonymous Apex

    • SingleEmailMessage
  • And much more...

Packages

Package Link Description
go-salesforce-sdk Link Root package with high level API methods. Other packages should be considered the low-level API
cmd/go-salesforce-sdk Link CLI for generating golang type definitions
apex Link Demonstrates using the Execute Anonymous Apex endpoint to send an email
bulk Link Methods for bulk uploading and retrieving objects as text/csv
client Link Wraps http.Client and provides authentication, ratelimiting, and http.Transport customization
composite Link Provides Create, Read, Update, and Delete, operations with the Composite API
metadata Link TBD
requests Link HTTP request building using the builder design pattern
soql Link SOQL (Salesforce Object Query Language) building using the builder design pattern
templates Link Templates for generating Type definitions, Response types, Apex code, and other artifacts
tree Link Tree API operations for saving nested objects based on their relations. Uses generated types.
types Link Type definitions for Salesforce specific types like Date and Datetime

Contribute

Issues and Pull Requests welcome!

Credits

Gophers Slack.

The greater Devops community for keeping me sane through COVID.

go-salesforce-sdk's People

Contributors

beeekind avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

dcarbone

go-salesforce-sdk's Issues

Install issue

When running go get to install , I get:

go: github.com/beeekind/go-salesforce-sdk@upgrade (v0.0.1-alpha) requires github.com/beeekind/[email protected]: parsing go.mod:
module declares its path as: github.com/b3ntly/salesforce
but was required as: github.com/beeekind/go-salesforce-sdk

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.