Documentation ¶
Index ¶
- Constants
- Variables
- func ParseSalesforceError(statusCode int, responseBody []byte) (err error)
- type Client
- func (client *Client) DescribeGlobal() (*SObjectMeta, error)
- func (client *Client) DownloadFile(contentVersionID string, filepath string) error
- func (client *Client) ExecuteAnonymous(apexBody string) (*ExecuteAnonymousResult, error)
- func (client *Client) GetLoc() (loc string)
- func (client *Client) GetSid() (sid string)
- func (client *Client) LoginPassword(username, password, token string) error
- func (client *Client) Query(q string) (*QueryResult, error)
- func (client *Client) SObject(typeName ...string) *SObject
- func (client *Client) SetHttpClient(c *http.Client)
- func (client *Client) SetSidLoc(sid string, loc string)
- func (client *Client) Tooling() *Client
- func (client *Client) UnTooling()
- type ExecuteAnonymousResult
- type QueryResult
- type SObject
- func (obj *SObject) AttributesField() *SObjectAttributes
- func (obj *SObject) Create() *SObject
- func (obj *SObject) Delete(id ...string) error
- func (obj *SObject) Describe() *map[string]interface{}
- func (obj *SObject) Get(id ...string) *SObject
- func (obj *SObject) ID() string
- func (obj *SObject) InterfaceField(key string) interface{}
- func (obj *SObject) SObjectField(typeName, key string) *SObject
- func (obj *SObject) Set(key string, value interface{}) *SObject
- func (obj *SObject) StringField(key string) string
- func (obj *SObject) Type() string
- func (obj *SObject) Update() *SObject
- type SObjectAttributes
- type SObjectMeta
Constants ¶
const ( DefaultAPIVersion = "43.0" DefaultClientID = "simpleforce" DefaultURL = "https://login.salesforce.com" )
Variables ¶
var ( // ErrFailure is a generic error if none of the other errors are appropriate. ErrFailure = errors.New("general failure") // ErrAuthentication is returned when authentication failed. ErrAuthentication = errors.New("authentication failure") )
Functions ¶
func ParseSalesforceError ¶
Need to get information out of this package.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main instance to access salesforce.
func (*Client) DescribeGlobal ¶
func (client *Client) DescribeGlobal() (*SObjectMeta, error)
Get the List of all available objects and their metadata for your organization's data
func (*Client) DownloadFile ¶
DownloadFile downloads a file based on the REST API path given. Saves to filePath.
func (*Client) ExecuteAnonymous ¶
func (client *Client) ExecuteAnonymous(apexBody string) (*ExecuteAnonymousResult, error)
ExecuteAnonymous executes a body of Apex code
func (*Client) LoginPassword ¶
LoginPassword signs into salesforce using password. token is optional if trusted IP is configured. Ref: https://developer.salesforce.com/docs/atlas.en-us.214.0.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm Ref: https://developer.salesforce.com/docs/atlas.en-us.214.0.api.meta/api/sforce_api_calls_login.htm
func (*Client) Query ¶
func (client *Client) Query(q string) (*QueryResult, error)
Query runs an SOQL query. q could either be the SOQL string or the nextRecordsURL.
func (*Client) SObject ¶
SObject creates an SObject instance with provided type name and associate the SObject with the client.
func (*Client) SetHttpClient ¶
type ExecuteAnonymousResult ¶
type ExecuteAnonymousResult struct { Line int `json:"line"` Column int `json:"column"` Compiled bool `json:"compiled"` Success bool `json:"success"` CompileProblem interface{} `json:"compileProblem"` ExceptionStackTrace interface{} `json:"exceptionStackTrace"` ExceptionMessage interface{} `json:"exceptionMessage"` }
ExecuteAnonymousResult is returned by ExecuteAnonymous function
type QueryResult ¶
type QueryResult struct { TotalSize int `json:"totalSize"` Done bool `json:"done"` NextRecordsURL string `json:"nextRecordsUrl"` Records []SObject `json:"records"` }
QueryResult holds the response data from an SOQL query.
type SObject ¶
type SObject map[string]interface{}
SObject describes an instance of SObject. Ref: https://developer.salesforce.com/docs/atlas.en-us.214.0.api_rest.meta/api_rest/resources_sobject_basic_info.htm
func (*SObject) AttributesField ¶
func (obj *SObject) AttributesField() *SObjectAttributes
AttributesField returns a read-only copy of the attributes field of an SObject.
func (*SObject) Create ¶
Create posts the JSON representation of the SObject to salesforce to create the entry. If the creation is successful, the ID of the SObject instance is updated with the ID returned. Otherwise, nil is returned for failures. Ref: https://developer.salesforce.com/docs/atlas.en-us.214.0.api_rest.meta/api_rest/dome_sobject_create.htm
func (*SObject) Delete ¶
Delete deletes an SObject record identified by external ID. nil is returned if the operation completes successfully; otherwise an error is returned
func (*SObject) Describe ¶
Describe queries the metadata of an SObject using the "describe" API. Ref: https://developer.salesforce.com/docs/atlas.en-us.214.0.api_rest.meta/api_rest/resources_sobject_describe.htm
func (*SObject) Get ¶
Get retrieves all the data fields of an SObject. If id is provided, the SObject with the provided external ID will be retrieved; otherwise, the existing ID of the SObject will be checked. If the SObject doesn't contain an ID field and id is not provided as the parameter, nil is returned. If query is successful, the SObject is updated in-place and exact same address is returned; otherwise, nil is returned if failed.
func (*SObject) InterfaceField ¶
InterfaceField accesses a field in the SObject as raw interface. This allows access to any type of fields.
func (*SObject) SObjectField ¶
SObjectField accesses a field in the SObject as another SObject. This is only applicable if the field is an external ID to another object. The typeName of the SObject must be provided. <nil> is returned if the field is empty.
func (*SObject) Set ¶
Set indexes value into SObject instance with provided key. The same SObject pointer is returned to allow chained access.
func (*SObject) StringField ¶
StringField accesses a field in the SObject as string. Empty string is returned if the field doesn't exist.
type SObjectAttributes ¶
SObjectAttributes describes the basic attributes (type and url) of an SObject.
type SObjectMeta ¶
type SObjectMeta map[string]interface{}
SObjectMeta describes the metadata returned by describing the object. Ref: https://developer.salesforce.com/docs/atlas.en-us.214.0.api_rest.meta/api_rest/resources_sobject_describe.htm