Documentation
¶
Overview ¶
Package composite provides Composite API operations.
Index ¶
- type BatchRequest
- type BatchResponse
- type BatchSubrequest
- type BatchSubresponse
- type CollectionRequest
- type CollectionResponse
- type CollectionResult
- type Error
- type Graph
- type GraphRequest
- type GraphResponse
- type GraphResult
- type HTTPClient
- type Request
- type Response
- type Service
- func (s *Service) CreateCollection(ctx context.Context, records []interface{}, allOrNone bool) (CollectionResponse, error)
- func (s *Service) CreateTree(ctx context.Context, objectType string, records []TreeRecord) (*TreeResponse, error)
- func (s *Service) DeleteCollection(ctx context.Context, ids []string, allOrNone bool) (CollectionResponse, error)
- func (s *Service) Execute(ctx context.Context, req Request) (*Response, error)
- func (s *Service) ExecuteBatch(ctx context.Context, req BatchRequest) (*BatchResponse, error)
- func (s *Service) ExecuteGraph(ctx context.Context, req GraphRequest) (*GraphResponse, error)
- func (s *Service) GetCollection(ctx context.Context, objectType string, ids []string, fields []string) ([]map[string]interface{}, error)
- func (s *Service) UpdateCollection(ctx context.Context, records []interface{}, allOrNone bool) (CollectionResponse, error)
- type Subrequest
- type Subresponse
- type TreeAttributes
- type TreeRecord
- type TreeRequest
- type TreeResponse
- type TreeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchRequest ¶
type BatchRequest struct {
BatchRequests []BatchSubrequest `json:"batchRequests"`
HaltOnError bool `json:"haltOnError,omitempty"`
}
BatchRequest represents a batch request.
type BatchResponse ¶
type BatchResponse struct {
HasErrors bool `json:"hasErrors"`
Results []BatchSubresponse `json:"results"`
}
BatchResponse represents a batch response.
type BatchSubrequest ¶
type BatchSubrequest struct {
Method string `json:"method"`
URL string `json:"url"`
RichInput interface{} `json:"richInput,omitempty"`
}
BatchSubrequest represents a single batch subrequest.
type BatchSubresponse ¶
type BatchSubresponse struct {
StatusCode int `json:"statusCode"`
Result interface{} `json:"result"`
}
BatchSubresponse represents a single batch subresponse.
type CollectionRequest ¶
type CollectionRequest struct {
AllOrNone bool `json:"allOrNone"`
Records []interface{} `json:"records"`
}
CollectionRequest represents an SObject Collections request.
type CollectionResponse ¶
type CollectionResponse []CollectionResult
CollectionResponse represents an SObject Collections response.
type CollectionResult ¶
type CollectionResult struct {
ID string `json:"id"`
Success bool `json:"success"`
Errors []Error `json:"errors,omitempty"`
}
CollectionResult represents a single collection result.
type Error ¶
type Error struct {
StatusCode string `json:"statusCode"`
Message string `json:"message"`
Fields []string `json:"fields,omitempty"`
}
Error represents an API error.
type Graph ¶
type Graph struct {
GraphId string `json:"graphId"`
CompositeRequest []Subrequest `json:"compositeRequest"`
}
Graph represents a single graph in a graph request.
type GraphRequest ¶
type GraphRequest struct {
Graphs []Graph `json:"graphs"`
}
GraphRequest represents a Composite Graph request.
type GraphResponse ¶
type GraphResponse struct {
Graphs []GraphResult `json:"graphs"`
}
GraphResponse represents a Composite Graph response.
type GraphResult ¶
type GraphResult struct {
GraphId string `json:"graphId"`
IsSuccessful bool `json:"isSuccessful"`
GraphResponse Response `json:"graphResponse"`
}
GraphResult represents a single graph result.
type HTTPClient ¶
type HTTPClient interface {
Get(ctx context.Context, path string) ([]byte, error)
Post(ctx context.Context, path string, body interface{}) ([]byte, error)
Patch(ctx context.Context, path string, body interface{}) ([]byte, error)
Delete(ctx context.Context, path string) ([]byte, error)
}
HTTPClient interface for dependency injection.
type Request ¶
type Request struct {
AllOrNone bool `json:"allOrNone"`
CollateSubrequests bool `json:"collateSubrequests,omitempty"`
CompositeRequest []Subrequest `json:"compositeRequest"`
}
Request represents a composite API request.
type Response ¶
type Response struct {
CompositeResponse []Subresponse `json:"compositeResponse"`
}
Response represents a composite API response.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides Composite API operations.
func NewService ¶
func NewService(client HTTPClient, apiVersion string) *Service
NewService creates a new Composite service.
func (*Service) CreateCollection ¶
func (s *Service) CreateCollection(ctx context.Context, records []interface{}, allOrNone bool) (CollectionResponse, error)
CreateCollection creates multiple records using SObject Collections.
func (*Service) CreateTree ¶
func (s *Service) CreateTree(ctx context.Context, objectType string, records []TreeRecord) (*TreeResponse, error)
CreateTree creates records using SObject Tree.
func (*Service) DeleteCollection ¶
func (s *Service) DeleteCollection(ctx context.Context, ids []string, allOrNone bool) (CollectionResponse, error)
DeleteCollection deletes multiple records using SObject Collections.
func (*Service) ExecuteBatch ¶
func (s *Service) ExecuteBatch(ctx context.Context, req BatchRequest) (*BatchResponse, error)
ExecuteBatch executes a batch request.
func (*Service) ExecuteGraph ¶
func (s *Service) ExecuteGraph(ctx context.Context, req GraphRequest) (*GraphResponse, error)
ExecuteGraph executes a composite graph request.
func (*Service) GetCollection ¶
func (s *Service) GetCollection(ctx context.Context, objectType string, ids []string, fields []string) ([]map[string]interface{}, error)
GetCollection retrieves multiple records using SObject Collections.
func (*Service) UpdateCollection ¶
func (s *Service) UpdateCollection(ctx context.Context, records []interface{}, allOrNone bool) (CollectionResponse, error)
UpdateCollection updates multiple records using SObject Collections.
type Subrequest ¶
type Subrequest struct {
Method string `json:"method"`
URL string `json:"url"`
ReferenceId string `json:"referenceId"`
Body interface{} `json:"body,omitempty"`
HTTPHeaders map[string]string `json:"httpHeaders,omitempty"`
}
Subrequest represents a single subrequest in a composite request.
type Subresponse ¶
type Subresponse struct {
Body interface{} `json:"body"`
HTTPHeaders map[string]string `json:"httpHeaders"`
HTTPStatusCode int `json:"httpStatusCode"`
ReferenceId string `json:"referenceId"`
}
Subresponse represents a single subresponse.
func (*Subresponse) IsSuccess ¶
func (s *Subresponse) IsSuccess() bool
IsSuccess returns true if the subresponse was successful.
type TreeAttributes ¶
type TreeAttributes struct {
Type string `json:"type"`
ReferenceId string `json:"referenceId,omitempty"`
}
TreeAttributes contains record attributes for tree requests.
type TreeRecord ¶
type TreeRecord struct {
Attributes TreeAttributes `json:"attributes"`
ReferenceId string `json:"referenceId"`
Fields map[string]interface{}
}
TreeRecord represents a record in a tree request.
func (TreeRecord) MarshalJSON ¶
func (t TreeRecord) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for TreeRecord.
type TreeRequest ¶
type TreeRequest struct {
Records []TreeRecord `json:"records"`
}
TreeRequest represents an SObject Tree request.
type TreeResponse ¶
type TreeResponse struct {
HasErrors bool `json:"hasErrors"`
Results []TreeResult `json:"results"`
}
TreeResponse represents an SObject Tree response.
type TreeResult ¶
type TreeResult struct {
ID string `json:"id"`
ReferenceId string `json:"referenceId"`
Errors []Error `json:"errors,omitempty"`
}
TreeResult represents a single result in a tree response.