Documentation
¶
Overview ¶
A Go package that provides bindings to the force.com REST API
Index ¶
- Constants
- func BuildQuery(fields, table string, constraints []string) string
- type ApiError
- type ApiErrors
- type ChildRelationship
- type CompositeRequest
- type CompositeRequests
- type CompositeResponse
- type CompositeResponses
- type ForceApi
- func Create(version, clientId, clientSecret, userName, password, securityToken, ... string) (*ForceApi, error)
- func CreateWithAccessToken(version, clientId, accessToken, instanceUrl string) (*ForceApi, error)
- func CreateWithAccessTokenOnly(version, clientId, accessToken, instanceUrl string) (*ForceApi, error)
- func CreateWithRefreshToken(version, clientId, accessToken, instanceUrl string) (*ForceApi, error)
- func CreateWithoutResources(version, clientId, clientSecret, userName, password string) (*ForceApi, error)
- func (forceApi *ForceApi) CompositeDeleteSObject(id string, obj SObject, referenceID string) *CompositeRequest
- func (forceApi *ForceApi) CompositeGetSObject(id string, obj SObject, fields []string, referenceID string) *CompositeRequest
- func (forceApi *ForceApi) CompositeInsertSObject(in SObject, referenceID string) *CompositeRequest
- func (forceApi *ForceApi) CompositeQuery(query string, referenceID string) *CompositeRequest
- func (forceApi *ForceApi) CompositeUpdateSObject(id string, in SObject, referenceID string) *CompositeRequest
- func (forceApi *ForceApi) Delete(path string, params url.Values) error
- func (forceApi *ForceApi) DeleteSObject(id string, in SObject) (err error)
- func (forceApi *ForceApi) DeleteSObjectByExternalId(id string, in SObject) (err error)
- func (forceApi *ForceApi) DescribeSObject(in SObject) (resp *SObjectDescription, err error)
- func (forceAPI *ForceApi) DescribeSObjects() (map[string]*SObjectMetaData, error)
- func (forceApi *ForceApi) Get(path string, params url.Values, out interface{}) error
- func (forceApi *ForceApi) GetAccessToken() string
- func (forceApi *ForceApi) GetInstanceURL() string
- func (forceApi *ForceApi) GetLimits() (limits *Limits, err error)
- func (forceApi *ForceApi) GetSObject(id string, fields []string, out SObject) (err error)
- func (forceApi *ForceApi) GetSObjectByExternalId(id string, fields []string, out SObject) (err error)
- func (forceApi *ForceApi) InsertSObject(in SObject) (resp *SObjectResponse, err error)
- func (forceApi *ForceApi) Patch(path string, params url.Values, payload, out interface{}) error
- func (forceApi *ForceApi) Post(path string, params url.Values, payload, out interface{}) error
- func (forceApi *ForceApi) PostCompositeRequests(in *CompositeRequests) (resp *CompositeResponses, err error)
- func (forceApi *ForceApi) Put(path string, params url.Values, payload, out interface{}) error
- func (forceApi *ForceApi) Query(query string, out interface{}) (err error)
- func (forceApi *ForceApi) QueryAll(query string, out interface{}) (err error)
- func (forceApi *ForceApi) QueryNext(uri string, out interface{}) (err error)
- func (forceApi *ForceApi) RefreshToken() error
- func (forceApi *ForceApi) SObjCollectionCreate(in SObjCollection, allOrNone bool) (*SObjCollectionResponse, error)
- func (forceApi *ForceApi) SetAPIResources(src io.Reader) error
- func (forceApi *ForceApi) SetAPISObjects(src io.Reader) error
- func (forceApi *ForceApi) TraceOff()
- func (forceApi *ForceApi) TraceOn(prefix string, logger ForceApiLogger)
- func (forceApi *ForceApi) UpdateSObject(id string, in SObject) (err error)
- func (forceApi *ForceApi) UpsertSObjectByExternalId(id string, in SObject) (resp *SObjectResponse, err error)
- type ForceApiLogger
- type Limit
- type Limits
- type PicklistValue
- type RecordTypeInfo
- type RefreshTokenResponse
- type SObjCollection
- type SObjCollectionRequest
- type SObjCollectionResponse
- type SObject
- type SObjectApiResponse
- type SObjectDescription
- type SObjectField
- type SObjectMetaData
- type SObjectResponse
Constants ¶
const (
BaseQueryString = "SELECT %v FROM %v"
)
Variables ¶
This section is empty.
Functions ¶
func BuildQuery ¶
Types ¶
type ApiError ¶
type ApiError struct { Fields []string `json:"fields,omitempty" force:"fields,omitempty"` Message string `json:"message,omitempty" force:"message,omitempty"` ErrorCode string `json:"errorCode,omitempty" force:"errorCode,omitempty"` ErrorName string `json:"error,omitempty" force:"error,omitempty"` ErrorDescription string `json:"error_description,omitempty" force:"error_description,omitempty"` }
type ChildRelationship ¶
type CompositeRequest ¶
type CompositeRequest struct { Method string `force:"method,omitempty"` URL string `force:"url,omitempty"` HTTPHeaders map[string]string `force:"httpHeaders,omitempty"` Body interface{} `force:"body,omitempty"` ReferenceID string `force:"referenceId,omitempty"` }
CompositeRequest defines a single request
type CompositeRequests ¶
type CompositeRequests struct { AllOrNone bool `force:"allOrNone,omitempty"` CompositeRequest []CompositeRequest `force:"compositeRequest,omitempty"` }
CompositeRequests is a struct that contains all requests to be executed AllOrNone reverts all requests if a single request fails
func (*CompositeRequests) Add ¶
func (requests *CompositeRequests) Add(request *CompositeRequest)
Add adds a request object to the CompositeRequests struct so that when it is executed, all containing requests are processed
type CompositeResponse ¶
type CompositeResponse struct { Body json.RawMessage `force:"body,omitempty"` HTTPHeaders map[string]string `force:"httpHeaders,omitempty"` HTTPStatusCode int `force:"httpStatusCode,omitempty"` ReferenceID string `force:"referenceId,omitempty"` }
CompositeResponse describes the response to a single request
type CompositeResponses ¶
type CompositeResponses struct {
CompositeResponse []CompositeResponse `force:"compositeResponse,omitempty"`
}
CompositeResponses contains the responses to each request made
type ForceApi ¶
type ForceApi struct {
// contains filtered or unexported fields
}
func CreateWithAccessToken ¶
func CreateWithRefreshToken ¶
func CreateWithoutResources ¶
func (*ForceApi) CompositeDeleteSObject ¶
func (forceApi *ForceApi) CompositeDeleteSObject(id string, obj SObject, referenceID string) *CompositeRequest
CompositeDeleteSObject generates a CompositeRequest in the format of a DeleteSObject @Params (obj SObject) only needs an empty object to define SObject type
func (*ForceApi) CompositeGetSObject ¶
func (forceApi *ForceApi) CompositeGetSObject(id string, obj SObject, fields []string, referenceID string) *CompositeRequest
CompositeGetSObject generates a CompositeRequest in the format of a GetSObject @Params (obj SObject) only needs an empty object to define SObject type
func (*ForceApi) CompositeInsertSObject ¶
func (forceApi *ForceApi) CompositeInsertSObject(in SObject, referenceID string) *CompositeRequest
CompositeInsertSObject generates a CompositeRequest in the format of a InsertSObject
func (*ForceApi) CompositeQuery ¶
func (forceApi *ForceApi) CompositeQuery(query string, referenceID string) *CompositeRequest
CompositeQuery generates a CompositeRequest in the format of a Query
func (*ForceApi) CompositeUpdateSObject ¶
func (forceApi *ForceApi) CompositeUpdateSObject(id string, in SObject, referenceID string) *CompositeRequest
CompositeUpdateSObject generates a CompositeRequest in the format of a UpdateSObject
func (*ForceApi) DeleteSObject ¶
func (*ForceApi) DeleteSObjectByExternalId ¶
func (*ForceApi) DescribeSObject ¶
func (forceApi *ForceApi) DescribeSObject(in SObject) (resp *SObjectDescription, err error)
func (*ForceApi) DescribeSObjects ¶
func (forceAPI *ForceApi) DescribeSObjects() (map[string]*SObjectMetaData, error)
func (*ForceApi) Get ¶
Get issues a GET to the specified path with the given params and put the umarshalled (json) result in the third parameter
func (*ForceApi) GetAccessToken ¶
func (*ForceApi) GetInstanceURL ¶
func (*ForceApi) GetSObject ¶
func (*ForceApi) GetSObjectByExternalId ¶
func (*ForceApi) InsertSObject ¶
func (forceApi *ForceApi) InsertSObject(in SObject) (resp *SObjectResponse, err error)
func (*ForceApi) Patch ¶
Patch issues a PATCH to the specified path with the given params and payload and put the unmarshalled (json) result in the third parameter
func (*ForceApi) Post ¶
Post issues a POST to the specified path with the given params and payload and put the unmarshalled (json) result in the third parameter
func (*ForceApi) PostCompositeRequests ¶
func (forceApi *ForceApi) PostCompositeRequests(in *CompositeRequests) (resp *CompositeResponses, err error)
PostCompositeRequests performs a composite request Salesforce API used must be v39.0 or greater
func (*ForceApi) Put ¶
Put issues a PUT to the specified path with the given params and payload and put the unmarshalled (json) result in the third parameter
func (*ForceApi) Query ¶
Use the Query resource to execute a SOQL query that returns all the results in a single response, or if needed, returns part of the results and an identifier used to retrieve the remaining results.
func (*ForceApi) QueryAll ¶
Use the QueryAll resource to execute a SOQL query that includes information about records that have been deleted because of a merge or delete. Use QueryAll rather than Query, because the Query resource will automatically filter out items that have been deleted.
func (*ForceApi) RefreshToken ¶
func (*ForceApi) SObjCollectionCreate ¶
func (forceApi *ForceApi) SObjCollectionCreate(in SObjCollection, allOrNone bool) (*SObjCollectionResponse, error)
SObjCollectionCreate creates a batch create request
func (*ForceApi) SetAPIResources ¶
SetAPIResources populates the forceApi.apiResources
func (*ForceApi) SetAPISObjects ¶
SetAPISObjects populates forceAPi.apiSObjects manually
func (*ForceApi) TraceOff ¶
func (forceApi *ForceApi) TraceOff()
TraceOff turns off tracing. It is idempotent.
func (*ForceApi) TraceOn ¶
func (forceApi *ForceApi) TraceOn(prefix string, logger ForceApiLogger)
TraceOn turns on logging for this ForceApi. After this is called, all requests, responses, and raw response bodies will be sent to the logger. If prefix is a non-empty string, it will be written to the front of all logged strings, which can aid in filtering log lines.
Use TraceOn if you want to spy on the ForceApi requests and responses.
Note that the base log.Logger type satisfies ForceApiLogger, but adapters can easily be written for other logging packages (e.g., the golang-sanctioned glog framework).
func (*ForceApi) UpdateSObject ¶
func (*ForceApi) UpsertSObjectByExternalId ¶
func (forceApi *ForceApi) UpsertSObjectByExternalId(id string, in SObject) (resp *SObjectResponse, err error)
type ForceApiLogger ¶
type ForceApiLogger interface {
Printf(format string, v ...interface{})
}
type PicklistValue ¶
type RecordTypeInfo ¶
type RefreshTokenResponse ¶
type SObjCollection ¶
type SObjCollection []SObject
type SObjCollectionRequest ¶
type SObjCollectionRequest struct { AllOrNone bool `force:"allOrNone,omitempty"` Records []SObject `force:"records,omitempty"` }
SObjCollectionRequest marshals to an SObject Collections Request https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobjects_collections_create.htm
type SObjCollectionResponse ¶
type SObjCollectionResponse []SObjectResponse
type SObjectApiResponse ¶
type SObjectApiResponse struct { Encoding string `json:"encoding"` MaxBatchSize int64 `json:"maxBatchSize"` SObjects []*SObjectMetaData `json:"sobjects"` }
type SObjectDescription ¶
type SObjectDescription struct { Name string `json:"name"` Fields []*SObjectField `json:"fields"` KeyPrefix string `json:"keyPrefix"` Layoutable bool `json:"layoutable"` Activateable bool `json:"activateable"` LabelPlural string `json:"labelPlural"` Custom bool `json:"custom"` CompactLayoutable bool `json:"compactLayoutable"` Label string `json:"label"` Searchable bool `json:"searchable"` URLs map[string]string `json:"urls"` Queryable bool `json:"queryable"` Deletable bool `json:"deletable"` Updateable bool `json:"updateable"` Createable bool `json:"createable"` CustomSetting bool `json:"customSetting"` Undeletable bool `json:"undeletable"` Mergeable bool `json:"mergeable"` Replicateable bool `json:"replicateable"` Triggerable bool `json:"triggerable"` FeedEnabled bool `json:"feedEnabled"` Retrievable bool `json:"retrieveable"` SearchLayoutable bool `json:"searchLayoutable"` LookupLayoutable bool `json:"lookupLayoutable"` Listviewable bool `json:"listviewable"` DeprecatedAndHidden bool `json:"deprecatedAndHidden"` RecordTypeInfos []*RecordTypeInfo `json:"recordTypeInfos"` ChildRelationsips []*ChildRelationship `json:"childRelationships"` AllFields string `json:"-"` // Not from force.com API. Used to generate SELECT * queries. }
type SObjectField ¶
type SObjectField struct { Length float64 `json:"length"` Name string `json:"name"` Type string `json:"type"` DefaultValue string `json:"defaultValue"` RestrictedPicklist bool `json:"restrictedPicklist"` NameField bool `json:"nameField"` ByteLength float64 `json:"byteLength"` Precision float64 `json:"precision"` Filterable bool `json:"filterable"` Sortable bool `json:"sortable"` Unique bool `json:"unique"` CaseSensitive bool `json:"caseSensitive"` Calculated bool `json:"calculated"` Scale float64 `json:"scale"` Label string `json:"label"` NamePointing bool `json:"namePointing"` Custom bool `json:"custom"` HtmlFormatted bool `json:"htmlFormatted"` DependentPicklist bool `json:"dependentPicklist"` Permissionable bool `json:"permissionable"` ReferenceTo []string `json:"referenceTo"` RelationshipOrder float64 `json:"relationshipOrder"` SoapType string `json:"soapType"` CalculatedValueFormula string `json:"calculatedValueFormula"` DefaultValueFormula string `json:"defaultValueFormula"` DefaultedOnCreate bool `json:"defaultedOnCreate"` Digits float64 `json:"digits"` Groupable bool `json:"groupable"` Nillable bool `json:"nillable"` InlineHelpText string `json:"inlineHelpText"` WriteRequiresMasterRead bool `json:"writeRequiresMasterRead"` PicklistValues []*PicklistValue `json:"picklistValues"` Updateable bool `json:"updateable"` Createable bool `json:"createable"` DeprecatedAndHidden bool `json:"deprecatedAndHidden"` DisplayLocationInDecimal bool `json:"displayLocationInDecimal"` CascadeDelete bool `json:"cascasdeDelete"` RestrictedDelete bool `json:"restrictedDelete"` ControllerName string `json:"controllerName"` ExternalId bool `json:"externalId"` IdLookup bool `json:"idLookup"` AutoNumber bool `json:"autoNumber"` RelationshipName string `json:"relationshipName"` }
type SObjectMetaData ¶
type SObjectMetaData struct { Name string `json:"name"` Label string `json:"label"` KeyPrefix string `json:"keyPrefix"` LabelPlural string `json:"labelPlural"` Custom bool `json:"custom"` Layoutable bool `json:"layoutable"` Activateable bool `json:"activateable"` URLs map[string]string `json:"urls"` Searchable bool `json:"searchable"` Updateable bool `json:"updateable"` Createable bool `json:"createable"` DeprecatedAndHidden bool `json:"deprecatedAndHidden"` CustomSetting bool `json:"customSetting"` Deletable bool `json:"deletable"` FeedEnabled bool `json:"feedEnabled"` Mergeable bool `json:"mergeable"` Queryable bool `json:"queryable"` Replicateable bool `json:"replicateable"` Retrieveable bool `json:"retrieveable"` Undeletable bool `json:"undeletable"` Triggerable bool `json:"triggerable"` }
type SObjectResponse ¶
type SObjectResponse struct { Id string `force:"id,omitempty"` Errors ApiErrors `force:"error,omitempty"` //TODO: Not sure if ApiErrors is the right object Success bool `force:"success,omitempty"` }
Response received from force.com API after insert of an sobject.