Skip to content

Latest commit

 

History

History
71 lines (65 loc) · 1.78 KB

README.md

File metadata and controls

71 lines (65 loc) · 1.78 KB

Composite Batch API

back

The batch package is an implementation of Salesforce APIs centered on Composite Batch operations. These operations include:

  • Limits Resources
  • SObject Resources
  • Query All
  • Query
  • Search
  • Connect Resources
  • Chatter Resources

As a reference, see Salesforce API documentation

Examples

The following are examples to access the APIs. It is assumed that a sfdc session has been created.

Subrequest

type batchSubrequester struct {
	url             string
	method          string
	richInput       map[string]interface{}
	binaryPartName  string
	binaryPartAlais string
}

func (b *batchSubrequester) URL() string {
	return b.url
}
func (b *batchSubrequester) Method() string {
	return b.method
}
func (b *batchSubrequester) BinaryPartName() string {
	return b.binaryPartName
}
func (b *batchSubrequester) BinaryPartNameAlias() string {
	return b.binaryPartAlais
}
func (b *batchSubrequester) RichInput() map[string]interface{} {
	return b.richInput
}

Composite Batch

	subRequests := []batch.Subrequester{
		&batchSubrequester{
			url:    "v44.0/sobjects/Account/0012E00001qLpKZQA0",
			method: http.MethodPatch,
			richInput: map[string]interface{}{
				"Name": "NewName",
			},
		},
		&batchSubrequester{
			url:    "v44.0/sobjects/Account/0012E00001qLpKZQA0",
			method: http.MethodGet,
		},
	}

	resource, err := batch.NewResource(session)
	if err != nil {
		fmt.Printf("Batch Composite Error %s\n", err.Error())
		return
	}
	value, err := resource.Retrieve(false, subRequests)
	if err != nil {
		fmt.Printf("Batch Composite Error %s\n", err.Error())
		return
	}

	fmt.Printf("%+v\n", value)