Documentation
¶
Index ¶
- type Client
- func (c *Client) CreaetSobject(sobjectName string, sobject interface{}) (id string, err error)
- func (c *Client) DeleteSobject(sobjectName, sobjectID string) error
- func (c *Client) Do(op Operator) error
- func (c *Client) GetSobject(sobjectName, sobjectID string, target interface{}) error
- func (c *Client) QuerySobject(op *OpQuery) (result *QueryResult, err error)
- func (c *Client) Resources() (resources map[string]string, err error)
- func (c *Client) SobjectInfo() (info map[string]interface{}, err error)
- func (c *Client) UpdateSobject(sobjectName, sobjectID string, sobject interface{}) error
- func (c *Client) Versions() (versions []*Version, err error)
- type Config
- type Logger
- type OpQuery
- func (op *OpQuery) From(sobjectName string) *OpQuery
- func (op *OpQuery) Handle(resp *http.Response) error
- func (op *OpQuery) Limit(n int) *OpQuery
- func (op *OpQuery) Make(ctx *RequestCtx) (*Request, error)
- func (op *OpQuery) OrderAsc(field string) *OpQuery
- func (op *OpQuery) OrderDesc(field string) *OpQuery
- func (op *OpQuery) OrderNullFirst() *OpQuery
- func (op *OpQuery) OrderNullLast() *OpQuery
- func (op *OpQuery) OrderReset() *OpQuery
- func (op *OpQuery) Select(fields ...string) *OpQuery
- func (op *OpQuery) Where(field string, condition interface{}) *OpQuery
- type Operator
- type QueryResult
- type Request
- type RequestCtx
- func (ctx *RequestCtx) BaseURL() string
- func (ctx *RequestCtx) QueryURL(q string) string
- func (ctx *RequestCtx) SobjectURL() string
- func (ctx *RequestCtx) SobjectURLWithID(sobjectName, sobjectID string) string
- func (ctx *RequestCtx) SobjectURLWithName(sobjectName string) string
- func (ctx *RequestCtx) VersionURL() string
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client Type
func (*Client) CreaetSobject ¶
CreaetSobject creates sobject by given sobject name and entity.
func (*Client) DeleteSobject ¶
DeleteSobject deletes sobject by given sobject name and id.
func (*Client) Do ¶
Do uses op Operator to make request, send it to salesforce, receieve response and pass it to the Operator to handle.
func (*Client) GetSobject ¶
GetSobject get sobject by given sobject name and id, use target to receive the result.
func (*Client) QuerySobject ¶
func (c *Client) QuerySobject(op *OpQuery) (result *QueryResult, err error)
QuerySobject query sobject or sobjects by given op OpQuery. See also OpQuery.
func (*Client) SobjectInfo ¶
SobjectInfo shows the basic information of given sobject name.
func (*Client) UpdateSobject ¶
UpdateSobject updates sobject by given sobject name, id and entity contains changes.
type Config ¶
type Config struct { // auth Host string `json:"host"` ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` Username string `json:"username"` Password string `json:"password"` ExpiresIn int `json:"expires_in"` // api APIVersion int `json:"api_version"` // proxy url ProxyURL string `json:"proxy_url"` }
Config type
type Logger ¶
type Logger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) }
Logger inteface
type OpQuery ¶
type OpQuery struct {
// contains filtered or unexported fields
}
OpQuery is a request for quering SObject. Set which Sobject type and fileds to query by Select() and From() is necessary. The reset operations below is optional:
- OrderDesc(), OrderAsc(), OrderReset(), OrderNullFirst(), OrderNullLast() to control ORDER key.
- Limit() to control LIMIT key
See the methods' doc for more details.
func NewOpQuery ¶
NewOpQuery returns a OpQuery instance with given sobjectName.
func (*OpQuery) Limit ¶
Limit defines the max records will be return. if n==0, will treat it as a signal to reset limitation to unlimited.
func (*OpQuery) Make ¶
func (op *OpQuery) Make(ctx *RequestCtx) (*Request, error)
Make request by given request context.
func (*OpQuery) OrderNullFirst ¶
OrderNullFirst make null null column value first in query results when given order column.
func (*OpQuery) OrderNullLast ¶
OrderNullLast make null column value last in query results when given order column.
func (*OpQuery) OrderReset ¶
OrderReset resets the order statment=="".
type Operator ¶
type Operator interface { // Make request by given request context. Make(*RequestCtx) (*Request, error) // Handle success response from salesforce. Handle(*http.Response) error }
Operator can make a *http.Request instance according to given request ctx for http.Client to send request to salesforce or returns an error. It can also handle the response responded from salesforce.
type QueryResult ¶
type QueryResult struct { TotalSize int `json:"totalSize"` Done bool `json:"done"` Records []interface{} `json:"records"` }
QueryResult is the result of a query operation.
func (*QueryResult) Parse ¶
func (r *QueryResult) Parse(targets interface{}) error
Parse parses the result.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request can make a http.Request instance which contains json-format body if data provided.
func NewRequest ¶
NewRequest returns a new Request given a method, URL, and optional data.
type RequestCtx ¶
type RequestCtx struct {
// contains filtered or unexported fields
}
RequestCtx holds the host and api version informations.
func (*RequestCtx) BaseURL ¶
func (ctx *RequestCtx) BaseURL() string
BaseURL returns the base URL of salesforce restful api. Assume host is "https://instance.salesforce.com", baseURL will be "https://instance.salesforce.com/services/data"
func (*RequestCtx) QueryURL ¶
func (ctx *RequestCtx) QueryURL(q string) string
QueryURL returns the URL with query SOQL statments, like: "https://instance.salesforce.com/services/data/v24.0/query?q=SELECT+Id,+Name+FROM+User"
func (*RequestCtx) SobjectURL ¶
func (ctx *RequestCtx) SobjectURL() string
SobjectURL returns the URL can work with SObjects, like: "https://instance.salesforce.com/services/data/v36.0/sobjects"
func (*RequestCtx) SobjectURLWithID ¶
func (ctx *RequestCtx) SobjectURLWithID(sobjectName, sobjectID string) string
SobjectURLWithID returns the URL with specific sobject and id. Assume the given sobject is 'User' and id is '00e28000001K04LAA1', the return URL will be: "https://instance.salesforce.com/services/data/v36.0/sobjects/User/00e28000001K04LAA1"
func (*RequestCtx) SobjectURLWithName ¶
func (ctx *RequestCtx) SobjectURLWithName(sobjectName string) string
SobjectURLWithName returns the URL with specific sobject. Assume the given sobject is 'User', the return URL will be: "https://instance.salesforce.com/services/data/v36.0/sobjects/User"
func (*RequestCtx) VersionURL ¶
func (ctx *RequestCtx) VersionURL() string
VersionURL returns the URL with version, like: "https://instance.salesforce.com/services/data/v36.0"